perf(bun): compress embedded assets with byte-exact registration - #10053
proggeramlug wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughBun embedded assets now use checksummed zstd compression when size thresholds are met. Generated code registers compressed payloads through a new runtime API, which validates and decodes them into persistent storage. Tests cover compiler output, runtime validation, loaders, and retained asset data. ChangesBun embedded asset compression
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant Compiler
participant GeneratedBunBinary
participant PerryRuntime
participant EmbeddedAssetRegistry
Compiler->>Compiler: compress eligible embedded assets
Compiler->>GeneratedBunBinary: emit zstd payload and registration call
GeneratedBunBinary->>PerryRuntime: register compressed asset
PerryRuntime->>PerryRuntime: validate and decode zstd frame
PerryRuntime->>EmbeddedAssetRegistry: publish decoded bytes and metadata
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The scoped native-test setup validates the repository-pinned Node version and correctly includes the embedded-compression suite's required runtime preparation. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 72.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 7 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
Scope
Independent Bun-platform embedded-asset compression. Based on main
603b074ac;does not depend on the child-output, own-bind, or generator PRs, and no extracted
application, credentials, account, or Bun installation is needed for its tests.
require at least 256 KiB of aggregate payload savings. Otherwise retain raw
embedding. Existing non-Bun behavior is unchanged.
bun-cli-utilsdependency/feature selection. No dependency,default feature, environment knob, or existing exported ABI is changed.
trailing/concatenated data, preserves explicit file/text loader metadata,
and publishes only decoded bytes. Constructor failure is fatal.
is required. This trades compressed image bytes for native heap storage at
startup, and is not a peak-memory reduction claim.
Validation
At exact head
d8c817ef1f69bf7121bd9fb880eb7908ecb57743, the full normal-debugruntime suite passed 3,529 tests, no failures, four ignored, on one thread.
This includes all five new compression tests: empty/Unicode/NUL/binary bytes,
malformed/truncated/trailing/concatenated frames, checksummed payload damage,
metadata mismatch, retained ownership and no publication on failure. All three
compiler packaging tests passed, including incompressible/raw controls.
All 13 compiler embedding tests pass (including those three new tests).
Formatting, whitespace, file caps and JavaScript syntax checks pass.
The full script tier reports 75 passes, one failure, two CI-only skips;
compile-tier lint is explicitly skipped locally. The sole failure is public
benchmark artifact freshness, also present in the exact base-main
603b074acpush run 34565492075.Current-head Linux runtime CI also passes all five new tests: 3,509 passed,
one failed, four ignored. Its sole failure is the identical main stack-size
assertion at
native_stack.rs:53/:60(bound must belong to this worker).Current zizmor reports only the unchanged
gate-failure-watch.ymltrigger;the triggering workflow, zizmor workflow and configuration are unchanged.
The frozen before-fix compiler
81b47b47ccompiles the new native fixture,then fails its compression-liveness assertion (zero registrations,
three required), rather than failing setup. Native execution is not reached
in that negative control.
The final clean-commit compiler and all nine matching provider archives have
been built and frozen at
d8c817ef1. Compiler/default graph: 3m31s;provider/Wasm graph: 5m14s. An earlier combined invocation incorrectly enabled
Wasm host externs inside the compiler and was rejected at linking; the restored
two-stage build passes without source changes or archive/stamp substitutions.
The standalone native matrix passes under both default and compact GC, with
Wasm enabled. It proves three assets actually take the compressed path, moves
the source directory away, and checks exact filesystem bytes, Bun.file,
explicit text-loader require, raw/empty controls and retained values after GC
against pinned Node. Neither test needs extracted application files.
Additional local real-emitter measurement packages 1,825 recorded asset payloads
in a small independent program: the asset object decreases from 42,629,960
to 17,379,160 bytes, a 25,250,800-byte reduction. All 1,825 actual emitted
payload hashes match the originals (934 compressed, 891 raw); both native
programs read every embedded file with the source directory hidden. This
compares same-compiler Node/raw vs Bun/compressed asset objects; whole-program
platform linkage differs, so its executable difference is not attributed solely
to compression. No full application rebuild or application-size claim is made.
Linux check and warnings pass at
d8c817ef1. Its scoped native job exposed anown CI setup error: it inherited Node 22.23.2, failing the required
26.5.1 assertion before any native compilation. This was not attributed to
main or hidden by relaxing the oracle. Follow-up head
7793a66e3e999e3404f01377978b29bdff35288cinstalls Node from.node-versionand verifies the version before costly native builds. The actual workflow
preflight passes with the correct pin and fails with a deliberately wrong pin;
its setup/verification/build order and conditional guards are checked.
That follow-up changes only CI and the changeset;
git diff d8c817ef1 -- crates scriptsis empty. The frozen native results above remain atd8c817ef1, not aclaim of a fresh compiler build at the CI-only head. Final script lint again
reports 75 passes, the same inherited benchmark freshness failure, two
CI-only skips, with compile tier explicitly skipped. At exact head
7793a66e,Linux scoped native CI
now passes:
standalone_compressed_asset_regressionactually executed andpassed in 127.61 seconds, after the pinned-Node verification. Check/warnings
also pass. The runtime job remains red only on the same main stack-size
assertion (3,509 passed, one failed, four ignored).
All jobs in that run have now finished. Shards 4 and 6 pass; all ten printed
failure/crash diagnostics in shards 1/2/3/5 exactly match main
603b074acrun
34565492075, including the WebCrypto 10-second timeout. The comparisoncovers reported exit codes and printed output excerpts, not full stdout.
GC stress has byte-exact Node parity in 588/588 cells: 429 PASS, 159
UNVERIFIED, 0 FAIL. The inert 159 arms are not moving-GC evidence. The
fan-in is red on the documented baseline failures; this is not an all-green
CI claim or a claim that compression was exercised by the gap/GC suites.
Its live compression proof is the scoped native test explicitly named above.
No claim that the full application works or reaches 300 MB. Ready for
maintainer review; the merge train can perform the patch-version bump.