Skip to content

Proof of concept: task eviction after snapshot for turbo-tasks-backend#91790

Open
lukesandberg wants to merge 4 commits intoracy_snapshot_encodingfrom
eviction_semantics_for_real_this_time
Open

Proof of concept: task eviction after snapshot for turbo-tasks-backend#91790
lukesandberg wants to merge 4 commits intoracy_snapshot_encodingfrom
eviction_semantics_for_real_this_time

Conversation

@lukesandberg
Copy link
Copy Markdown
Contributor

@lukesandberg lukesandberg commented Mar 22, 2026

Note: This is a proof of concept implementation. It is not yet ready for production use.

Summary

Implements memory eviction for the turbo-tasks engine. After a persistence snapshot completes, tasks that are safe to remove are evicted from in-memory storage and transparently restored from disk on next access.

Eviction levels

  • Full eviction: Entire task removed from the in-memory map (restored from disk on access). Only possible when the task has no meaningful transient state (and other state is already on disk)
  • DataAndMeta eviction: Both data and meta categories cleared, but the task stays in the map to preserve transient state (e.g. current_session_clean, aggregated session-clean counts).
  • DataOnly eviction: Only data-category fields cleared; meta (graph structure, output, dirty state) stays in memory.
  • MetaOnly eviction: Only meta-category fields cleared; data stays in memory.

Data and meta evictability are computed independently — if one category is modified but the other is clean, the clean category can still be dropped.

Eviction is gated behind BackendOptions::evict_after_snapshot (off by default), and can be enabled in Next.js via the TURBO_ENGINE_EVICT_AFTER_SNAPSHOT=1 env var for testing.

Key changes

  • Orthogonal eviction decision tree (storage_schema.rs): Data and meta evictability are computed independently. Full eviction additionally requires no meaningful transient state (session-clean flags, aggregated session-clean counts). Replaces the previous sequential bail-out approach which was too aggressive on full eviction (losing transient session state on leaf tasks) and not aggressive enough on partial eviction (blocking all eviction when only one category was modified).

  • Transient-dependent scanning (storage_schema.rs): Evictability checks whether output_dependent, cell_dependents, collectibles_dependents, and upper contain transient task references via O(n) scans. This is correct but not optimal — a future improvement would maintain data_contains_transient_state / meta_contains_transient_state bits to make these O(1). TODOs are left in the code.

  • drop_data(), drop_meta() and drop_data_and_meta() codegen (task_storage_macro.rs): New generated methods. drop_data_and_meta() is a combined single-pass version that scans lazy once instead of twice.

  • Session-stateful values (#[turbo_tasks::value(session_stateful)]): Attribute marking value types whose cells accumulate non-serializable runtime state (e.g. DiskFileSystem, which holds file-watcher handles). Tasks writing these cells are blocked from data eviction mid-session. The session_stateful property is encoded as a high bit in ValueTypeId so eviction checks are a single integer test with no extra memory per task.

  • task_cache moved into Storage (storage.rs): The CachedTaskType → TaskId deduplication map was previously a separate field on TurboTasksBackendInner. It is now owned by Storage so eviction can remove entries when a task is fully evicted. Because task_cache is a pure performance cache (entries are re-populated by task_by_type() on miss once the task type is persisted to backing storage), evicting entries is safe. After bulk eviction the map is shrunk when it is less than half full.

  • Parallel shard eviction (storage.rs): Eviction iterates all storage shards in parallel after snapshot, applying the appropriate eviction level per task. Each shard is shrunk after bulk eviction to reclaim slack capacity.

Design notes

  • SessionDependent tasks: SessionDependent tasks can still be evicted but if current_session_clean is set we prevent full eviction to avoid rechecking. Within a session the file-watchers are responsible for invalidations after setting current_session_clean.

Known limitations (proof of concept)

  • No LRU or access-frequency tracking — all eligible tasks are evicted on every snapshot cycle
  • No memory pressure feedback — eviction runs on a timer, not in response to actual memory pressure
  • This tends to leave us a with a fragmented heap, more work is needed to either address this or better manage it
  • Only runs after snapshotting which tends to be a high point in memory
    • Future work will explore interleaving this logic with snapshotting to trim the peak
  • Transient Cell Data is currently always retained, this requires a redesign of serialization=none value cells, see [turbopack] Unify Cell Storage #92974
  • This breaks the last_succesful_parse dev mode optimization which means parse errors become more costly, see [turbopack] Persistent last_successful_parse #92852 for a fix

@nextjs-bot nextjs-bot added created-by: Turbopack team PRs by the Turbopack team. Turbopack Related to Turbopack with Next.js. labels Mar 22, 2026
Copy link
Copy Markdown
Contributor Author

lukesandberg commented Mar 22, 2026

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.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@nextjs-bot
Copy link
Copy Markdown
Contributor

nextjs-bot commented Mar 22, 2026

Tests Passed

@nextjs-bot
Copy link
Copy Markdown
Contributor

nextjs-bot commented Mar 22, 2026

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▅▁▁▅▅
Cold (Ready in log) 440ms 440ms █▇▂▅▅
Cold (First Request) 817ms 822ms ▁▁█▁█
Warm (Listen) 456ms 456ms ▅▅▅▅█
Warm (Ready in log) 440ms 440ms ▃▃▃▁▄
Warm (First Request) 338ms 339ms ▅▅▇▂▇
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change Trend
Cold (Listen) 455ms 455ms ▅▁▅▅▅
Cold (Ready in log) 438ms 438ms ▂▇▁▃▅
Cold (First Request) 1.857s 1.895s ▆█▆▆█
Warm (Listen) 456ms 456ms ▅█▁▅▅
Warm (Ready in log) 438ms 438ms ▄▆▂▃▅
Warm (First Request) 1.871s 1.876s ▅▇▆▆█

⚡ Production Builds

Metric Canary PR Change Trend
Fresh Build 3.979s 3.951s ▄█▃▅▂
Cached Build 3.980s 4.009s ▃█▂▄▁
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change Trend
Fresh Build 14.452s 14.439s ██▂▃█
Cached Build 14.540s 14.589s ▂█▄▁▆
node_modules Size 494 MB 494 MB █████
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
04gfaeiu1v7qm.js gzip 151 B N/A -
07rxhp_1_g4mu.js gzip 13.1 kB N/A -
07vz_1vlust95.js gzip 65.5 kB N/A -
08avva-dy02e7.js gzip 10.4 kB N/A -
09x_ycos2214h.js gzip 151 B N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0fli3_wppnim5.js gzip 12.9 kB N/A -
0k09jwjeb-tki.js gzip 13.8 kB N/A -
0kb7_ep3r1z0_.js gzip 10.1 kB N/A -
0kw8xgqdrilf6.js gzip 8.56 kB N/A -
0lgndkr1hands.js gzip 49.6 kB N/A -
0ojkk2e654xsc.js gzip 8.59 kB N/A -
0wfoal20dkqj1.js gzip 155 B N/A -
0wxpyd8r-vipl.js gzip 1.47 kB N/A -
0xy2fhla48_rd.js gzip 9.24 kB N/A -
0zx3fp91iid52.js gzip 159 B N/A -
10wqsvi2mgfmi.js gzip 9.82 kB N/A -
16lhqjoqbznyg.js gzip 220 B 220 B
16vepdkipri3r.js gzip 8.51 kB N/A -
17n96uu6y1pxq.js gzip 8.6 kB N/A -
18y4_8-9or0mn.js gzip 8.51 kB N/A -
19410kg_2bl_2.js gzip 156 B N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1gq145j3kps-h.js gzip 8.62 kB N/A -
1li2wvnrlll1x.js gzip 155 B N/A -
1nsh-mbn0e-se.js gzip 8.56 kB N/A -
1tsrrp1tdngti.js gzip 13.3 kB N/A -
2__-e_ym8n788.js gzip 450 B N/A -
22o6xd9_ywdu6.js gzip 233 B N/A -
2587zu9zz3ch0.js gzip 154 B N/A -
25ykkt57gkfew.js gzip 154 B N/A -
2kb7581t3yg4r.js gzip 153 B N/A -
2kvj8yrfznmwx.js gzip 5.69 kB N/A -
2qv7m7xjnokgr.js gzip 8.58 kB N/A -
342ijzvrpe53h.js gzip 2.29 kB N/A -
37pyv-119nldk.js gzip 152 B N/A -
3geqw_3h7k33y.js gzip 156 B N/A -
3ok6wj7wwsorf.js gzip 70.8 kB N/A -
3sfdvnlx2-d2i.js gzip 152 B N/A -
3u-chifslwdvs.js gzip 166 B N/A -
44un3--wmqiyh.js gzip 7.61 kB N/A -
turbopack-09..02ja.js gzip 4.2 kB N/A -
turbopack-0c.._q68.js gzip 4.18 kB N/A -
turbopack-0s..yucr.js gzip 4.19 kB N/A -
turbopack-0x..vpta.js gzip 4.19 kB N/A -
turbopack-10..-d_w.js gzip 4.19 kB N/A -
turbopack-11..dlm2.js gzip 4.18 kB N/A -
turbopack-1k..j62f.js gzip 4.19 kB N/A -
turbopack-27..b9wz.js gzip 4.17 kB N/A -
turbopack-2u..oxs7.js gzip 4.18 kB N/A -
turbopack-37..th14.js gzip 4.18 kB N/A -
turbopack-39..mfcn.js gzip 4.18 kB N/A -
turbopack-3h..4bnr.js gzip 4.18 kB N/A -
turbopack-3i..gib8.js gzip 4.19 kB N/A -
turbopack-3m..bo_z.js gzip 4.19 kB N/A -
07ao55cvtbxdj.js gzip N/A 153 B -
09t9i6o8nvir7.js gzip N/A 49.6 kB -
0arkbdqpxc37i.js gzip N/A 8.6 kB -
0bz-xifewa17d.js gzip N/A 8.63 kB -
0tp80kb9upsmd.js gzip N/A 153 B -
0tsy2vtfmen7f.js gzip N/A 155 B -
0tv67up09u6yz.js gzip N/A 168 B -
0tvekitj587fh.js gzip N/A 8.51 kB -
0y-5s9e_qen41.js gzip N/A 160 B -
0yvk6-wi8e9wh.js gzip N/A 13.3 kB -
0z83a1om5rvtt.js gzip N/A 7.61 kB -
1-jqyfc89tixo.js gzip N/A 1.46 kB -
14t1kneseb8th.js gzip N/A 2.3 kB -
15sb1-dsqfk_j.js gzip N/A 8.59 kB -
1ab2xruymo-oj.js gzip N/A 449 B -
1gt0tm9ba-fkj.js gzip N/A 70.8 kB -
1p-256e9l_n93.js gzip N/A 156 B -
1rexplishteym.js gzip N/A 156 B -
1tu25qtsmfhar.js gzip N/A 9.82 kB -
1vein_gnv3mwr.js gzip N/A 8.56 kB -
1wtjzfc14dkv9.js gzip N/A 154 B -
1wzrm0xjjbzn5.js gzip N/A 10.1 kB -
1xvan__507d2k.js gzip N/A 155 B -
1z3g0uaqtv9_3.js gzip N/A 8.56 kB -
25a1yz7zua29z.js gzip N/A 13.8 kB -
2bi5hx402juv-.js gzip N/A 8.58 kB -
2hy56297fog9u.js gzip N/A 8.52 kB -
2u_rpxq3tzytl.js gzip N/A 233 B -
31pzx_2wlpu4e.js gzip N/A 156 B -
368lim5wq0o0r.js gzip N/A 12.9 kB -
3drqjohogojbw.js gzip N/A 5.69 kB -
3fs484yi1tj7v.js gzip N/A 156 B -
3g8l1m2-o-ewi.js gzip N/A 13.1 kB -
3jmkxsnxg0nrh.js gzip N/A 10.4 kB -
3qacr5lkwv7qz.js gzip N/A 65.5 kB -
3qi06md02f2cn.js gzip N/A 159 B -
3socpyg9nr02a.js gzip N/A 157 B -
3wpp8nvyoj121.js gzip N/A 9.24 kB -
turbopack-0n..mrvy.js gzip N/A 4.17 kB -
turbopack-0p..kynv.js gzip N/A 4.19 kB -
turbopack-0s..7ud3.js gzip N/A 4.18 kB -
turbopack-17..4gpi.js gzip N/A 4.19 kB -
turbopack-1c..9gyb.js gzip N/A 4.19 kB -
turbopack-1e..ccp_.js gzip N/A 4.19 kB -
turbopack-1s..h27x.js gzip N/A 4.19 kB -
turbopack-1t..njk8.js gzip N/A 4.2 kB -
turbopack-29..e4gm.js gzip N/A 4.19 kB -
turbopack-2a..5zpv.js gzip N/A 4.19 kB -
turbopack-2c..tpfn.js gzip N/A 4.19 kB -
turbopack-2k..hjo6.js gzip N/A 4.19 kB -
turbopack-32..3ekq.js gzip N/A 4.19 kB -
turbopack-42..fj8z.js gzip N/A 4.19 kB -
Total 465 kB 465 kB ⚠️ +103 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 712 B 715 B
Total 712 B 715 B ⚠️ +3 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 431 B 433 B
Total 431 B 433 B ⚠️ +2 B

📦 Webpack

Client

Main Bundles
Canary PR Change
2637-HASH.js gzip 4.63 kB N/A -
7724.HASH.js gzip 169 B N/A -
8274-HASH.js gzip 61.4 kB N/A -
8817-HASH.js gzip 5.59 kB N/A -
c3500254-HASH.js gzip 62.8 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 254 B 255 B
main-HASH.js gzip 39.4 kB 39.3 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
5887-HASH.js gzip N/A 5.61 kB -
6522-HASH.js gzip N/A 60.8 kB -
6779-HASH.js gzip N/A 4.63 kB -
8854.HASH.js gzip N/A 169 B -
eab920f9-HASH.js gzip N/A 62.8 kB -
Total 236 kB 235 kB ✅ -640 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 182 B 182 B
css-HASH.js gzip 333 B 334 B
dynamic-HASH.js gzip 1.81 kB 1.8 kB
edge-ssr-HASH.js gzip 255 B 255 B
head-HASH.js gzip 353 B 349 B 🟢 4 B (-1%)
hooks-HASH.js gzip 384 B 382 B
image-HASH.js gzip 581 B 581 B
index-HASH.js gzip 260 B 259 B
link-HASH.js gzip 2.51 kB 2.51 kB
routerDirect..HASH.js gzip 316 B 318 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 313 B 314 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.98 kB 7.97 kB ✅ -10 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 126 kB 126 kB
page.js gzip 274 kB 273 kB
Total 399 kB 399 kB ✅ -384 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 620 B 618 B
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 43.9 kB 44.3 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 45.5 kB 45.9 kB ⚠️ +390 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 721 B 720 B
Total 721 B 720 B ✅ -1 B
Build Cache
Canary PR Change
0.pack gzip 4.39 MB 4.38 MB
index.pack gzip 115 kB 115 kB
index.pack.old gzip 114 kB 114 kB
Total 4.62 MB 4.61 MB ✅ -3.78 kB

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 347 kB 347 kB
app-page-exp..prod.js gzip 192 kB 192 kB
app-page-tur...dev.js gzip 347 kB 347 kB
app-page-tur..prod.js gzip 192 kB 192 kB
app-page-tur...dev.js gzip 343 kB 343 kB
app-page-tur..prod.js gzip 190 kB 190 kB
app-page.run...dev.js gzip 344 kB 344 kB
app-page.run..prod.js gzip 190 kB 190 kB
app-route-ex...dev.js gzip 77 kB 77 kB
app-route-ex..prod.js gzip 52.5 kB 52.5 kB
app-route-tu...dev.js gzip 77.1 kB 77.1 kB
app-route-tu..prod.js gzip 52.6 kB 52.6 kB
app-route-tu...dev.js gzip 76.7 kB 76.7 kB
app-route-tu..prod.js gzip 52.3 kB 52.3 kB
app-route.ru...dev.js gzip 76.6 kB 76.6 kB
app-route.ru..prod.js gzip 52.3 kB 52.3 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 43.9 kB 43.9 kB
pages-api-tu..prod.js gzip 33.5 kB 33.5 kB
pages-api.ru...dev.js gzip 43.9 kB 43.9 kB
pages-api.ru..prod.js gzip 33.5 kB 33.5 kB
pages-turbo....dev.js gzip 53.3 kB 53.3 kB
pages-turbo...prod.js gzip 39.1 kB 39.1 kB
pages.runtim...dev.js gzip 53.3 kB 53.3 kB
pages.runtim..prod.js gzip 39.1 kB 39.1 kB
server.runti..prod.js gzip 63 kB 63 kB
Total 3.07 MB 3.07 MB ✅ -1 B
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/77631e6dc9d11936dca57fa75b1321c9d4d77db5/next

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Mar 22, 2026

Merging this PR will not alter performance

✅ 17 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing eviction_semantics_for_real_this_time (8b16ef4) with canary (0b08e2f)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on racy_snapshot_encoding (e98a934) during the generation of this report, so canary (0b08e2f) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from c194c61 to fa50df9 Compare March 23, 2026 02:19
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from fa50df9 to 056be10 Compare March 23, 2026 22:03
@lukesandberg lukesandberg changed the title eviction Proof of concept: task eviction after snapshot for turbo-tasks-backend Mar 23, 2026
Comment thread test/e2e/filesystem-cache/evict-after-snapshot.test.ts
/// snapshot → evict → restore cycle works correctly.
///
/// Returns `(snapshot_had_new_data, eviction_counts)`.
pub fn snapshot_and_evict(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apply cfg(test)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub fn snapshot_and_evict(
pub fn snapshot_and_evict_for_testing(

Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage_schema.rs Outdated
Comment thread turbopack/crates/turbo-tasks/src/vc/traits.rs Outdated
@lukesandberg lukesandberg marked this pull request as ready for review March 24, 2026 22:30
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch 2 times, most recently from 116d63d to ae6878d Compare April 7, 2026 18:36
@lukesandberg lukesandberg marked this pull request as draft April 7, 2026 20:44
@lukesandberg lukesandberg changed the base branch from canary to graphite-base/91790 April 11, 2026 14:14
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from 35da0fa to 290c8d7 Compare April 11, 2026 14:14
@lukesandberg lukesandberg changed the base branch from graphite-base/91790 to racy_snapshot_encoding April 11, 2026 14:14
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch 2 times, most recently from 890a1ba to da87628 Compare April 13, 2026 23:47
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage_schema.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/storage_schema.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbo-tasks-backend/src/backend/mod.rs Outdated
Comment thread turbopack/crates/turbopack-node/src/evaluate.rs Outdated
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from 642cf11 to 77631e6 Compare April 17, 2026 22:19
@lukesandberg lukesandberg force-pushed the racy_snapshot_encoding branch from 5f7ce69 to c27d432 Compare April 17, 2026 22:19
@lukesandberg lukesandberg requested a review from sokra April 17, 2026 23:42
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from bc661cd to 852ab00 Compare April 21, 2026 17:50
lukesandberg added a commit that referenced this pull request Apr 21, 2026
## What

Tightens the value-type persistence API and sets the table for a future eviction policy. Two user-visible changes on the `#[turbo_tasks::value(...)]` macro:

- **`serialization = "none"` → `serialization = "skip"`** — imperative ("skip persisting") instead of descriptive.  Making it clear that it isn't that we are missing a feature but rather that we are choosing to not persist (of course persisting might be impossible but that is generally rare)
- **New `evict = "always" | "last" | "never"` attribute** — replaces the old overloaded `"none"` semantic. Only valid with `serialization = "skip"`. Defaults to `"always"`.

Internally this collapses `persistent_cell_data` + `transient_cell_data` into one `cell_data` map and replaces the old `bincode: Option<(enc, dec)>` field with a four-variant `ValueTypePersistence` enum. Eviction machinery itself is a follow-up PR; this PR just gives each value type a precise, queryable persistence/eviction descriptor.

## Why break out a new parameter?

`serialization = "none"` on canary conflated three different intents:

1. **Cheap recomputable outputs** (SWC ASTs, codegen `Rope`s) — fine to evict, recompute is cheap.
2. **Expensive recomputable outputs** (WASM modules, Node process pools) — re-derivable but costly.
3. **Session-scoped state** (`State<>` cells, `Arc<Mutex<_>>` dedup histories) — can't be recomputed without losing accumulated mutations.

They all produced identical runtime behavior (stored in transient_cell_data), so eviction can't tell them apart. The fix is two orthogonal attributes:

```rust
// A cheap skip — default evict = "always"
#[turbo_tasks::value(serialization = "skip")]
// Expensive recompute — evict last under pressure
#[turbo_tasks::value(serialization = "skip", evict = "last")]
// Session-scoped state — never evict
#[turbo_tasks::value(serialization = "skip", evict = "never")]
```

The macro rejects `evict` on any other `serialization` mode.

## `ValueTypePersistence` enum

Replaces `ValueType.bincode: Option<(enc, dec)>`:

```rust
pub enum ValueTypePersistence {
    Persistable(AnyEncodeFn, AnyDecodeFn<SharedReference>),  // auto, custom
    SkipPersist { expensive: bool },                         // skip (+ evict = last)
    HashOnly,                                                // hash
    SessionStateful,                                         // skip + evict = never
}
```

The existing `"hash"` mode gets its own `HashOnly` variant rather than being folded into `SkipPersist`, which lets the backend gate its hash-writing and hash-comparison paths precisely.

## Unified `cell_data` storage

`persistent_cell_data: AutoMap<CellId, TypedSharedReference>` + `transient_cell_data: AutoMap<CellId, SharedReference>` collapse into `cell_data: CellData`. `CellData` is a newtype over `AutoMap<CellId, SharedReference>` with a custom bincode impl that filters non-`Persistable` entries at encode time. This removes the `is_serializable_cell_content: bool` parameter that was threading through ~14 read/write call sites.

Uses `SharedReference` instead of `TypedSharedReference` — `CellId` already carries the `ValueTypeId`.

## Annotation sweep

All prior `serialization = "none"` sites move to either `serialization = "skip", evict = "never"` or `serialization = "skip", evict = "last"` based on a per-site audit. Summary:

**`evict = "last"` (6 sites)** — re-derivable but expensive:
- `SwcPluginModule`, `EvaluatePool`, `ChildProcessPool`, `WorkerThreadPool`, `EffectInstance`, `Effects`

**`evict = "never"` (2 sites)** — interior-mutable state accumulated across the session:
- `ConsoleUi` (`Arc<Mutex<SeenIssues>>`), `VersionState` (`State<VersionRef>` with HMR invalidators)

The distinguishing rule: `evict = "never"` only when the value holds interior mutability accumulated across the session. Everything else can be re-derived (possibly expensively) by re-running the producing task.

## Follow-ups (separate PRs)

- Wire an eviction policy that consumes `ValueTypePersistence` — respects `SessionStateful` (never evict), prefers cheap `SkipPersist` over `expensive: true` ones.  Either as part of #91790 or afterwards depending on when things land

<!-- NEXT_JS_LLM_PR -->
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from 852ab00 to 765be4f Compare April 21, 2026 23:48
@lukesandberg lukesandberg force-pushed the racy_snapshot_encoding branch from 054b887 to 6964cfd Compare April 21, 2026 23:48
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from 765be4f to c5f0530 Compare April 21, 2026 23:52
@lukesandberg lukesandberg force-pushed the racy_snapshot_encoding branch from 6964cfd to e98a934 Compare April 22, 2026 00:05
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from c5f0530 to 8b16ef4 Compare April 22, 2026 00:05
@lukesandberg lukesandberg force-pushed the racy_snapshot_encoding branch from e98a934 to 06eef17 Compare April 24, 2026 23:04
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from 8b16ef4 to 6ba65cc Compare April 24, 2026 23:04
@lukesandberg lukesandberg force-pushed the racy_snapshot_encoding branch from 06eef17 to dffcc78 Compare April 24, 2026 23:06
@lukesandberg lukesandberg force-pushed the eviction_semantics_for_real_this_time branch from 6ba65cc to 46b10ce Compare April 24, 2026 23:06
@github-actions
Copy link
Copy Markdown
Contributor

Stats from current PR

✅ No significant changes detected

📊 All Metrics
📖 Metrics Glossary

Dev Server Metrics:

  • Listen = TCP port starts accepting connections
  • First Request = HTTP server returns successful response
  • Cold = Fresh build (no cache)
  • Warm = With cached build artifacts

Build Metrics:

  • Fresh = Clean build (no .next directory)
  • Cached = With existing .next directory

Change Thresholds:

  • Time: Changes < 50ms AND < 10%, OR < 2% are insignificant
  • Size: Changes < 1KB AND < 1% are insignificant
  • All other changes are flagged to catch regressions

⚡ Dev Server

Metric Canary PR Change
Cold (Listen) 811ms 810ms
Cold (Ready in log) 783ms 784ms
Cold (First Request) 1.232s 1.247s
Warm (Listen) 812ms 811ms
Warm (Ready in log) 789ms 787ms
Warm (First Request) 604ms 602ms
📦 Dev Server (Webpack) (Legacy)

📦 Dev Server (Webpack)

Metric Canary PR Change
Cold (Listen) 812ms 812ms
Cold (Ready in log) 776ms 777ms
Cold (First Request) 3.193s 3.185s
Warm (Listen) 812ms 812ms
Warm (Ready in log) 774ms 778ms
Warm (First Request) 3.160s 3.178s

⚡ Production Builds

Metric Canary PR Change
Fresh Build 4.871s 4.875s
Cached Build 4.873s 4.884s
📦 Production Builds (Webpack) (Legacy)

📦 Production Builds (Webpack)

Metric Canary PR Change
Fresh Build 23.642s 23.791s
Cached Build 23.621s 23.816s
node_modules Size 495 MB 495 MB
📦 Bundle Sizes

Bundle Sizes

⚡ Turbopack

Client

Main Bundles
Canary PR Change
07rxhp_1_g4mu.js gzip 13.1 kB N/A -
0cz1d0mv5g_q7.js gzip 39.4 kB 39.4 kB
0fli3_wppnim5.js gzip 12.9 kB N/A -
0jaojkrb2rf_l.js gzip 158 B N/A -
0k09jwjeb-tki.js gzip 13.8 kB N/A -
0kb7_ep3r1z0_.js gzip 10.1 kB N/A -
0kw8xgqdrilf6.js gzip 8.56 kB N/A -
0ojkk2e654xsc.js gzip 8.59 kB N/A -
0wxpyd8r-vipl.js gzip 1.47 kB N/A -
0xy2fhla48_rd.js gzip 9.24 kB N/A -
0zg1_op6gpm77.js gzip 159 B N/A -
10u1wg6830n69.js gzip 155 B N/A -
10wqsvi2mgfmi.js gzip 9.82 kB N/A -
16lhqjoqbznyg.js gzip 220 B 220 B
16vepdkipri3r.js gzip 8.51 kB N/A -
17n96uu6y1pxq.js gzip 8.6 kB N/A -
18y4_8-9or0mn.js gzip 8.51 kB N/A -
1ejk4yy877m2s.js gzip 156 B N/A -
1elt1qium-r2m.css gzip 115 B 115 B
1gq145j3kps-h.js gzip 8.62 kB N/A -
1nsh-mbn0e-se.js gzip 8.56 kB N/A -
1o8iht4q821x5.js gzip 49.4 kB N/A -
1tsrrp1tdngti.js gzip 13.3 kB N/A -
1wbblhm8kdg1d.js gzip 70.9 kB N/A -
2__-e_ym8n788.js gzip 450 B N/A -
21h2q5l_ijxo1.js gzip 156 B N/A -
22o6xd9_ywdu6.js gzip 233 B N/A -
25ee1c0k3yry7.js gzip 155 B N/A -
25n272-g99oa1.js gzip 7.61 kB N/A -
2jqyc54izxg_5.js gzip 154 B N/A -
2kvj8yrfznmwx.js gzip 5.69 kB N/A -
2m-x8jeelz1qx.js gzip 169 B N/A -
2qv7m7xjnokgr.js gzip 8.58 kB N/A -
2t9oc38of5_ar.js gzip 153 B N/A -
2zf1ecbz94sp-.js gzip 65.5 kB N/A -
342ijzvrpe53h.js gzip 2.29 kB N/A -
3b0qzjz24jcjn.js gzip 157 B N/A -
3k1k5gtofm6eq.js gzip 10.4 kB N/A -
3m606uqf8ws_m.js gzip 155 B N/A -
3msaeh9eztxfm.js gzip 161 B N/A -
3pgbrgq66slx4.js gzip 155 B N/A -
turbopack-02..a6-3.js gzip 4.19 kB N/A -
turbopack-0b..7ght.js gzip 4.17 kB N/A -
turbopack-19..b8v3.js gzip 4.19 kB N/A -
turbopack-1k..fy7t.js gzip 4.19 kB N/A -
turbopack-1n..nqqb.js gzip 4.2 kB N/A -
turbopack-1z..cxi_.js gzip 4.19 kB N/A -
turbopack-21..uim9.js gzip 4.19 kB N/A -
turbopack-27..jjpo.js gzip 4.19 kB N/A -
turbopack-2m..i5vn.js gzip 4.19 kB N/A -
turbopack-2m..1fe1.js gzip 4.19 kB N/A -
turbopack-2v..1576.js gzip 4.19 kB N/A -
turbopack-33..fmta.js gzip 4.19 kB N/A -
turbopack-3q..h-7b.js gzip 4.19 kB N/A -
turbopack-3u..fo-_.js gzip 4.19 kB N/A -
01ofzfnqdbuen.js gzip N/A 158 B -
0arkbdqpxc37i.js gzip N/A 8.6 kB -
0bz-xifewa17d.js gzip N/A 8.63 kB -
0gh_yv8qw4m5-.js gzip N/A 157 B -
0im0h0br03kar.js gzip N/A 156 B -
0tvekitj587fh.js gzip N/A 8.51 kB -
0yvk6-wi8e9wh.js gzip N/A 13.3 kB -
1-jqyfc89tixo.js gzip N/A 1.46 kB -
10y3h86mnhs_2.js gzip N/A 10.4 kB -
14t1kneseb8th.js gzip N/A 2.3 kB -
15sb1-dsqfk_j.js gzip N/A 8.59 kB -
1ab2xruymo-oj.js gzip N/A 449 B -
1cz0kmzuvr895.js gzip N/A 70.9 kB -
1tu25qtsmfhar.js gzip N/A 9.82 kB -
1vein_gnv3mwr.js gzip N/A 8.56 kB -
1wzrm0xjjbzn5.js gzip N/A 10.1 kB -
1z3g0uaqtv9_3.js gzip N/A 8.56 kB -
25a1yz7zua29z.js gzip N/A 13.8 kB -
2auzvn7t9xf96.js gzip N/A 65.5 kB -
2bi5hx402juv-.js gzip N/A 8.58 kB -
2fiqb4-ar30kx.js gzip N/A 49.4 kB -
2fuln2dxq8d_0.js gzip N/A 154 B -
2hy56297fog9u.js gzip N/A 8.52 kB -
2qd9d0wg7yxwc.js gzip N/A 158 B -
2u_rpxq3tzytl.js gzip N/A 233 B -
2wr55o64ssudv.js gzip N/A 161 B -
2yy2v4vukl6e0.js gzip N/A 161 B -
35-eg4zotgxro.js gzip N/A 157 B -
35nh2lh_i5pyh.js gzip N/A 7.61 kB -
368lim5wq0o0r.js gzip N/A 12.9 kB -
3drqjohogojbw.js gzip N/A 5.69 kB -
3g8l1m2-o-ewi.js gzip N/A 13.1 kB -
3ixmpqnyxmqfs.js gzip N/A 170 B -
3k0wlheipb1ej.js gzip N/A 159 B -
3km28rtkbqo-g.js gzip N/A 158 B -
3n9xy43ds2l11.js gzip N/A 159 B -
3tfgis6xa1unl.js gzip N/A 158 B -
3wpp8nvyoj121.js gzip N/A 9.24 kB -
turbopack-0-..xakf.js gzip N/A 4.19 kB -
turbopack-09..ikej.js gzip N/A 4.19 kB -
turbopack-0j..nybk.js gzip N/A 4.19 kB -
turbopack-0o..1pwm.js gzip N/A 4.21 kB -
turbopack-1m..wh9e.js gzip N/A 4.17 kB -
turbopack-1r..xsvl.js gzip N/A 4.19 kB -
turbopack-1t..xctc.js gzip N/A 4.19 kB -
turbopack-28..ffdj.js gzip N/A 4.19 kB -
turbopack-2k..ao0y.js gzip N/A 4.19 kB -
turbopack-2o..i1c7.js gzip N/A 4.19 kB -
turbopack-2o..wsn2.js gzip N/A 4.19 kB -
turbopack-2t..clq6.js gzip N/A 4.19 kB -
turbopack-35..-wtq.js gzip N/A 4.19 kB -
turbopack-3w..fwa0.js gzip N/A 4.19 kB -
Total 465 kB 465 kB ⚠️ +90 B

Server

Middleware
Canary PR Change
middleware-b..fest.js gzip 721 B 719 B
Total 721 B 719 B ✅ -2 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 435 B 433 B
Total 435 B 433 B ✅ -2 B

📦 Webpack

Client

Main Bundles
Canary PR Change
2637-HASH.js gzip 4.63 kB N/A -
7724.HASH.js gzip 169 B N/A -
8274-HASH.js gzip 61.3 kB N/A -
8817-HASH.js gzip 5.59 kB N/A -
c3500254-HASH.js gzip 62.8 kB N/A -
framework-HASH.js gzip 59.7 kB 59.7 kB
main-app-HASH.js gzip 255 B 255 B
main-HASH.js gzip 39.4 kB 39.3 kB
webpack-HASH.js gzip 1.68 kB 1.68 kB
5887-HASH.js gzip N/A 5.61 kB -
6522-HASH.js gzip N/A 60.6 kB -
6779-HASH.js gzip N/A 4.63 kB -
8854.HASH.js gzip N/A 169 B -
eab920f9-HASH.js gzip N/A 62.8 kB -
Total 235 kB 235 kB ✅ -620 B
Polyfills
Canary PR Change
polyfills-HASH.js gzip 39.4 kB 39.4 kB
Total 39.4 kB 39.4 kB
Pages
Canary PR Change
_app-HASH.js gzip 193 B 193 B
_error-HASH.js gzip 182 B 182 B
css-HASH.js gzip 333 B 334 B
dynamic-HASH.js gzip 1.81 kB 1.8 kB
edge-ssr-HASH.js gzip 255 B 255 B
head-HASH.js gzip 353 B 349 B 🟢 4 B (-1%)
hooks-HASH.js gzip 384 B 382 B
image-HASH.js gzip 581 B 581 B
index-HASH.js gzip 260 B 259 B
link-HASH.js gzip 2.52 kB 2.52 kB
routerDirect..HASH.js gzip 316 B 318 B
script-HASH.js gzip 386 B 386 B
withRouter-HASH.js gzip 313 B 314 B
1afbb74e6ecf..834.css gzip 106 B 106 B
Total 7.99 kB 7.98 kB ✅ -10 B

Server

Edge SSR
Canary PR Change
edge-ssr.js gzip 126 kB 126 kB
page.js gzip 274 kB 273 kB
Total 400 kB 399 kB ✅ -629 B
Middleware
Canary PR Change
middleware-b..fest.js gzip 616 B 616 B
middleware-r..fest.js gzip 156 B 156 B
middleware.js gzip 44.4 kB 44.3 kB
edge-runtime..pack.js gzip 842 B 842 B
Total 46 kB 45.9 kB ✅ -80 B
Build Details
Build Manifests
Canary PR Change
_buildManifest.js gzip 722 B 719 B
Total 722 B 719 B ✅ -3 B
Build Cache
Canary PR Change
0.pack gzip 4.39 MB 4.39 MB
index.pack gzip 113 kB 115 kB 🔴 +1.29 kB (+1%)
index.pack.old gzip 115 kB 115 kB
Total 4.62 MB 4.62 MB ✅ -917 B

🔄 Shared (bundler-independent)

Runtimes
Canary PR Change
app-page-exp...dev.js gzip 348 kB 348 kB
app-page-exp..prod.js gzip 193 kB 193 kB
app-page-tur...dev.js gzip 347 kB 347 kB
app-page-tur..prod.js gzip 193 kB 193 kB
app-page-tur...dev.js gzip 344 kB 344 kB
app-page-tur..prod.js gzip 191 kB 191 kB
app-page.run...dev.js gzip 344 kB 344 kB
app-page.run..prod.js gzip 191 kB 191 kB
app-route-ex...dev.js gzip 77.3 kB 77.3 kB
app-route-ex..prod.js gzip 52.7 kB 52.7 kB
app-route-tu...dev.js gzip 77.3 kB 77.3 kB
app-route-tu..prod.js gzip 52.8 kB 52.8 kB
app-route-tu...dev.js gzip 76.9 kB 76.9 kB
app-route-tu..prod.js gzip 52.5 kB 52.5 kB
app-route.ru...dev.js gzip 76.9 kB 76.9 kB
app-route.ru..prod.js gzip 52.5 kB 52.5 kB
dist_client_...dev.js gzip 324 B 324 B
dist_client_...dev.js gzip 326 B 326 B
dist_client_...dev.js gzip 318 B 318 B
dist_client_...dev.js gzip 317 B 317 B
pages-api-tu...dev.js gzip 44.2 kB 44.2 kB
pages-api-tu..prod.js gzip 33.6 kB 33.6 kB
pages-api.ru...dev.js gzip 44.2 kB 44.2 kB
pages-api.ru..prod.js gzip 33.6 kB 33.6 kB
pages-turbo....dev.js gzip 53.5 kB 53.5 kB
pages-turbo...prod.js gzip 39.3 kB 39.3 kB
pages.runtim...dev.js gzip 53.5 kB 53.5 kB
pages.runtim..prod.js gzip 39.3 kB 39.3 kB
server.runti..prod.js gzip 63.1 kB 63.1 kB
Total 3.07 MB 3.07 MB
📎 Tarball URL
https://vercel-packages.vercel.app/next/commits/46b10ceb3ec601e9ab2e63c031a673ff730ef2bd/next

Commit: 46b10ce

@github-actions
Copy link
Copy Markdown
Contributor

Failing test suites

Commit: 46b10ce | About building and testing Next.js

pnpm test-dev test/e2e/filesystem-cache/evict-after-snapshot.test.ts (job)

  • evict-after-snapshot > should serve correct content after eviction and HMR (DD)
  • evict-after-snapshot > should handle client component HMR after eviction (DD)
Expand output

● evict-after-snapshot › should serve correct content after eviction and HMR

expect(received).toBe(expected) // Object.is equality

Expected: "cycle 1"
Received: "hello world"

  55 |         const expected = currentContent
  56 |         await retry(async () => {
> 57 |           expect(await browser.elementByCss('p').text()).toBe(expected)
     |                                                          ^
  58 |         }, 10000)
  59 |       }
  60 |

  at toBe (e2e/filesystem-cache/evict-after-snapshot.test.ts:57:58)
  at retry (lib/next-test-utils.ts:862:14)
  at Object.<anonymous> (e2e/filesystem-cache/evict-after-snapshot.test.ts:56:9)

● evict-after-snapshot › should handle client component HMR after eviction

expect(received).toBe(expected) // Object.is equality

Expected: "hello eviction"
Received: "hello world"

  78 |         async () => {
  79 |           await retry(async () => {
> 80 |             expect(await browser.elementByCss('p').text()).toBe(
     |                                                            ^
  81 |               'hello eviction'
  82 |             )
  83 |           }, 10000)

  at toBe (e2e/filesystem-cache/evict-after-snapshot.test.ts:80:60)
  at retry (lib/next-test-utils.ts:862:14)
  at e2e/filesystem-cache/evict-after-snapshot.test.ts:79:11
  at NextDevInstance.patchFile (lib/next-modes/base.ts:756:9)
  at NextDevInstance.patchFile (lib/next-modes/next-dev.ts:304:16)
  at Object.<anonymous> (e2e/filesystem-cache/evict-after-snapshot.test.ts:75:7)

pnpm test-dev test/e2e/filesystem-cache/evict-after-snapshot.test.ts (job)

  • evict-after-snapshot > should serve correct content after eviction and HMR (DD)
  • evict-after-snapshot > should handle client component HMR after eviction (DD)
Expand output

● evict-after-snapshot › should serve correct content after eviction and HMR

expect(received).toBe(expected) // Object.is equality

Expected: "cycle 1"
Received: "hello world"

  55 |         const expected = currentContent
  56 |         await retry(async () => {
> 57 |           expect(await browser.elementByCss('p').text()).toBe(expected)
     |                                                          ^
  58 |         }, 10000)
  59 |       }
  60 |

  at toBe (e2e/filesystem-cache/evict-after-snapshot.test.ts:57:58)
  at retry (lib/next-test-utils.ts:862:14)
  at Object.<anonymous> (e2e/filesystem-cache/evict-after-snapshot.test.ts:56:9)

● evict-after-snapshot › should handle client component HMR after eviction

expect(received).toBe(expected) // Object.is equality

Expected: "hello eviction"
Received: "hello world"

  78 |         async () => {
  79 |           await retry(async () => {
> 80 |             expect(await browser.elementByCss('p').text()).toBe(
     |                                                            ^
  81 |               'hello eviction'
  82 |             )
  83 |           }, 10000)

  at toBe (e2e/filesystem-cache/evict-after-snapshot.test.ts:80:60)
  at retry (lib/next-test-utils.ts:862:14)
  at e2e/filesystem-cache/evict-after-snapshot.test.ts:79:11
  at NextDevInstance.patchFile (lib/next-modes/base.ts:756:9)
  at NextDevInstance.patchFile (lib/next-modes/next-dev.ts:304:16)
  at Object.<anonymous> (e2e/filesystem-cache/evict-after-snapshot.test.ts:75:7)

pnpm test-dev-turbo test/e2e/filesystem-cache/evict-after-snapshot.test.ts (turbopack) (job)

  • evict-after-snapshot > should serve correct content after eviction and HMR (DD)
  • evict-after-snapshot > should handle client component HMR after eviction (DD)
Expand output

● evict-after-snapshot › should serve correct content after eviction and HMR

expect(received).toBe(expected) // Object.is equality

Expected: "cycle 1"
Received: "hello world"

  55 |         const expected = currentContent
  56 |         await retry(async () => {
> 57 |           expect(await browser.elementByCss('p').text()).toBe(expected)
     |                                                          ^
  58 |         }, 10000)
  59 |       }
  60 |

  at toBe (e2e/filesystem-cache/evict-after-snapshot.test.ts:57:58)
  at retry (lib/next-test-utils.ts:862:14)
  at Object.<anonymous> (e2e/filesystem-cache/evict-after-snapshot.test.ts:56:9)

● evict-after-snapshot › should handle client component HMR after eviction

expect(received).toBe(expected) // Object.is equality

Expected: "hello eviction"
Received: "hello world"

  78 |         async () => {
  79 |           await retry(async () => {
> 80 |             expect(await browser.elementByCss('p').text()).toBe(
     |                                                            ^
  81 |               'hello eviction'
  82 |             )
  83 |           }, 10000)

  at toBe (e2e/filesystem-cache/evict-after-snapshot.test.ts:80:60)
  at retry (lib/next-test-utils.ts:862:14)
  at e2e/filesystem-cache/evict-after-snapshot.test.ts:79:11
  at NextDevInstance.patchFile (lib/next-modes/base.ts:756:9)
  at NextDevInstance.patchFile (lib/next-modes/next-dev.ts:304:16)
  at Object.<anonymous> (e2e/filesystem-cache/evict-after-snapshot.test.ts:75:7)

Comment on lines +55 to +56
/// - `SkipPersist { expensive: false }` — cheap to re-derive by re-running the task.
/// - `HashOnly` — the hash lives in `cell_data_hash`; value is re-derived.
Copy link
Copy Markdown
Member

@sokra sokra Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the split is a bit weird here:

I would make it SkipPersist { expensive: bool, hash: bool } instead of SkipPersist and HashOnly.

Currently you are limiting HashOnly to never be expensive: true, but that might not be true. We could also have an expensive to recompute value that is stored with hash.

Comment on lines +85 to +87
if self.len() < len_start {
self.shrink_to_fit();
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if self.len() < len_start {
self.shrink_to_fit();
}
self.shrink_to_fit();

Why do we want to do that conditionally? I guess it's always good to shrink at this point.


/// Configurable idle timeout for snapshot persistence.
/// Defaults to 2 seconds if not set or if the value is invalid.
/// Defaults to 10 seconds if not set or if the value is invalid.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Defaults to 10 seconds if not set or if the value is invalid.
/// Defaults to 2 seconds if not set or if the value is invalid.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a reviewer honeypot, wasn't it?

/// then re-check the specific task's `restoring`/`restored` bits after waking.
pub(crate) restored: Event,
/// Maps `CachedTaskType` → `TaskId` for deduplication of persistent task creation.
/// This is backed by the TaskCache table in the backend.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This is backed by the TaskCache table in the backend.
/// This is backed by the TaskCache table in the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

created-by: Turbopack team PRs by the Turbopack team. tests Turbopack Related to Turbopack with Next.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants