Skip to content

perf(build): reuse prepared dashboard gzip set across build-script reruns - #4360

Draft
ScriptedAlchemy with Copilot wants to merge 2 commits into
masterfrom
copilot/perf-build-stop-recompressing-assets
Draft

ScriptedAlchemy with Copilot wants to merge 2 commits into
masterfrom
copilot/perf-build-stop-recompressing-assets

Conversation

Copilot AI commented Oct 19, 2026 •

Copy link
Copy Markdown

Summary

  • Rust-only edits rerun build.rs even when the dashboard bytes are unchanged. Every rerun re-gzipped, round-trip decoded and rewrote every asset, because the cached frontend path still went through from_sources.
  • Compressed payloads are now stored as an immutable set per (bundle digest, compression settings). Warm reruns validate and reuse that set instead of compressing again.

Motivation

The frontend build was already cached, but the dashboard embedding step was not. A "frontend cache hit" still paid for Compression::best, a decode, and unconditional file writes.

Changes

  • Prepared set: dashboard-gz/<digest>-gzip-best-v1/ holds the gzip payloads and a manifest.tsv.
    • The manifest has one line per asset: encoding, sha256 (gzip entries only), relative path.
    • The directory name carries the settings version. Changing the gzip level or format means bumping DASHBOARD_GZ_SETTINGS.
  • Warm path (read_prepared_set):
    • It checks that the manifest matches the asset list exactly and that each gzip payload's sha256 matches.
    • It does no compression, no source reads and no writes.
    • A Rust-only change reuses the set because the directory name depends only on the digest and settings.
    • A changed dashboard asset changes the digest, so it gets a new set.
  • Cold path (publish_prepared_set):
    • It compresses each eligible asset once and round-trip checks it. The round-trip check now runs only here, not on every cache hit.
    • It stages everything under .staging-<digest>-<pid> and publishes with a single directory rename, so no build sees a partial set.
    • If a concurrent build wins the rename, the loser re-validates the existing set and uses it.
  • Corrupt, truncated or foreign set: it is removed and rebuilt. A directory existing is never treated as valid.
  • Unchanged behaviour:
    • Identity is still used for fonts and images, for empty files, and for any file where gzip is larger.
    • MIME type and encoding metadata are the same as before. The MIME mapping is now dashboard_content_type.
    • The generated glue was already written only when its bytes differ.

Test plan

  • The affected Bazel targets pass
  • bazel build //... passes when the change crosses package boundaries
  • Tested manually (describe below if applicable)

Not yet verified. Bazel was unavailable in the authoring environment, so this change has only been rustfmt-checked and has never been compiled or run.

Still to do:

  • Build and tests: build //crates/tracedecay-cli:build_script_build and run the existing bundle digest, cache-tag and packaging tests.
  • Measurements: the issue asks for warm-rerun numbers on the shipping path (compression calls, bytes written, CPU/wall). None are included here.
  • Regression tests: none added. A direct test would be a warm rerun with unchanged dashboard bytes that performs no gzip and writes nothing, plus one corrupted-payload case.
  • Open scope item: the issue's preferred step of moving gzip into the Bazel asset-production action is not done. This change only makes the build-script path reusable.

Checklist

  • CHANGELOG.md updated (under [Unreleased] if no version bump)
  • No secrets, credentials, or .env files included
  • Breaking changes documented (if any)

@changeset-bot

changeset-bot Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: d4c074f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-authored-by: ScriptedAlchemy <25274700+ScriptedAlchemy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build process to avoid recompressing unchanged dashboard assets perf(build): reuse prepared dashboard gzip set across build-script reruns Oct 19, 2026
Copilot AI requested a review from ScriptedAlchemy October 19, 2026 04:05

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(build): stop recompressing unchanged dashboard assets on build-script reruns

2 participants