perf(pm): add mock manifest provider#3035
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the mock registry implementation in crates/ruborist/src/traits/registry.rs by adding Clone derivations to MockPackage and MockRegistryClient, and implementing the ManifestProvider trait. A new test case was also added to verify manifest job execution. Feedback was provided regarding the use of synchronous, potentially expensive JSON parsing within the Full and ExtractVersion job variants; it is recommended to use the extract_core_version_off_runtime helper to avoid blocking the async runtime.
| let speculative = spec.and_then(|spec| { | ||
| resolve_target_version((&*full).into(), &spec) | ||
| .ok() | ||
| .and_then(|version| { | ||
| full.get_core_version(&version) | ||
| .map(|core| (spec, Arc::new(core))) | ||
| }) | ||
| }); |
There was a problem hiding this comment.
The speculative extraction logic in the Full job variant uses full.get_core_version(&version), which is a synchronous and potentially expensive operation as it parses the entire JSON tree using simd_json. While this is a mock implementation, for more realistic performance testing and to avoid blocking the async runtime, consider using the extract_core_version_off_runtime helper which offloads this work to a rayon thread pool on native targets.
| let manifest = | ||
| full.get_core_version(&version) | ||
| .map(Arc::new) | ||
| .ok_or_else(|| { | ||
| MockError(format!( | ||
| "Version {version} not found in manifest for {name}" | ||
| )) | ||
| })?; |
There was a problem hiding this comment.
Similar to the Full job variant, the ExtractVersion job variant performs a synchronous extraction using full.get_core_version(&version). To maintain consistency with production behavior and avoid blocking the async executor during performance tests, it is recommended to use extract_core_version_off_runtime.
8c06b60 to
519961e
Compare
133eaf3 to
71f73b1
Compare
519961e to
a7138a9
Compare
71f73b1 to
5af3c3b
Compare
📊 pm-bench-phases ·
|
| PM | wall | ±σ | user | sys | RSS | pgMinor |
|---|---|---|---|---|---|---|
| bun | 9.14s | 0.15s | 10.40s | 10.34s | 693M | 338.7K |
| utoo-next | 7.87s | 0.19s | 10.55s | 12.27s | 987M | 124.4K |
| utoo-npm | 9.06s | 1.66s | 10.85s | 12.75s | 1.00G | 127.0K |
| utoo | 8.27s | 0.33s | 10.61s | 12.28s | 948M | 127.2K |
| PM | vCtx | iCtx | netRX | netTX | cache | node_mod | lock |
|---|---|---|---|---|---|---|---|
| bun | 16.1K | 18.9K | 1.19G | 7M | 1.86G | 1.75G | 1M |
| utoo-next | 112.8K | 84.7K | 1.16G | 5M | 1.71G | 1.70G | 2M |
| utoo-npm | 138.9K | 99.2K | 1.16G | 5M | 1.71G | 1.70G | 2M |
| utoo | 118.5K | 74.0K | 1.16G | 5M | 1.71G | 1.70G | 2M |
p1_resolve
| PM | wall | ±σ | user | sys | RSS | pgMinor |
|---|---|---|---|---|---|---|
| bun | 2.07s | 0.03s | 3.98s | 1.07s | 510M | 171.2K |
| utoo-next | 3.02s | 0.04s | 5.42s | 1.77s | 608M | 92.7K |
| utoo-npm | 3.14s | 0.02s | 5.57s | 2.12s | 619M | 79.6K |
| utoo | 3.02s | 0.07s | 5.38s | 1.77s | 616M | 86.7K |
| PM | vCtx | iCtx | netRX | netTX | cache | node_mod | lock |
|---|---|---|---|---|---|---|---|
| bun | 10.0K | 4.3K | 202M | 3M | 107M | - | 1M |
| utoo-next | 51.2K | 75.2K | 200M | 2M | 7M | 3M | 2M |
| utoo-npm | 74.6K | 95.4K | 200M | 3M | 7M | 3M | 2M |
| utoo | 50.3K | 74.6K | 200M | 3M | 7M | 3M | 2M |
p3_cold_install
| PM | wall | ±σ | user | sys | RSS | pgMinor |
|---|---|---|---|---|---|---|
| bun | 6.76s | 0.18s | 6.25s | 10.09s | 634M | 212.3K |
| utoo-next | 6.82s | 1.68s | 5.08s | 11.01s | 510M | 63.2K |
| utoo-npm | 8.21s | 1.87s | 5.17s | 11.29s | 498M | 63.1K |
| utoo | 5.85s | 0.04s | 4.98s | 10.60s | 480M | 62.6K |
| PM | vCtx | iCtx | netRX | netTX | cache | node_mod | lock |
|---|---|---|---|---|---|---|---|
| bun | 6.1K | 7.1K | 1019M | 4M | 1.76G | 1.76G | 1M |
| utoo-next | 110.6K | 54.4K | 990M | 3M | 1.70G | 1.70G | 2M |
| utoo-npm | 122.6K | 52.6K | 990M | 3M | 1.70G | 1.70G | 2M |
| utoo | 91.7K | 52.3K | 989M | 2M | 1.70G | 1.70G | 2M |
p4_warm_link
| PM | wall | ±σ | user | sys | RSS | pgMinor |
|---|---|---|---|---|---|---|
| bun | 3.30s | 0.07s | 0.20s | 2.36s | 135M | 32.5K |
| utoo-next | 2.33s | 0.12s | 0.50s | 3.75s | 80M | 18.5K |
| utoo-npm | 2.20s | 0.02s | 0.48s | 3.71s | 78M | 18.4K |
| utoo | 2.20s | 0.06s | 0.49s | 3.68s | 77M | 17.5K |
| PM | vCtx | iCtx | netRX | netTX | cache | node_mod | lock |
|---|---|---|---|---|---|---|---|
| bun | 306 | 21 | 5M | 36K | 1.91G | 1.75G | 1M |
| utoo-next | 41.3K | 20.5K | 13K | 25K | 1.70G | 1.70G | 2M |
| utoo-npm | 39.1K | 17.6K | 12K | 7K | 1.70G | 1.70G | 2M |
| utoo | 37.3K | 16.2K | 14K | 12K | 1.71G | 1.70G | 2M |
npmmirror.com: no output captured.
Summary
Review-sized split from #3028 / #2948, stacked after #3034.
Prepares resolver main-loop tests by teaching the test mock registry to satisfy
ManifestProviderjobs:Clonefor the mock registry data;ManifestProviderforMockRegistryClientunder#[cfg(test)];No production behavior changes in this PR.
Size
1 file changed, 101 insertions(+)Validation
cargo fmtcargo check -p utoo-ruboristcargo test -p utoo-ruborist traits::registry::mock::mock_registry_executes_manifest_provider_jobscargo clippy --all-targets -- -D warnings --no-depspack-napistill warns locally becausenext.jsis a symlink in this worktree; clippy exits successfully.