Repository navigation
List pack index directories from a map built once, which makes javac's first compile about a quarter faster - #34
Conversation
… scanning every path
# Conflicts: # src/browser/http.ts
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
There was a problem hiding this comment.
The PR optimizes three hot paths: (1) PackIndex.children() builds a directory-to-names map once and caches it until the index grows, replacing per-listing scans of all paths. (2) JVM.slotOf uses nested maps (owner -> name -> slot) instead of concatenating a key string on every call. (3) fillStat writes time fields using literal names instead of building them in a loop. A shared TextDecoder is also reused in parsePack. All changes are localized and tests pass.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
javac's first compile spent a fifth of its time listing directories. Its file manager opens the platform classes through the
jrt:file system. Over the exploded image,jdk.internal.jrtfs.ExplodedImagewalks every module directory: about 900 directories and 21,000 files. Each listing went throughlistIndex, which scanned every path in the pack index to find one directory's children.PackIndex.children()builds a directory-to-names map in one pass and reuses it until the index grows. Entries are only ever added, when a module's lines are parsed, so a change in size is the signal to rebuild. Names keep index order, as before.JVM.slotOf, which natives use to read and write fields by name, looked up a key built asowner + "." + nameon every call. It now looks up the owner, then the name, in nested maps. Both are literal strings with cached hashes, so no key string is built.fillStatnames its time fields as literals for the same reason.TextDecoder(from the review of Parse the boot index of each module the first time a path in it is read #31).Measured with
com.sun.tools.javac.Main -d out Hi.javaondist/node.js, starting from a boot snapshot, on a small ARM board:listIndexself time in that runcompilestepThe field lookup change alone is about 1% of the javac run (7.94 s to 7.87 s, median of 4); the rest is the directory map. The "before" column was measured before #31 too, so it includes that change's smaller gain.
Checks:
pnpm typecheckpasses, andpnpm testpasses (139 tests) on master with Parse the boot index of each module the first time a path in it is read #31, Run the OpenJDK tests in CI from the built bundle #32 and Run the java-web command through a launcher that turns on Node's compile cache #33.Noticed, not fixed:
lstatthrough the NIO natives. It is the JDK's ownExplodedImagecode, which HotSpot runs the same way on an exploded image.