Repository navigation
perf(api): fetch dependency graph metadata concurrently on the worker - #1606
Merged
Merged
Conversation
littledivy
approved these changes
Nov 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.