Skip to content

Cache hashes in the marker uniqueness index - #2074

Draft
zaniebot wants to merge 1 commit into
zb/marker-interner-node-idsfrom
zb/marker-interner-cached-hash
Draft

zaniebot wants to merge 1 commit into
zb/marker-interner-node-idsfrom
zb/marker-interner-cached-hash

Conversation

@zaniebot

@zaniebot zaniebot commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

The marker uniqueness table recomputes each stored node's hash when it grows, walking and hashing the node's outgoing ranges again. Store the hash alongside NodeId and reject unequal full hashes before comparing nodes. The shared node store remains the authority for equality.

Hyperfine 2.0.0 measurements of 166a8ed8c → a9957b63c used release builds of the complete CLI with rustc 1.99.0 (b940084d7 2026-09-28) on an AMD EPYC-Genoa Linux VM, pinned to four CPUs. Output went to /dev/null. Workloads that select or query an interpreter used CPython 3.12.13.

Commands include uv workspace metadata --script SCRIPT --frozen --python PYTHON --preview-features workspace-metadata. The synthetic frozen script locks contain one root and conditional leaves. Repeated expressions, distinct version-and-machine expressions, categorical values, and version exclusions exercise fresh marker interning alongside lock parsing and output formatting. Each command starts a fresh process and rebuilds its in-memory marker caches. OS pages and interpreter-query caches are warm. Frozen commands do not resolve, download, build, or install packages.

Values are means, parent → head. Changes are (head / parent - 1) with 95% confidence intervals; negative values indicate a reduction.

Workload Wall time Change, 95% CI Peak RSS Change, 95% CI
metadata / 64 edges / version-and-machine marker / shared marker 16.9 → 16.7 ms -1.11% [-3.22%, +0.92%] 25.21 → 25.29 MiB +0.30% [-0.22%, +0.86%]
metadata / 8,192 edges / version-and-machine marker / shared marker 101.1 → 101.8 ms +0.72% [-0.78%, +2.70%] 50.89 → 50.88 MiB -0.03% [-0.29%, +0.21%]
metadata / 1,024 edges / version-and-machine marker / distinct markers 30.9 → 30.3 ms -1.91% [-3.50%, -0.24%] 30.23 → 30.53 MiB +0.99% [+0.61%, +1.35%]
metadata / 8,192 edges / version-and-machine marker / distinct markers 141.3 → 135.7 ms -3.94% [-4.87%, -3.04%] 68.61 → 69.04 MiB +0.63% [+0.42%, +0.80%]
metadata / 32,768 edges / version-and-machine marker / distinct markers 579.2 → 523.6 ms -9.61% [-10.19%, -9.01%] 174.87 → 182.37 MiB +4.29% [+3.94%, +4.64%]
metadata / 512 edges / categorical values / 16 per marker / distinct markers 69.9 → 65.0 ms -6.98% [-7.69%, -6.20%] 44.95 → 45.22 MiB +0.59% [+0.28%, +0.93%]
metadata / 512 edges / version exclusions / 16 per marker / distinct markers 91.6 → 80.8 ms -11.76% [-12.70%, -10.89%] 50.67 → 51.02 MiB +0.69% [+0.38%, +1.04%]

Each workload used ten comparison blocks with alternating revision order, one warmup followed by three measured runs per revision in each block (30 measurements per revision). The pointwise 95% percentile-bootstrap intervals use 20,000 resamples of paired block means and retain all samples. They estimate within-run uncertainty, not variation across machines, independent builds, or separate benchmark campaigns.

The five distinct-marker workloads reduced elapsed time by 1.91–11.76%, while increasing peak RSS by 0.27–7.50 MiB. The 32,768-edge case shows the largest RSS increase alongside a 9.61% runtime reduction. Both shared-marker controls have runtime and RSS intervals that include zero. The measured benefit is a runtime/memory tradeoff in the distinct-marker workloads. RSS is Hyperfine's Linux wait4 peak, not an allocation count or summed simultaneous process-tree memory.

Earlier measurements

Earlier benchmark study:

Against #2072, 31 alternating macOS arm64 process pairs that each construct 50,000 distinct version/extra expressions reduce CPU by 27.9% (95% confidence interval: 26.3% to 29.5%). Both builds use the same Rust nightly, profiling profile, and production allocator. Retained requested heap storage increases from 113,344,027 to 115,441,179 bytes, or 1.9%, because each table entry stores an additional u64. Repeated parsing of 812 real Jupyter requirements is inconclusive (0.2% less CPU, interval -0.5% to 0.9%). Offline Jupyter and Airflow resolution do not establish a command-level speedup.

@codspeed

codspeed Bot commented Sep 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 45 untouched benchmarks


Comparing zb/marker-interner-cached-hash (a9957b6) with zb/marker-interner-node-ids (166a8ed)

Open in CodSpeed

@zaniebot zaniebot added risk:2 Low, contained risk of minor incorrect behavior with straightforward recovery. priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. size:1 Small: one localized behavior with straightforward tests or documentation checks. labels Sep 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. risk:2 Low, contained risk of minor incorrect behavior with straightforward recovery. size:1 Small: one localized behavior with straightforward tests or documentation checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants