[turbopack] Retain fewer stale cache versions and use a TTL - #96941
Open
lukesandberg wants to merge 7 commits into
Open
[turbopack] Retain fewer stale cache versions and use a TTL#96941lukesandberg wants to merge 7 commits into
lukesandberg wants to merge 7 commits into
Conversation
Contributor
Failing test suitesCommit: 824e057 | About building and testing Next.js
Expand output● use-cache-custom-handler-dev › serves a short-expire value warm through a custom handler and re-warms it on each reload ● use-cache-custom-handler-dev › stops serving a front-cached entry after the backing cache is purged out-of-band |
Contributor
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
Build Cache
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (2 files)Files with changes:
View diffspages-api.runtime.dev.jsDiff too large to display pages.runtime.dev.jsDiff too large to display 📎 Tarball URLCommit: 824e057 |
lukesandberg
commented
Aug 7, 2026
lukesandberg
commented
Aug 7, 2026
lukesandberg
commented
Aug 7, 2026
lukesandberg
commented
Aug 7, 2026
lukesandberg
commented
Aug 7, 2026
Remove development narrative and restated code from the comments added in this change, and fix two stale references to the old count-based retention design (a doc comment mentioning a 'count limit' that no longer exists, and the test_max_versions name).
lukesandberg
force-pushed
the
lukesandberg/turbopack_disk_cache_semantics
branch
from
August 8, 2026 19:46
bd53d64 to
85f082d
Compare
Stamping last_used_time on every open cost two fsyncs (the CURRENT.next sync_data plus the directory sync) to refresh a hint compared against a 3-day TTL. Commits already stamp it, so any session that writes anything is covered; the open-time write only mattered for read-only or no-write sessions, which are rare and would shift the stamp by minutes against a threshold of days. Also restores open_read_only_with_parallel_scheduler to pass read_only: false to open_directory as it did before - that flag was only flipped to keep the open-time stamp write from running cleanup.
The field is only ever stamped by commits, so the old name overpromised. Renames the Rust field, the JSON key, and the TS reader, plus the db_versioning helper that consumes it (time_since_last_used -> time_since_last_commit). The retention concept stays 'last used' since a cache that's in use gets written to.
Removes three tests that weren't earning their keep: - test_ttl_days_override: exercised a trivial parse routine at the cost of unsafe process-wide env mutation and a SAFETY obligation nothing enforced. - test_ttl_retains_recently_used_version: the not_ci case of test_only_most_recently_used_other_version_is_retained already covers retaining a within-TTL version. - test_survivor_independent_of_scan_order: named for a property it couldn't establish, since read_dir order isn't controllable from the test. The min-tracking it actually covered is trivial. With the parse no longer under test, also drops the hand-rolled digits-only guard in favor of plain u64 parsing, which now accepts a leading '+'.
lukesandberg
enabled auto-merge (squash)
August 9, 2026 02:18
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.
In CI we do not retain old versions of the db at all, but in dev or non-CI settings we would retain up to 2 indefinitely.
Given how large caches can grow, this PR reduces it to no more than 1 old version, and then only for a certain amount of time, currently 3 days. The idea being to support switching back and forth between feature branches and a next.js upgrade branch, 3 days allows this worflow to survive a weekend.
To support this the
CURRENTfile format is modified. Instead of just storing a sequence number it now stores a small json object containing themax_sequence_numberand the mtime. We store the last_write_time in the file to support the fact that we anticipatecachedirectories to be copied around and the native mtime would record the copy time instead of the commit time.This should reduce dev time disk usage in the common case.