Repository navigation
perf(history): batch validation of reconstructed book levels - #16
Open
FlavioMili wants to merge 2 commits into
Open
FlavioMili wants to merge 2 commits into
FlavioMili wants to merge 2 commits into
Conversation
FlavioMili
marked this pull request as ready for review
October 9, 2026 20:48
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.
Historical reconstruction calls a Python
OrderLevelconstructor for every level of every emitted state. Pass level dictionaries intoHistoricalOrderBookinstead so its nested validator constructs the same validated models together. Decimal updates, ordering, metadata and independent output objects stay unchanged.The diff contains only the example change, regression tests, and one standalone benchmark. Generated investigation artifacts are excluded.
Three alternating pairs on synthetic books with 100 levels per side measured 23% less reconstruction time and 15% less time including JSON encoding (Python 3.13.5, Pydantic 2.14.0, Ryzen AI 7 350, CPU 0). Candidate/control ratios were 0.768 [0.762–0.771] and 0.855 [0.847–0.866], respectively; corresponding A/A ranges were [0.997–1.024] and [0.996–1.052]. A separate tracemalloc diagnostic measured about 37 KB more temporary peak memory at depth 100. These results concern client reconstruction, not network downloads or the hosted service; the Texas Senate dataset was not measured.
Reproduce with identical parameters for both sources, alternating order across seeds 1729, 2738 and 3747:
git show 53af00c49b184d8ae5c3a4e0755fc98b26c25694:examples/track_historical_book.py > /tmp/history-control.py python benchmarks/history_replay.py --replay-source /tmp/history-control.py --depth 100 --repeats 3 --seed 1729 --export python benchmarks/history_replay.py --depth 100 --repeats 3 --seed 1729 --exportOmit
--exportto isolate reconstruction. Use--response recorded-range.jsonfor a saved real API response. Measurements include response validation and full reconstruction after each delta; they exclude network and disk I/O.Validation: 10 historical tests pass, including output and JSON equality against the previous construction across depths 0–1000, deletion/reinsertion and output independence.