Skip to content

perf(pm): fast path registry cache package clones#2979

Draft
elrrrrrrr wants to merge 7 commits into
perf/pm-resolver-demand-bfsfrom
exp/pm-registry-cache-package-fast-path
Draft

perf(pm): fast path registry cache package clones#2979
elrrrrrrr wants to merge 7 commits into
perf/pm-resolver-demand-bfsfrom
exp/pm-registry-cache-package-fast-path

Conversation

@elrrrrrrr
Copy link
Copy Markdown
Contributor

@elrrrrrrr elrrrrrrr commented May 18, 2026

Summary

  • add a registry-cache clone fast path that uses the standard package/ wrapper directly
  • keep seeded/git/file cache clones on the existing auto-discovery path
  • carry cache layout through the install scheduler so workers remain primitive I/O operations

Hypothesis

Warm registry installs currently call the generic source-discovery path before every cache clone, which costs at least one directory scan per package. Since npm registry tarballs are extracted into <cache>/<name>/<version>/package, the scheduler can skip that scan for registry download/cache-hit paths and reduce p4 ctx/syscall without changing non-registry cache semantics.

Validation

  • cargo fmt
  • CARGO_NET_OFFLINE=true cargo test -p utoo-pm util::cloner::tests::test_clone_registry_package_from_cache_sync_uses_package_dir
  • CARGO_NET_OFFLINE=true cargo test -p utoo-pm service::install_scheduler::tests
  • CARGO_NET_OFFLINE=true cargo clippy -p utoo-pm --all-targets -- -D warnings --no-deps

Benchmark Result

GHA run: https://github.com/utooland/utoo/actions/runs/26025415891

npmjs phase bench:

phase wall vCtx iCtx note
p0 7.56s ±1.69 109.8K 58.9K noisy
p1 2.28s ±0.01 17.3K 20.1K unchanged target
p3 4.64s ±0.36 70.9K 44.5K no clear ctx win vs #2975
p4 1.74s ±0.08 14.1K 9.2K wall good, vCtx not better than #2975 best

Conclusion: this does not currently prove a ctx/syscall win. #2975 already had p4 around 13.1-13.7K / 9.3-9.9K; this branch is 14.1K / 9.2K. Keep as rejected/hold unless repeated runs show otherwise.

@elrrrrrrr elrrrrrrr added A-Pkg Manager Area: Package Manager benchmark Run pm-bench on PR labels May 18, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces prefetching for registry tarballs and refactors the installation scheduler to utilize a synchronous worker pool for extraction and cloning operations. It adds synchronous utility functions for cache lookups and directory cloning to optimize performance on warm installs. Feedback was provided regarding the removal of a redundant HashSet in the directory creation logic to avoid unnecessary allocations.

Comment on lines +156 to +164
let mut created_dirs = HashSet::new();
for dir in &dirs {
if created_dirs.insert(dir.clone())
&& let Err(e) = fs::create_dir_all(dir)
&& e.kind() != io::ErrorKind::AlreadyExists
{
return Err(e).with_context(|| err_msg.clone());
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The created_dirs HashSet is redundant here. The dirs vector is populated by collect_entries using a depth-first tree traversal, which naturally visits each directory exactly once. Removing this set avoids unnecessary allocations and lookups in the hot path of package cloning.

        for dir in &dirs {
            if let Err(e) = fs::create_dir_all(dir)
                && e.kind() != io::ErrorKind::AlreadyExists
            {
                return Err(e).with_context(|| err_msg.clone());
            }
        }

@github-actions
Copy link
Copy Markdown

📊 pm-bench-phases · 47cb085 · linux (ubuntu-latest)

Workflow run — ant-design

PMs: utoo (this branch) · utoo-npm (latest published) · bun (latest)

npmjs.org

npmmirror.com: no output captured.

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

Labels

A-Pkg Manager Area: Package Manager benchmark Run pm-bench on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant