Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Aborted Scavenge #20515

Open
amicic opened this issue Nov 5, 2024 · 1 comment
Open

Optimize Aborted Scavenge #20515

amicic opened this issue Nov 5, 2024 · 1 comment

Comments

@amicic
Copy link
Contributor

amicic commented Nov 5, 2024

When aborted Scavenge occurs (in a middle of Scavnge, no free space left in either Nursery or Tenure to move objects to) we handle it differently for:

  1. STW Scavenge, backout the work that Scavenge performed in this cycle (move the objects and references to their original position and values), and after that perform an ordinary Global GC to free up memory in Nursery by sweep and proceed with allocation (more aggressive Global GCs may be triggered if needed)

  2. CS Scavenge, we stop, leave the objects where they are, and perform Global GC that is aware of forwarding pointers. It fixes up all the references that have not been updated. While sweep will also free up some memory in Nursery, it will be more fragmented (since both Evacuate and Survivor side of Nursery will have live objects scattered), a single threaded compaction is performed to increase the likelihood of allocation success.

The latter approach could work for both CS and STW (and the former does not work for CS), so we could simplify the code and only use the latter one.

Another motivation for not doing backout approach, is that we could remove the second pass of RS scanning (aka pruning pass), hence slightly reduce Scavenge time (a rough estimate, by 5%).

However doing a single thread compaction is very expensive and should be avoided and optimized if/when possible:

  • we can try Global GC without compact, and only if that allocation fails, we trigger compaction (or simply another Global GC with compaction)
  • we try single thread Compact only if parallel Compact does not satisfy allocation
  • we can Compact only Nursery (if the original Scavenge was triggered by Nursery allocation) - we can do this because we have correct RS after Global GC. We would fixup RS, but not need to Compact Tenure, which typically has far more objects.
@amicic amicic added the comp:gc label Nov 5, 2024
Copy link

github-actions bot commented Nov 5, 2024

Issue Number: 20515
Status: Open
Recommended Components: comp:gc, comp:vm, comp:test
Recommended Assignees: amicic, tajila, babsingh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant