Repository navigation
perf(pack): write the library snapshot in one stream per kind of value - #2373
Merged
Merged
Conversation
Co-Authored-By: jason.han <hanhuijun@gmail.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
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 and why
The js/wasm size budgets have been raised repeatedly (#2367, #2355, #2187) and three pull requests were blocked on the engine budget by a few KB of their own code (#2354, #2294, #2335). This returns about 0.7 MB gzipped to every artefact that embeds the library snapshot, without removing anything.
The embedded snapshot is 4.16 MB raw and was 1.63 MB of each gzipped artefact.
internal/syntax/packwrote every value into one byte stream — a length, a string index, a span delta, a boolean — and that interleaving defeats gzip, although each kind on its own is very regular. The writer now keeps one stream per kind of value (lengths, booleans, floats, unsigned, signed, string indices), and splits each multi-byte varint into its first byte and its tail. A section is led by the lengths of its streams, so it is still decoded apart from the rest. The snapshot is the same size raw (4,157,811 → 4,157,921 bytes) and gzips to 0.95 MB.The encoding is lossless and knows nothing about the content. Because the bytes differ,
snapshotFormatVersion(31 → 32) and the on-disk recordformatVersion(36 → 37) are bumped, so an older cache entry is rejected and rebuilt rather than misread; the pinned symbol-kind digest moves only because it includes the format number.Gzipped sizes from
make wasm-check(go1.27.4),develop36c76c4 against this branch. No budget constant is changed.sysml-enginesysmlsysml-coresysml-syntax(no snapshot)sysml-wasmHow it was verified
go build ./...,go vet ./...,gofmt -l .(empty),go test -count=1 ./...,make lint,go test -C tools ./referee/apijsonandmake wasm-checkpass on this head, with the snapshot regenerated bymake stdlib-snapshot.internal/syntax/packtests: the malformed-input cases are rewritten for the new layout and extended (missing or overlong stream lengths, unterminated and overflowing varint tails, lengths beyond the bytes left, a section longer than its stream, reads past a stream); a new test checks that each kind lands in its own stream and that values read back in any interleaving. Trailing bytes after the last stream are still reported byDone.BenchmarkDecodeSnapshot11.6 → 11.1 ms (mean of 8), 42.2 MB and 72.1 k allocations in both.Not run locally: the
-racesuite (make test); the plaingo test ./...suite was run instead.Checklist
make testandmake lintpass locally —make lintandgo test ./...yes;-raceleft to CIdocs/internals/architecture.md,docs/internals/performance.md)changes/unreleased/pack-columnar-streams.performance.mdmake docs-countsrun if a gate count moved — none moved🟢 Devin Review found nothing to fix · View findings