Serve precompressed web app assets for slow links#437
Open
ymichael wants to merge 6 commits into
Open
Conversation
Collaborator
|
You might be able to shave off an extra 100k by using brotli |
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.
Summary
This PR improves slow/high-latency web startup by serving the existing production app assets precompressed, without changing the initial JS/CSS request graph.
.brand.gzsidecars during@bb/appproduction builds./assets/*withbrpreferred overgzipwhen the browser advertises support./assets/*cache headers andno-storeHTML fallback behavior.The earlier code-splitting experiment is intentionally not included. It increased startup request count and did not materially reduce the delivered startup payload.
Measurement scripts used during investigation were removed from this PR; the branch now keeps only the product change and server regression coverage.
Cost / Tradeoffs
11.65swall,11.02suser,0.43ssys for 394 assets. Full forced@bb/appTurbo build with precompression:34.108s.17.92 MiB/ 467 files. Sidecars add7.57 MiB/ 788 files:3.45 MiBBrotli +4.12 MiBgzip. Total dist becomes25.48 MiB..br/.gzfile and streams it. No per-request compression work for precompressed assets.Content-EncodingandVary: Accept-Encodingare added when a sidecar is served.Browser Throttling Used
Yes. Before/after measurements used a local Chrome/Playwright-style browser run with Chrome DevTools Protocol network emulation:
Network.setCacheDisabled({ cacheDisabled: true })Network.emulateNetworkConditions({ latency: 600ms, downloadThroughput: 80 KiB/s, uploadThroughput: 30 KiB/s })120s; settle after DOMContentLoaded:500msFor the before/after comparison, I used the same built JS/CSS graph and measured:
.br/.gzsidecars removed, simulating previous identity static serving..br/.gzsidecars present, simulating this PR's static serving.Measurements
Static graph accounting:
diff-worker-pool: 2.07 MiB raw / 645.0 KiB gzip / 509.2 KiB brbraccepteddiff-worker-pool: 2.07 MiB raw / 645.0 KiB gzip / 509.2 KiB brReal browser/CDP airplane profile:
identity: 22br: 21,identity: 1Largest startup resources in the browser run:
diff-worker-pool-CzIm9giF.jsindex-B9ZDeg52.jspage-shell-v8a65niI.jsindex-CzQEJdK0.cssresponsive-overlay-D_kX1YMN.jsdropdown-menu-BHhHHxNb.jshost-display-Bq0L7hZQ.jsthread-queries-DOOopSrx.jsCode-Splitting Prototype Findings
I prototyped deferring the root compose secondary-panel/file-preview/diff-worker path.
What it tried:
Why the initial attempt was ineffective/counterproductive:
diff-worker-poolimport disappeared, but the large shared graph was repeatedly hoisted into other initial chunks (threadWorkspaceOpenPath,useThreadSecondaryPanelVisibility,threadSecondaryPanelSelection,ThreadTerminalPanel,useThreadFileTabs, thensecondaryPanelTabState).Why this is hard here:
Recommendation: do not include the code-splitting prototype in PR #437. Keep this PR scoped to precompressed static serving. Revisit JS graph reduction separately with a hard requirement that request count does not increase materially and that full-composer readiness improves, not only fallback shell paint.
Verification
Final branch is mergeable:
gh pr view 437 --json mergeStateStatusreportsCLEAN.Commands run after removing the measurement scripts:
git diff --checkpnpm exec turbo run typecheck --filter=@bb/app --filter=@bb/server --forcepnpm exec turbo run test --filter=@bb/server --force -- test/app/static-cache.test.tsEarlier final-branch verification before script removal, still applicable to the product/server changes:
pnpm exec turbo run build --filter=@bb/app --forcepnpm exec turbo run build --filter=@bb/server --forcepnpm exec turbo run test --filter=@bb/app --filter=@bb/server --forceResults:
@bb/apptests passed: 165 files / 1110 tests.@bb/servertests passed: 100 files / 809 tests.