src: make compile cache zstd dictionary reproducible#17
Open
lemire wants to merge 1 commit into
Open
Conversation
Add tools/train_compile_cache_dict.mjs, a maintainer tool that regenerates src/compile_cache_zstd.dict end to end, and replace the embedded dictionary with its byte-for-byte reproducible output. The script walks a fixed in-tree corpus, harvests a V8 code cache from each module via vm.compileFunction with produceCachedData (the same shape the CommonJS loader produces at runtime), feeds the blobs to `zstd --train`, and writes the 16 KiB dictionary in place. The output is byte-for-byte stable when node is run with --predictable (the script re-execs itself with it, since V8 otherwise randomizes the string hash seed and that seed leaks into cachedData), the corpus and its sorted order are fixed, and the node build is fixed. This documents and makes reproducible exactly how the embedded dictionary was created, so a future maintainer can regenerate it (e.g. after a V8 or corpus change) and review the resulting diff. Refs: nodejs#63861
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.
self-explanatory