perf(api): fetch dependency graph metadata concurrently on the worker #1606
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.42) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 334 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.348
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1606"
general
weight: 0.35
littledivy
GET /api/scopes/:scope/packages/:package/versions/:version/dependencies/graphis still slow on the worker. This makes it faster without using more memory.Cause
On
wasm32, deno_graph's defaultExecutordoesn't spawn anything. It returns each future without starting it.resolve_pending_jsr_specifiersthen awaits each pendingmeta.json, and then each<version>_meta.json, one after another. Every metadata fetch at a level of the dependency tree became its own R2 round trip in series: a level with 10 dependencies costs ~20 sequential round trips instead of ~2.Natively the default executor does spawn, so this never showed up in tests or in the earlier work (#1543).
Changes
DepTreeExecutorspawns each load withtokio::spawn+AssertSend(the same patternspawn_blockinguses on the worker). It keeps the current span so R2 binding spans still nest correctly. The native build is unchanged.<version>_meta.jsonas a fullVersionMetadata. That builds a wholeserde_json::Valuetree plus everyModuleInfo, only to readexports, manifest sizes and module keys. It now deserializes a small struct that skips the module graph contents withIgnoredAny.RegistryMetadataCachestoresArc<[u8]>, the type deno_graph takes, so a hit goes into the graph without a copy (before, it was copied twice viato_vec().into()). Other loads go from two copies to one.mem::take. This also replacesArc::into_inner(..).unwrap()onexports, which could panic if a spawned task still held a clone.Memory goes down: fewer copies, no per-dependency
Valuetree, no map clones. Concurrency doesn't hold any more documents than before.Behaviour change
A dependency's metadata with neither
moduleGraph2normoduleGraph1used to fail the whole graph. Now it loads, and its files are treated as needing a download.Tests
cargo check/clippyare clean for native andwasm32-unknown-emscripten, and all 162registry_apitests pass. The executor change only applies on wasm, so the tests don't exercise it and the speedup isn't measured yet. Staging traces of this endpoint, before and after, should show it.Not addressed
The handler's parse of the root package's
VersionMetadatastill goes throughserde_json::Value, once per request. Fixing it means changing the shared deserializer, which other code also uses.