Repository navigation
Simplify state hydration benchmark, drop metadata-only test - #7503
Conversation
test_hydration_metadata re-read the cached name, full name, parent and root of every class in a 20- and a 200-substate tree. It came in with #7064 to show the per-class metadata cache replacing the lru_cache whose 128-entry capacity the 200-class tree thrashed. With that cache in place both sizes measure the same cache-hit path, and that path is almost entirely CPython's type attribute cache and call specialization rather than reflex code. That makes it flip on CodSpeed with no related change: [200] alternates between 1.7 and 1.8 ms (-6.9% on #7502, -7.7% on #7501), [20] between 207.6 and 216.7 us (-4.2% on #7410 and #7434, +4.3% on the changelog-only #7445), while every other benchmark reports untouched. Reproduced under callgrind with the same pytest-codspeed instrumentation CI uses. Two runs of the module alone are byte-identical: 1,420,889 Ir for [200]. Running test_state_access.py or test_state_delta.py first in the same process gives 1,363,413 and 1,306,760 Ir (-4.0%, -8.0%) for the unchanged function, while test_hydration_snapshot[200] moves about 1% (5,335,449 to 5,392,507). The count depends on what the process did before the benchmark, not on the code it measures, so no restructuring of the body would settle it. test_hydration_snapshot stays: it walks the same metadata on its way to serializing the tree, so a regression in the metadata path still shows up there, diluted by real work enough to sit under the threshold when nothing changed. The two removed benchmarks show as skipped on CodSpeed until they are archived in the project settings. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011LZPUJkHZur6LUinHeFpZT
There was a problem hiding this comment.
All reported issues were addressed across 1 file
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
Merging this PR will improve performance by 4.66%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_on_event_router_data |
2 ms | 1.9 ms | +4.66% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/lucid-turing-8fnlv5 (484c91f) with main (62d454f)
Footnotes
-
20 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Type of change
Changes To Core Features
Description
This PR refactors the state hydration benchmark to focus on what matters for performance regression detection:
Changes:
Updated docstring to clarify the benchmark's purpose: measuring complete snapshots of state trees, which inherently exercises the per-class metadata caches (name and parent) during serialization.
Removed
test_hydration_metadata— a separate benchmark that only re-read cached metadata without serialization work. This test was problematic because:Rationale:
The snapshot benchmark (
test_hydration_snapshot) is the better regression detector because it measures the full serialization pipeline, which naturally exercises metadata caches in a realistic context. Regressions in those caches show up clearly in the snapshot benchmark without the noise from CPU-level caching effects.Test Plan
Existing benchmark tests pass. The remaining
test_hydration_snapshotbenchmark continues to exercise state tree hydration and metadata cache performance in a realistic serialization context.https://claude.ai/code/session_011LZPUJkHZur6LUinHeFpZT