Skip to content

Avoid repeated workspace-member lookups during discovery - #281

Draft
zaniebot wants to merge 1 commit into
mainfrom
zb/bughuntperf/264-workspace-member-path-lookup
Draft

zaniebot wants to merge 1 commit into
mainfrom
zb/bughuntperf/264-workspace-member-path-lookup

Conversation

@zaniebot

@zaniebot zaniebot commented Jul 16, 2026 •

Copy link
Copy Markdown
Collaborator

Repeated discovery of an already-cached workspace member scans the workspace’s package map to recover the project name. Store the optional project name alongside each path-keyed cache entry and reuse it in project and virtual-project discovery. This removes the repeated member scan while keeping virtual workspace roots distinct from projects, selecting the first package in workspace order when member roots overlap, and respecting intermediate pyproject.toml boundaries.

Hyperfine 2.0.0 measurements of 75a00c556 → b3795ac8b used release builds with Rust 1.99.0 and CPython 3.12.13 on an AMD EPYC-Genoa Linux VM, pinned to four CPUs. The command was uv lock --directory FIXTURE --python PYTHON --no-index, with --offline --no-config --color never --cache-dir CACHE. Output went to /dev/null.

The synthetic root depends on every local workspace member through workspace sources. The root project sorts after the members. Each invocation performs a fresh lock, including workspace discovery, repeated member lookup, resolution, and lock serialization. Hyperfine's --prepare removes the previous lock outside measured time and RSS. OS pages and interpreter-query caches were warm. These local fixtures use no external index or source backend.

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
1 member + root; fresh lock 22.7 → 22.4 ms -1.31% [-3.22%, +0.11%] 34.84 → 34.91 MiB +0.19% [-0.29%, +0.65%]
32 members + root; fresh lock 35.5 → 35.8 ms +0.70% [-1.72%, +3.14%] 37.72 → 37.70 MiB -0.03% [-0.56%, +0.48%]
256 members + root; fresh lock 100.1 → 100.1 ms +0.03% [-1.16%, +1.20%] 45.79 → 46.38 MiB +1.29% [-0.04%, +2.90%]
1,024 members + root; fresh lock 353.9 → 323.5 ms -8.60% [-9.92%, -7.47%] 76.38 → 76.26 MiB -0.15% [-0.98%, +0.79%]
2,048 members + root; fresh lock 764.7 → 636.2 ms -16.80% [-17.65%, -15.99%] 113.98 → 114.87 MiB +0.78% [-0.56%, +2.30%]

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 1,024-member case uses 8.60% less wall time [-9.92%, -7.47%], falling from 353.9 ms to 323.5 ms. At 2,048 members, time falls from 764.7 ms to 636.2 ms: -16.80% [-17.65%, -15.99%]. The three smaller runtime intervals include zero. All five RSS intervals include zero. These fresh-lock measurements show runtime improvements in the two largest workspaces, without an established peak-memory change. RSS is Hyperfine's Linux wait4 peak, not an allocation count or summed simultaneous process-tree memory.

@zaniebot zaniebot added priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. size:2 Moderate: one subsystem with meaningful invariants, edge cases, or operational evidence to inspect. performance risk:1 Negligible risk of localized mistakes that are obvious and easy to correct. labels Sep 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/264-workspace-member-path-lookup branch from ef8164a to b3795ac Compare October 6, 2026 14:50
@codspeed

codspeed Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 14.55%

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

❌ 1 regressed benchmark
✅ 68 untouched benchmarks
⏩ 35 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ ⚠️ Simulation discover_workspace_from_all_members_with_excludes 140.2 ms 164 ms -14.55%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing zb/bughuntperf/264-workspace-member-path-lookup (38155c0) with main (05e1cc1)

Open in CodSpeed

Footnotes

  1. 35 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. ↩

@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/bughuntperf/264-workspace-member-path-lookup branch from b3795ac to 38155c0 Compare October 16, 2026 15:16

This branch was successfully deployed

1 active deployment
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:1 Negligible risk of localized mistakes that are obvious and easy to correct. size:2 Moderate: one subsystem with meaningful invariants, edge cases, or operational evidence to inspect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants