Repository navigation
Conversation
With signal eligibility declared, RuntimeServices checked every market field of every asset on every bar, though a bar at the current timestamp is always published to the inclusive clock when no known-at, eligibility or instrument lifetime applies. On 2.2M daily bars of 1,164 assets this took 95 of 132 seconds; a run now takes 30.
…between decisions MarketDataView built its asset/timestamp row index one Python row at a time and checked known-at timezones per row. It now groups row numbers by asset in Polars, shares one Python value per distinct instant, and checks timezone compatibility once per column. Duplicate and timezone errors are unchanged. RuntimeServices._advance looked up a signal row for every asset at every event although signal rows exist only at decisions. It now returns early at events with no signal row and nothing to mask, reads each signal row's masks from a table computed once in Polars (a row is read at its own timestamp, so its mask depends on the row alone), and checks an instrument lifetime once per asset instead of reading the bar and testing twelve fields. Measured on one monthly book over 1,165 assets x 2,264 sessions (2.2M bars): _bind 4.7 s -> 0.4 s, _advance 7.2 s -> 0.5 s, Engine.run 14.9 s -> 9.8 s, with identical fills and equity.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Maintainer review and repair
Reviewed contributor revision
c4d95dcf244817c6d3104962a9907573632d39c3. Its cached publication mask exposed a feature published 1 nanosecond after a millisecond/microsecond decision. Maintainer commit04adb82b3073670e1a2f7d49becc32df22aa9c2apreserves physical-time precision with overflow-safe integer comparison. Four causal regressions fail on the original contribution; all 12 precision/future-append cases pass after repair.The repaired wheel matches all 114 runtime modules and passes 155 installed RuntimeServices/history tests with the immutable Data/Engineer/Diagnostic cohort, zero skips. A public Engine portfolio using Engineer's real feature producer, 40 assets, 252 sessions, universe exclusions and missing observations matches main exactly: 406 fills, fees, observations, full equity series and final cash. No producer API change is required; publication/eligibility and decision-specific snapshot semantics remain authoritative.
The contributor's single-run timings below are retained as attributed observations, not adopted as retained benchmark claims. The existing 17 timed reference workflows do not instantiate RuntimeServices. Final integrated native evidence and all current-head hosted gates are still required before merge.
OpenAI Codex performed the maintainer review, wrote the precision repair/regressions, and ran the source and installed checks above. Original contributor commits and their AI disclosure are preserved. The author's unchecked accountability statement below has not been asserted on their behalf.
Owning issue
Closes #198
Outcome
RuntimeServicesdid per-bar Python work that cannot change its result. This change removes that work. Errors and results are unchanged.Bug regression evidence
Not a bug fix.
Compatibility
No numerical change: the same events reach the strategy with the same values.
tests/test_prepared_features.py::test_feature_values_reach_a_strategy_only_at_decisions_when_prices_have_events_between_them(added here, with and without late publication) covers the new early return. It passes on the base and on this PR. The benchmark below reads the same 48,000 signal values on both.Verification
Synthetic benchmark: 500 assets x 2,000 daily sessions, a prepared feature panel every 21 sessions (96 decisions) with eligibility declared,
RuntimeServices(), and a strategy that reads every asset's signal at each event and does not trade. Apple M4 Pro, macOS 15.5, Python 3.14.0, one run each:DataFeedEngine.run99ee997(src/restored tomain)c4d95dcbench_runtime.py (run from the repository root:
uv run python bench_runtime.py)On our own workload, one monthly book over about 1,165 US stocks x 2,264 sessions (2.2M bars): the first commit took a run from 132 s to 30 s. The second took
_bindfrom 4.7 s to 0.4 s,_advancefrom 7.2 s to 0.5 s andEngine.runfrom 14.9 s to 9.8 s, with identical fills and equity.These numbers come from outside your retained performance harness (#62). If one of its workloads covers
RuntimeServices, point me to it and I will add its numbers.Checks from
AGENTS.md, at this PR's revision:uv run ruff check src tests: all checks passeduv run ruff format --check src tests: 325 files already formatteduv run ty check: all checks passeduv run pytest: 3,187 passed, 125 skipped, 14 failed: the contract tests intests/contracts/test_parity_claim_generation.pyandtests/contracts/test_real_strategy_runner.pythat pin the engine source digest of the retained correctness and performance evidence (backtrader/01 engine digest is stale, ...). Onmainall pass (3,199 passed, 125 skipped). Requalifying that evidence needs the retained real-strategy bundles, which I do not have, so as in Close fractional positions exactly at zero target weight #195 it is left to your requalification.uv build: wheel and sdist builtBug regression fails on the base and passes with the fix, or this is not a bug fix
Ruff lint and format checks pass
typassesTest suite passes (all but the 14 digest-pinned contract tests above)
Package build passes when applicable
Strict MkDocs build passes when documentation is affected (no documentation change)
Ecosystem qualification passes (not run)
AI assistance
An AI coding agent (Claude Code) wrote the change, its test, the benchmark and this description, and ran the commands above.
Documentation and release
No documentation change. Release notes, under Changed or Performance: faster
RuntimeServicesbinding and event processing on prepared feature panels.