perf(responses): reuse measured entry strings for the state snapshot - #6360
Conversation
writeBoundedSnapshot already stringifies every candidate entry once in selectSnapshotEntries to measure its UTF-8 size, then stringified the whole selection again to build the payload. Keep the measured strings and join them instead. The output is byte-identical; a pinned-bytes regression test covers stubs, residents, multibyte text, escapes, and both byte budgets. Reworks the snapshot half of #4732 onto the two-pass selector now on dev. Co-authored-by: WU, CHI-LUNG <chilung-cgu@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (2)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughSnapshot selection now returns serialized entries, which the snapshot writer uses to build the version-2 payload. Tests cover serialized output, byte budgets, and the empty-store payload. ChangesSnapshot serialization
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Refactor Merge Risk: ⚪ Minimal · up to The change reuses serialized snapshot entries while preserving the existing format and selection behavior. No concrete merge-blocking issue is identified; normal CI checks should pass before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation Issue [ Resolution Implement the [ Full details: Docstring CoverageExplanation Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Carries the snapshot half of #4732 by @chilung-cgu onto current
dev.writeBoundedSnapshotalready serializes every candidate entry once inselectSnapshotEntriesto measure its UTF-8 size, then serialized the whole selection a second time to build the payload. The selector now keeps the measured entry strings and the payload is assembled by joining them, so a snapshot write does oneJSON.stringifypass over the entries instead of two. The output is byte-identical.The router half of #4732 (static
PROVIDER_REGISTRYlookup maps) is not carried:devhas since reshaped the snapshot code intoselectSnapshotEntries, and a direct measurement showed no measurablerouteModelchange from the registry cache, so it would add state without a benefit.Measured with a standalone script (not committed) that runs the previous
devselector verbatim against the new one on a 1,200-entry state map that produces a 23.98 MiB payload, asserting identical output before timing (30 runs after 5 warmups, two rounds):devCloses #4732 as carried.
Co-authored-by: WU, CHI-LUNG chilung-cgu@users.noreply.github.com
Verification
tests/responses/responses-state-snapshot-select.test.tspins the exact snapshot bytes across stub and resident entries, multibyte text, escapes, and both byte budgets; it is registered inscripts/test-layout/layout.jsonandtests/fixtures/test-layout-expected.json.Checklist
Summary by CodeRabbit