-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Turbopack: add support for selective reads of keyed cell values #88303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: canary
Are you sure you want to change the base?
Conversation
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
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: **431 kB** → **431 kB** ✅ -7 B82 files with content-based hashes (individual files not comparable between builds) Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
|
1122fbd to
7b41b1e
Compare
7b41b1e to
31c1bf5
Compare
Merging this PR will not alter performance
Comparing Footnotes
|
43f64a5 to
23ef142
Compare
31c1bf5 to
385d817
Compare
23ef142 to
a5f8baf
Compare
385d817 to
9f04ddd
Compare
45d4f52 to
bd5f4f7
Compare
860b093 to
8456c8d
Compare
8456c8d to
c151034
Compare
bd5f4f7 to
0494417
Compare
0494417 to
fe6a338
Compare
c151034 to
f351aab
Compare

What?
Previously cells could either be unchanged or changed. This falls short when updating Maps or Sets.
We can't have a dependency on a single key of a map or set.
The workaround for this was to create an "selector" turbo-tasks which picks the value and copies it into a new cell.
This allows more granular invalidation.
But it also creates a lot of extra tasks. And changing the map/set does invalidate all these selector tasks, which causes a lot of invalidation work.
This change adds support for dependencies on certain keys of cells.
On write side a turbo-tasks value need to opt-in into that behavior via
cell = "keyed".This changes the
cellmethod to compare the new value key-by-key and report the changed keys to the backend.On read side the Vc need to be read via
.get(key).await?or.contains_key(key).await?, which returns only the value resp. existance of the key and adds a dependency only to that key.With this approach the "selector" tasks can be avoided, while maintaining the same level of invalidation.
How?
On implementation side we only track the hash of the key for size reasons.
A dependency has an additional field
key: Option<u64>which represents the key depending on.When updating a cell we have a new optional argument
updated_key_hashes: Option<SmallVec<[u64; 2]>>where the updates keys can be provided. The newCellMode(cell = "keyed") fills that.