turbopack: reduce EffectStateStorage memory by storing u128 content hashes#92902
Merged
turbopack: reduce EffectStateStorage memory by storing u128 content hashes#92902
Conversation
…l content Reduces memory usage in EffectStateStorage by storing a xxh3 128-bit hash of the effect value instead of the full ReadRef<PersistedFileContent> or ReadRef<LinkContent>. The hash is precomputed at effect construction time. Co-Authored-By: Claude <noreply@anthropic.com>
bgw
reviewed
Apr 16, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
bgw
approved these changes
Apr 16, 2026
Collaborator
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
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?
In
turbo-tasks-fs, theWriteEffectandWriteLinkEffectstructs now store a precomputedu128xxh3 content hash instead of returning the fullReadRef<PersistedFileContent>/ReadRef<LinkContent>from theirEffect::value()implementations.The associated type
Effect::Valueis changed fromReadRef<PersistedFileContent>/ReadRef<LinkContent>tou128for both effect types.LinkContentgains aDeterministicHashderive to support hashing viahash_xxh3_hash128.Why?
EffectStateStoragestores the last-applied value for each effect key inlast_applied: Mutex<Option<Box<dyn Any + Send + Sync>>>to enable a double-checked deduplication fast path (skip re-writing a file if content hasn't changed). In long-running sessions this map grows continuously and holds onto a lot of memory because it stores full file content (ReadRef<PersistedFileContent>) or full link content (ReadRef<LinkContent>) for every file ever written.Storing a
u128hash (16 bytes) instead of the full content significantly reduces memory usage while preserving the deduplication semantics (hash equality implies content equality with negligible collision probability).How?
content_hash: u128field toWriteEffectandWriteLinkEffect, computed at construction time usinghash_xxh3_hash128(xxh3 128-bit non-cryptographic hash, already used elsewhere in turbopack for content addressing).Effect::Value = u128for both effect types;value()returns&self.content_hash.EffectStateStoragenow storesBox<u128>(24 bytes on the heap) per entry instead ofBox<ReadRef<...>>which held a reference-counted pointer into potentially large file content.EffectStateStorage,Effects::apply(), orDynEffectvtable — the existingAny/DynPartialEqmachinery works transparently withu128.