perf(build): faster builds via JSON compression skip + zopfli/gen2 tuning#3441
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
jamiehenson
approved these changes
Jun 23, 2026
2fb1c32 to
c929d67
Compare
Two compression levers ported from Voltaire to speed up builds: - Drop JSON from the pre-compress glob. Most are Gatsby's page-data.json (high count, large total size) and zopfli-precompressing them was the bulk of onPostBuild time for ~5-10% extra ratio over nginx's live gzip. nginx is configured with `gzip on; gzip_types application/json; gzip_static on;` so JSON is live-gzipped on the way out — no loss of gzip on JSON responses. assert-compressed.sh updated to match. - Lower the default zopfli numiterations from 15 to 1. CI already overrides to 1; this speeds local builds too. The deflate ratio plateaus after the first iteration (<0.5% byte savings vs. 5/15 for 25-45% more time per file). ASSET_COMPRESSION_ITERATIONS still allows bumping it for production if max ratio is wanted. Verified locally: 541 css/js/svg files compressed in 11.6s, no *.json.gz produced, assert-compressed.sh passes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Only the build job runs the CPU-bound `yarn build`; other jobs are light. gen2 is ~1.4x faster CPU at +20% credits/min, so it's the one place the trade pays off (per Voltaire's gen2 rollout). Falls back to xlarge if gen2 is unavailable on the plan. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c929d67 to
be6d373
Compare
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.
Context
Faster build feedback for the docs site. The repo already runs the piscina + zopfli compression pool (and CI already sets
ASSET_COMPRESSION_ITERATIONS: 1/COMPRESS_MAX_THREADS: 4), so the easy wins were in. This ports the remaining compression levers from Voltaire.Changes
Skip JSON pre-compression — drop
.jsonfrom the compress glob. Most are Gatsby'spage-data.json(high count, large total) and zopfli-precompressing them was the bulk ofonPostBuildtime for ~5-10% extra ratio over nginx's live gzip. nginx is already configured withgzip on; gzip_types application/json; gzip_static on;so JSON is live-gzipped at request time — no loss of gzip on JSON responses.assert-compressed.shupdated to match.Default zopfli
numiterations15 → 1 — CI already overrides to 1; this speeds local builds too. The deflate ratio plateaus after the first iteration (<0.5% byte savings vs. 5/15 for 25-45% more time per file).ASSET_COMPRESSION_ITERATIONSstill allows bumping for production.Build job on Docker gen2 — only the
buildjob runs the CPU-boundyarn build. gen2 is ~1.4x faster CPU at +20% credits/min. Falls back toxlargeif gen2 is unavailable.Verification
Local build (
NODE_OPTIONS=--max-old-space-size=12288 yarn build):Compressing 541 files ... 11.617s(no JSON, default 1 iteration)*.json.gzproduced; 541.css/.js/.svg.gzpresent./bin/assert-compressed.shpassesCI: confirm
build+test-nginxgreen on gen2.🤖 Generated with Claude Code
CI impact
First run on this branch vs. last on
main: workflow wall-clock 11 min → 7 min (~36%), driven by thebuildjob halving (593s → 299s).