[turbopack] Reduce persistence buffer lifetimes#92413
Open
lukesandberg wants to merge 2 commits into04-06-add_family_name_to_many_spansfrom
Open
[turbopack] Reduce persistence buffer lifetimes#92413lukesandberg wants to merge 2 commits into04-06-add_family_name_to_many_spansfrom
lukesandberg wants to merge 2 commits into04-06-add_family_name_to_many_spansfrom
Conversation
This was referenced Apr 6, 2026
Contributor
Author
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
31c5fbe to
f6297db
Compare
2be529b to
2bc6c08
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
f6297db to
9c3aaf1
Compare
2bc6c08 to
76294c3
Compare
This was referenced Apr 6, 2026
Collaborator
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
deserialize directly into the TaskStorage struct in the in memory cache this means we need to hold the shard lock while doing it, but we save a bunch of temporary memory allocations from the snapshots
76294c3 to
632c22b
Compare
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.

What?
Refactor the task restore path to decode persisted bytes directly into the live in-memory
TaskStorage, rather than first decoding into a scratchTaskStorageand then copying the fields across.Also introduces
batch_get_with— a streaming callback-based batch lookup that resolves and delivers each value immediately rather than accumulating all decoded values simultaneously.Why?
The old path allocated a scratch
TaskStorageper task, decoded into it, then calledrestore_fromto copy persisted fields into the live task. For large batches (up to 50K tasks) this meant holding every decoded value in memory at once.The new path:
TaskStorageallocation per taskrestore_from/restore_meta_from/restore_data_fromfamily of methods from theTaskStoragemacro, which were the only consumers of this patternAlso switches
batch_getfrom returningVec<Option<ArcBytes>>to a streamingbatch_get_with(callback)interface, and replaces theValueBuffer<'l>associated type onKeyValueDatabasewith a concreteArcBytesreturn type.How?
turbo-persistence: addbatch_get_withonTurboPersistenceandKeyValueDatabase;batch_lookup_withonMetaFilenow takes aFoundBitsetand fires a callback per resolved entry rather than storingLookupValuein the cells vecBackingStorage:lookup_datareturnsOption<ArcBytes>(raw bytes);batch_lookup_datatakes a&mut dyn FnMut(usize, Option<&[u8]>)callbackkv_backing_storage: decode removed from the lookup path; callers decode directly usingnew_turbo_bincode_decoderoperation/mod.rs: newrestore_batchhelper handles single and batch cases uniformly;process_taskclosure decodes into live storage and firesprepared_task_callbackinline without a second passtask_storage_macro.rs: removerestore_fromand related generated methods