-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Avoid using TaskTypes as keys in storage instead use hashes #88904
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
This stack of pull requests is managed by Graphite. Learn more about stacking. |
turbopack/crates/turbo-tasks-backend/src/backend/storage_schema.rs
Outdated
Show resolved
Hide resolved
turbopack/crates/turbo-tasks-backend/src/backend/operation/mod.rs
Outdated
Show resolved
Hide resolved
Failing test suitesCommit: 131bc3f | About building and testing Next.js
Expand output● runtime prefetching › passed to a public cache › can completely prefetch a page that uses cookies and no uncached IO ● runtime prefetching › passed to a public cache › can completely prefetch a page that uses cookies and no uncached IO |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
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: **432 kB** → **432 kB** ✅ -50 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
|
0c1d348 to
9e97759
Compare
aebd28d to
9562e78
Compare
9562e78 to
e929b37
Compare
turbopack/crates/turbo-tasks-backend/src/database/by_key_space.rs
Outdated
Show resolved
Hide resolved
instead store hashes, this makes lookups slightly more complex but greatly reduces storage requirements.
e929b37 to
a33253f
Compare
…he db lookup methods

Save space in the persisent store by only recording TaskType one time instead of twice.
What?
Instead of using an encoded TaskType struct as a key in persistent storage just use a 64 bit hash. Now when looking up we actually need to do a cascading read
Full cache misses perform the same and so do cache hits since we always end up reading the TaskData anyway (in the
connect_childoperation that immediately follows). This just slightly changes when that second read happens, as such we shouldn't really expect it to slow down.In the case of a hash collisions we do end up doing strictly more work (reading and restoring TaskData entries for the wrong task), but this work is cached and this should be extremely rare assuming a good hash function..
Why?
Currently we encode 2 copies of ever CachedTaskType in the database.
TaskCachekeyspace)TaskDatakeyspacethis redundancy is wasteful. Instead we can make the TaskCache map much smaller and add a bit of complexity to lookups.
Future Work
Right now to compute the hashes we are just running
encodeand then hashing the bytes. This is not optimal, but we do not have a hash function that is suitable for this usecase. So we should create a newPersistentHashtrait that TaskInputs implement in order to support this without encoding.