Remove ineffective turbo-tasks#91341
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
Failing test suitesCommit: 94d2f96 | About building and testing Next.js
Expand output● rewrites manual href/as › development mode › should allow manual href/as on index page ● rewrites manual href/as › production mode › should allow manual href/as on index page |
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 |
49d503b to
69f42c8
Compare
69f42c8 to
94d2f96
Compare
94d2f96 to
d9d04d5
Compare
d9d04d5 to
2fbcd36
Compare
06d6fc4 to
8e2af10
Compare
2fbcd36 to
0ffa417
Compare
8e2af10 to
c526347
Compare
4873b41 to
80f135b
Compare
80f135b to
905545d
Compare
e550aff to
7a01a73
Compare
Stats from current PR🟢 1 improvement
📊 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
📝 Changed Files (25 files)Files with changes:
View diffsapp-page-exp..ntime.dev.jsfailed to diffapp-page-exp..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page-tur..ntime.dev.jsfailed to diffapp-page-tur..time.prod.jsfailed to diffapp-page.runtime.dev.jsfailed to diffapp-page.runtime.prod.jsfailed to diffapp-route-ex..ntime.dev.jsDiff too large to display app-route-ex..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route-tu..ntime.dev.jsDiff too large to display app-route-tu..time.prod.jsDiff too large to display app-route.runtime.dev.jsDiff too large to display app-route.ru..time.prod.jsDiff too large to display pages-api-tu..ntime.dev.jsDiff too large to display pages-api-tu..time.prod.jsDiff too large to display pages-api.runtime.dev.jsDiff too large to display pages-api.ru..time.prod.jsDiff too large to display pages-turbo...ntime.dev.jsDiff too large to display pages-turbo...time.prod.jsDiff too large to display pages.runtime.dev.jsDiff too large to display pages.runtime.prod.jsDiff too large to display server.runtime.prod.jsDiff too large to display 📎 Tarball URLCommit: af3c3e2 |
7a01a73 to
157d145
Compare
157d145 to
f579205
Compare
Tests PassedCommit: af3c3e2 |
19ba862 to
b45210d
Compare
b45210d to
d83d8b4
Compare
d83d8b4 to
1c21955
Compare
Merge activity
|

Remove ineffective turbo-tasks
Identifies and removes turbo-tasks functions where the task overhead exceeds the value they provide. Each turbo-task carries ~4-6μs execution overhead per miss and ~200-500ns per cache hit, plus allocations and bookkeeping.
What?
Removes 22
#[turbo_tasks::function]implementations across resolve plugins, chunk items, and resolve-result helpers — converting them to plain methods or inlining their work. Changes fall into a few buckets:AfterResolvePluginCondition::matches,BeforeResolvePluginCondition::matches,after_resolve_condition,before_resolve_condition): conditions now store the resolvedGlobas aReadRef<Glob>on the plugin struct at construction, somatchesis a pure sync function and the per-plugin*_resolve_conditiongetters are trivial field reads (no longer turbo-tasks). Theafter_resolve/before_resolvehooks themselves stay as#[turbo_tasks::function]— they synthesize virtual sources/modules and need memoization on(self, lookup_path, reference_type, request)to avoid distinct cells producing duplicate module-graph idents.resolveand at the hook bodies themselves, not the conditions or condition getters.AfterResolvePluginConditionandBeforeResolvePluginConditionare markedserialization = "none"becauseReadRefcannot be persisted; plugin construction is cheap enough to re-derive on restore.chunking_context,ty,content_with_async_module_info): returned constants or simple field reads, zero cache hits and no.awaitcalls (no invalidation value).primary_modules,first_module,first_source,primary_sources,is_unresolvable,primary_output_assets): simple iterators over already-resolved data; converted to plain methods. Added aDuplicate(usize)variant toModuleResolveResultItemto handle dedup at construction time instead of in a separate task.ResolveResult/ModuleResolveResultmonolithically, and we get little to no benefit from fine grained access. e.g.is_unresolved()in theory that is a valuable turbotask, but since it rarely changes but generally if we change how we resolve an import then we have to regenerate code, so saving a few boolean conditions is unlikely to be very valuable.EcmascriptModuleAsset::analyze,is_types_resolving_enabled,next_server::resolve::condition.Impact (vercel-site build, dev first-compile)
The 22 removed tasks were collectively responsible for ~519K misses per build — each miss previously paying the full execution overhead. Most of the work from
EcmascriptModuleAsset::analyzenaturally migrated intoanalyze_ecmascript_module(the task it was wrapping; +129K hits there).On-disk cache size (persistent caching)
Each removed task also stops allocating cache cells on disk. Measured on the same vercel-site build with
.next/cache/turbopack(persistent cache enabled):Build-time wall clock and peak memory
Ran
pnpm next build --experimental-build-mode=compile5 times on each branchPeak RSS — clear reduction:
Every branch run has lower RSS than every canary run — the distributions don't overlap. Welch's t = −6.03.
Wall time — no measurable change:
Median is flat. The mean difference is within noise (Welch's t = +0.61, n = 5). Branch run-to-run variance is higher — one 68.23s outlier pulls the mean up — so this is neither a regression nor a measurable speedup at this sample size.