Add offline zstd dictionary tooling - #98281
Draft
lukesandberg wants to merge 9 commits into
Draft
Conversation
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Contributor
Failing test suitesCommit: 5f71ff4 | About building and testing Next.js
Expand output● app fetch build cache › should not use stale data if present |
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
lukesandberg
commented
Sep 4, 2026
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
lukesandberg
commented
Sep 5, 2026
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
lukesandberg
commented
Sep 5, 2026
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
lukesandberg
commented
Sep 6, 2026
lukesandberg
commented
Sep 6, 2026
lukesandberg
commented
Sep 6, 2026
Co-authored-by: Luke Sandberg <210140+lukesandberg@users.noreply.github.com>
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.
What?
Adds offline zstd dictionary training/evaluation tooling and enables a checked-in 64 KiB static dictionary for the TaskData persistence family.
Why?
TaskData is largely serialized state derived from JavaScript/CSS source and dependencies, so a representative static dictionary can remove repetition that ordinary zstd cannot capture independently in each value/block.
Dictionary iteration should not require rebuilding applications.
zstd_dictionarytrains and evaluates candidates from copied cache directories, while a resumable script builds a corpus from maintainedtest/productionapps.How?
FamilyConfignow storesCompressionConfig::{Lz4, Zstd3, Zstd3WithDictionary}. The configuration is threaded through SST/blob reads, writes, compaction, iteration, and block caches. Writers reuse a prepared dictionary compressor; readers retain one thread-local zstd context and reload its dictionary only when the configured dictionary changes.Meta files record both the compression algorithm and zstd dictionary ID. Database open validates both before serving reads, so a missing/wrong dictionary fails early rather than as an opaque decompression error. The meta magic changes because the header gained the dictionary-ID field.
zstd_dictionary:StaticSortedFileIterto read logical slice/medium/blob values;--source-dictionaryonly for SSTs already written with a dictionary;sst_inspectalso accepts--source-dictionaryso dictionary-compressed caches remain inspectable.The checked-in
train-taskdata-dictionary.shruns production tests in isolatedTMPDIRs with cleanup disabled, copies valid cache databases, hashes test paths into an 80/20 train/holdout split, resumes completed cases, trains, and performs five holdout evaluations.Held-out receipts
The sandbox completed 194 of 362 production test files before its disk budget was exhausted, yielding 204 training caches and 38 held-out caches. This limitation is recorded beside the dictionary; the script is resumable in a larger environment.
Held-out logical input: 1,462,462,144 bytes.
The raw saved bytes equal 29.32% of the copied holdout cache-directory total. That is directional rather than an exact rewritten-cache measurement. Timing is machine-specific diagnostic data; stable byte counts are the primary receipt.
Dictionary provenance:
11663000722d9e019e3c1071f1Verification
A real dictionary-compressed Next.js cache was also checked manually: opening without
--source-dictionaryfails with the recorded/expected IDs, whilezstd_dictionaryandsst_inspectboth succeed with the embedded dictionary. A current LZ4 TaskMeta cache also trains/evaluates directly without conversion or a source dictionary.Known limits: