Repository navigation
Fetch an app class in one request and prefix-code the boot index - #30
Conversation
|
Warning Review limit reachedYou'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. View limit details
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. |
There was a problem hiding this comment.
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
Two changes that cut what a page downloads before its first run.
One request per app class.
HttpBackend.statsent a HEAD for every app.classfile, then the class loader read it with a GET. For.classpaths,statnow 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 noContent-Length. Missing classes still cost one request, and directory checks still use HEAD.Prefix-coded boot index.
boot.packheld 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.packfiles 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 olderboot.packkeeps working.Measured in headless Chromium, cold page loads, with an uncompressed static server (median of 3, fresh profile each run):
cheerpjInitincludedRun 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:
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 typecheckandpnpm testpass.Noticed, not fixed:
System.loadLibrarystill sends HEAD then GET fornative.js.