Repository navigation
perf(tui): restore steps -- 8.8% less time - #46
Merged
Merged
Conversation
Reuse local CPU, checkpoint and method references during exact-step restoration, and avoid duplicate loop-history dictionary lookups. The frozen large-seek workload takes 8.8% less wall time across three fresh paired runs. All 287 tests and Ruff checks pass. Co-Authored-By: Aiden <aiden@weco.ai>
sql-hkr
approved these changes
Oct 26, 2026
sql-hkr
left a comment
Owner
There was a problem hiding this comment.
LGTM! Clean and safe micro-optimization. Thanks for the performance improvement!
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
TL;DR
CheckpointManager.restore_exact_stepand itsdetect_loopandrecordhelpers for large checkpoint seeks.test_goto_large_step_via_cache_and_dynamic_extensiontakes 8.8% less wall time: median paired ratio 0.912 across three fresh harness runs.Problem and change
Large seeks extend the checkpoint cache one CPU instruction at a time. Each iteration repeatedly resolves CPU attributes and bound methods, while loop detection probes the same history dictionary twice for existing signatures.
Bind the CPU, checkpoint containers and frequently used methods locally, and use
history.getto retrieve a previous step with one lookup. History values are integer step counts, soNonedistinguishes a missing entry from step zero. Execution order, loop checks, history updates, snapshot ordering, trace handling and public signatures remain unchanged. No dependencies or persistent caches are added.Measurements
The workload retains the repository test's precompute-to-5,000, seek-to-4,500 and extend-to-20,000 sequence. It also includes seeded variations and boundary cases for backward seeks, tracing, snapshot caps, memory and stack instructions, halts, cycles, empty caches and invalid requests.
Measurements used Python 3.12.13 and the frozen evaluator on an isolated benchmark slot. Each run used nine interleaved baseline/candidate pairs, fresh seeded inputs, three workload repetitions per sample, a parent-process wall clock, and a separate pristine-baseline oracle. The timed batches include the workload's state observations; these are not isolated method-call timings or pytest runner durations.
The headline reduction uses the median of the three paired-ratio scores, 0.911658. The absolute before/after values are separate medians of the three batch-time results, so their quotient need not equal the paired-ratio score. All three scores are below the evaluator's 0.95 improvement threshold, and each run passes its 5% relative-IQR noise gate and exact semantic checks.
Validation
Run from the changed repository copy:
The pristine baseline also passes the full 287-test suite and both style checks. Existing tests and the frozen oracle cover this behavior-preserving optimization; no new functionality or tests are added.
Checklist
AI assistance
Codex gpt-6.1-sol generated the optimization candidates, tracked with Weco Observe. Automated source review, semantic checks, native tests and benchmarking informed selection. No human review is claimed.
Weco share link: https://dashboard.weco.ai/share/OVyh1gbcXZ7zmOO5XWrtis26cn8RDmxo