You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Drop parsed member records after linking, about 1 to 3 MB less heap per VM - #55
Each VM keeps a little less heap. After linking, the runtime JField and JMethod objects hold everything the VM needs from a class's fields and methods, but the parser's member records stayed reachable from the class file object. Linking now drops them. Only the linking loop read them, and every class is parsed fresh and linked once, so nothing reads them later.
Measured here (Pi 5), heap used after a forced collection, two runs each against master:
master
this PR
saved
hello world, restored from the boot snapshot
45.90 MB
44.56 MB
1.34 MB
library VM after one javac compile
121.45 MB
118.46 MB
3.00 MB
Time is unchanged: hello world start 323 / 293 ms (median), library start 313 / 286 ms, one javac compile 5.77 / 5.21 s, pnpm test 308.7 / 310.6 s over three runs each.
pnpm typecheck and pnpm test pass, including the boot and warm snapshot tests.
Noticed, not fixed:
Constant pool entries remain the next big item: one plain object per entry, which shows up as about 4 to 12 MB of generic Object in heap snapshots. Packing them into typed arrays would need care to keep resolution as fast.
Review was skipped as selected files did not have any reviewable changes.
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: 16aee778-d7d6-4719-a1f4-c10439e535ad
Commits
Reviewing files that changed from the base of the PR and between 0f8bf28 and 23e1b38.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Improvements
Class linking now avoids retaining parsed member data after runtime setup is complete. This internal change does not alter the public API or expected application behavior. No user-facing features or behavior changes are included in this update.
JVM.defineLinked now empties the parsed ClassFile’s fields and methods arrays after creating runtime members and populating the class’s method map.
Changes: Class Definition
Layer / File(s)
Summary
Runtime member transfer src/jvm.ts
After creating runtime fields and methods and populating the method map, defineLinked empties the parsed ClassFile’s fields and methods arrays.
The cleanup appears mergeable after normal checks, with no identified behavioral regression.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title names the main change: parsed member records (fields and methods) are dropped after linking, which lowers heap use per VM. The raw summary confirms that defineLinked clears the ClassFile fie…
Description check
The description explains the change. It says linking now drops the parser's member records that stayed reachable from the class file object, and that only the linking loop read them. It also gives hea…
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: parsed member records (fields and methods) are dropped after linking, which lowers heap use per VM. The raw summary confirms that defineLinked clears the ClassFile fields and methods arrays after creating JField and JMethod objects. The title is specific and matches the changeset. It is slightly long at 74 characters, but it is clear.
Full details: Description check
Explanation
The description explains the change. It says linking now drops the parser's member records that stayed reachable from the class file object, and that only the linking loop read them. It also gives heap and timing measurements from before and after the change, notes that typecheck and tests pass, and mentions constant pool entries as a follow-up item. It is directly related to the changeset.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.
Finishing Touches
Generate docstrings
Commit to this branch
Create a new PR
Simplify code
Commit to this branch
Create a new PR
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.
A rabbit saw fields hop away, And methods follow without delay. Runtime members took their place, The parsed arrays cleared the space. The class now rests, neat as can be.
Recent review info
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: e258935b-812e-460e-84b5-0708d64640de
Commits
Reviewing files that changed from the base of the PR and between cac6f05 and 0f8bf28.
Files selected for processing: 1
src/jvm.ts
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
The PR clears the parsed field and method arrays on the class file object after linking, since the runtime JField and JMethod objects now own all needed metadata. This reduces heap usage by 1–3 MB per VM with no performance regression.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
The reason will be displayed to describe this comment to others. Learn more.
The PR discards the temporary parsed member records (fields and methods) from the ClassFile object after linking, reducing heap usage by about 1–3 MB per VM. The runtime JField and JMethod objects now hold all needed metadata, and the change does not affect start‑up or compile times.
review-bot, model cohere/north-mini-code:free, verdict approve
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
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.
Each VM keeps a little less heap. After linking, the runtime
JFieldandJMethodobjects hold everything the VM needs from a class's fields and methods, but the parser's member records stayed reachable from the class file object. Linking now drops them. Only the linking loop read them, and every class is parsed fresh and linked once, so nothing reads them later.Measured here (Pi 5), heap used after a forced collection, two runs each against master:
Time is unchanged: hello world start 323 / 293 ms (median), library start 313 / 286 ms, one javac compile 5.77 / 5.21 s,
pnpm test308.7 / 310.6 s over three runs each.pnpm typecheckandpnpm testpass, including the boot and warm snapshot tests.Noticed, not fixed:
Objectin heap snapshots. Packing them into typed arrays would need care to keep resolution as fast.