Skip to content

perf(build): faster builds via JSON compression skip + zopfli/gen2 tuning#3441

Merged
kennethkalmer merged 2 commits into
mainfrom
perf/compress-tuning
Jun 24, 2026
Merged

perf(build): faster builds via JSON compression skip + zopfli/gen2 tuning#3441
kennethkalmer merged 2 commits into
mainfrom
perf/compress-tuning

Conversation

@kennethkalmer

@kennethkalmer kennethkalmer commented Jun 23, 2026

Copy link
Copy Markdown
Member

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

  1. Skip JSON pre-compression — drop .json from the compress glob. Most are Gatsby's page-data.json (high count, large total) and zopfli-precompressing them was the bulk of onPostBuild time for ~5-10% extra ratio over nginx's live gzip. nginx is already configured with gzip 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.sh updated to match.

  2. Default zopfli numiterations 15 → 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 for production.

  3. Build job on Docker gen2 — only the build job runs the CPU-bound yarn build. gen2 is ~1.4x faster CPU at +20% credits/min. Falls back to xlarge if 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)
  • 0 *.json.gz produced; 541 .css/.js/.svg .gz present
  • ./bin/assert-compressed.sh passes

CI: confirm build + test-nginx green 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 the build job halving (593s → 299s).

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3f87fb29-8f4b-4d7d-a011-e48e765102a1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/compress-tuning

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kennethkalmer kennethkalmer marked this pull request as ready for review June 23, 2026 16:19
@kennethkalmer kennethkalmer force-pushed the perf/compress-tuning branch from 2fb1c32 to c929d67 Compare June 23, 2026 18:48
@kennethkalmer kennethkalmer enabled auto-merge June 23, 2026 18:48
kennethkalmer and others added 2 commits June 24, 2026 10:14
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>
@kennethkalmer kennethkalmer force-pushed the perf/compress-tuning branch from c929d67 to be6d373 Compare June 24, 2026 09:14
@kennethkalmer kennethkalmer merged commit 0703027 into main Jun 24, 2026
7 checks passed
@kennethkalmer kennethkalmer deleted the perf/compress-tuning branch June 24, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants