You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 52292db
Browse filesBrowse the repository at this point in the historyBrowse files
Session clock: read each day's occurrences once per bar; time() arguments resolved without copies (#339)
## What
`time(tf, session, tz)` with a script's own session argument reads TradingView's session clock outside UTC (#334). That path asked the per-day session cache about nine times a bar, and copied the session and zone strings on every `time()` / `time_close()` call. This PR reads each day's occurrences once per call, caches `utc_zone` per session-cache entry, and resolves the call's strings by reference. It changes one file, `src/session_time.cpp`: the language calendar functions under rule 1 of ADR 0001. It adds no switch, input, API or hashed state.
## Value identity (on this tree, against main)
- the old and new session functions run side by side over the whole suite: 0 mismatches;
- a differential over generated sessions, zones and timeframes, walking every DST switch of 2024–2026 minute by minute: 16.6 M queries, identical digest;
- an independent review repeated it with 33.2 M queries: 0 different answers, identical cache and zone-memo history, clean under ASan + UBSan;
- the 30 witness harvests: byte-identical, 0 re-pins;
- the whole-suite per-trade dump (all 21 Trade fields at `%.17g`, every state hash): identical apart from rows that differ between two runs of one tree;
- all 307 tape and witness executables: byte-identical;
- corpus 312/312, 0 moved.
## Timing (on this tree, against main 44eab7b)
Measured on a Xeon 8375C with 4 independent builds per tree, paired rotating blocks (81 per shape), and every process under exactly 22 environment variables. Positive means slower; `*` means the 95% interval covers 0. The **padded control** is this commit with every function outside `session_time.o` placed at main's address, checked symbol by symbol.
| | native | ta-sma | bracket | udt | composite-vcp |
|---|---|---|---|---|---|
| batch median, ungathered (1 m / 1 m) | +1.23 | +1.26 | +0.87 | +0.83 | **−9.54** |
| — padded control | +0.03* | +0.06* | +0.02* | −0.00* | **−7.93** |
| per call, ungathered | +0.21 | +0.04* | +0.19 | +0.10 | **−5.16** |
| — padded control | +0.05* | +0.01* | −0.02* | −0.02* | **−4.84** |
| stream p95, ungathered | +0.46 | +1.53 | +0.46 | +0.17 | **−3.07** |
| — padded control | +0.04* | +0.03* | −0.05* | +0.01* | **−3.46** |
| batch median, gathered (1 m / 3 m) | +0.60 | +0.09* | +0.54 | +0.41 | **−5.80** |
| — padded control | +0.06* | +0.06* | +0.05* | +0.09* | **−5.25** |
- **Only composite-vcp's work changes.** Its instruction count drops from 232.5 M to 220.1 M over 2 × 5,000 stream pushes, and from 2,512 to 1,275 per `timeframe_time` call.
- **The other four cases execute identical instructions.** Their differences against main are code placement: this file shrinks by 263 bytes and moves the hot functions by 192–256 bytes. With the layout held fixed (padded control), all four read 0 within noise on every metric. The commit message's table was measured with #336's tree as the base; the table above is this tree.
## Verification
- Engine verify bundles on this exact tree: release 859, sanitizers 837, debug 840, kernel 307 with 0 boundary findings, parity 312/312, subset, docs.
- One parity sweep of the full population on this head, paired with codegen main, is neutral: 7,989 comparable, no moves.
- An independent review returned MERGE; its message fixes are applied.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 commit comments