Skip to content

Fetch an app class in one request and prefix-code the boot index - #30

Merged
Project516 merged 1 commit into
masterfrom
p516/browser-requests
Nov 4, 2026
Merged

Project516 merged 1 commit into
masterfrom
p516/browser-requests

Conversation

@Project516

Copy link
Copy Markdown
Owner

Two changes that cut what a page downloads before its first run.

One request per app class. HttpBackend.stat sent a HEAD for every app .class file, then the class loader read it with a GET. For .class paths, stat now reads the file and takes its size from the bytes. The following read is served from the cache. This also gives the right size when the server compresses the response or sends no Content-Length. Missing classes still cost one request, and directory checks still use HEAD.

Prefix-coded boot index. boot.pack held a 2.0 MB text index of 20,008 files. Sorted paths share long prefixes, so each line now stores the number of characters shared with the line before it, then the rest (/index.prefix). The index drops to 0.98 MB. That saves about 1 MB of download from hosts that serve .pack files uncompressed, and about 1 MB of memory in the parsed pack. Compressed sizes barely change (gzip 314 KB to 275 KB, brotli 218 KB either way). The reader still accepts /index.txt, so a page that gets a cached older boot.pack keeps working.

Measured in headless Chromium, cold page loads, with an uncompressed static server (median of 3, fresh profile each run):

Step Before After
First library call, cheerpjInit included 4,143 ms 2,363 ms
Bytes transferred by then 7.85 MB 6.83 MB
Self-test, library mode 3,422 ms 1,906 ms
Self-test, Web Worker 2,381 ms 2,049 ms
Self-test, javac compile 9,246 ms 8,856 ms

Run to run times varied a lot on this machine, so treat the time columns as rough. The request trace for an app class went from HEAD plus GET to one GET.

Checks:

  • New tests: one GET per class with and without Content-Length, missing classes, a directory check still using HEAD, and a prefix-coded index giving the same paths, sizes, offsets and lazy packs.
  • pnpm typecheck and pnpm test pass.
  • The browser self-test passes every step on fresh and reused profiles.

Noticed, not fixed:

  • System.loadLibrary still sends HEAD then GET for native.js.
  • Module images are read in many small Range requests during the first run. Larger or merged ranges may help.

@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 15 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: eeb20aba-0a69-46a0-98d3-91be8fcc94cf
Commits

Reviewing files that changed from the base of the PR and between 06cb8a3 and 759ae49.

Files selected for processing: 4
  • scripts/build-web.ts
  • src/browser/http.ts
  • test/http-files.test.ts
  • test/image.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR makes two optimizations: (1) for .class files, stat() now does a single GET (caching the content) instead of HEAD+GET, and (2) the boot pack index is prefix-coded (/index.prefix) reducing its size from 2.0 MB to 0.98 MB. The reader falls back to /index.txt for backward compatibility. Tests cover the new behaviors and pass.


review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve

Comment thread src/browser/http.ts Resolved
@Project516
Project516 enabled auto-merge (squash) November 4, 2026 00:18
@Project516
Project516 merged commit 53a8e3b into master Nov 4, 2026
12 checks passed
@Project516
Project516 deleted the p516/browser-requests branch November 4, 2026 00:37
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.

1 participant

⌂ Proxy