8371327: G1: Replace FromCardCache with thread-local per-card cache - #32479
8371327: G1: Replace FromCardCache with thread-local per-card cache#32479walulyai wants to merge 13 commits into
Conversation
|
👋 Welcome back iwalulya! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
Webrevs
|
| if (_cm->do_yield_check()) { | ||
| _rebuild_closure.reset_from_card_cache(); | ||
| if (!should_rebuild_or_scrub(hr)) { |
There was a problem hiding this comment.
Just a suggestion, maybe encapsulate the yield check with the reset, i.e. something like:
bool my_yield_check() {
bool yielded = _cm->do_yield_check();
if (yielded) {
_rebuild_closure.reset_from_card_cache();
}
return yielded;
}
Maybe not though.
| verify_card_pair_refers_to_same_card(source_card, dest_card); | ||
|
|
||
| G1RemSet::RefineResult res = _rem_set->refine_card_concurrently(source_card, _worker_id); | ||
| G1RemSet::RefineResult res = _rem_set->refine_card_concurrently(source_card, _conc_refine_cl); |
There was a problem hiding this comment.
Did you consider putting the _conc_refine_cl construction into refine_card_concurrently()? Its lifecycle is exactly the same as that method after all.
There was a problem hiding this comment.
Yes, started out with G1ConcurrentRefineOopClosure conc_refine_cl local to the refine_card_concurrently, but maybe hoisting it was "premature" optimization.
| // This card index indicates "no card for that entry" yet. This allows us to use the OS | ||
| // lazy backing of memory with zero-filled pages to avoid initial actual memory use. | ||
| // This means that the heap must not contain card zero. | ||
| static const uintptr_t InvalidCard = 0; |
There was a problem hiding this comment.
I would prefer if that constant were explicitly retained for clarity. Its comment explains why its use is safe...
|
|
||
| assert(_num_cardsets < MaxNumCardsets, "source card has too many destination cardsets"); | ||
|
|
||
| if (_num_cardsets < MaxNumCardsets) { |
There was a problem hiding this comment.
I think this check is redundant and/or harmful. First, there is that assert above, and loosing a card just makes the program crash.
I would make sure that MaxCardSizeInBytes is consistent with the flag, and only add the assert.
Applied from openjdk/jdk PR openjdk#32479 by Ivan Walulya. After JEP 522, additions to G1CardSets happen during linear heap scans, so there is no need to cache state for previously processed cards. Replace the global O(regions x workers) direct-indexed FromCardCache with a per-closure cache holding the current source card and the cardset ids already visited for it, keyed on the cset candidate group id.
Hi,
Please review this change that replaces the global direct-indexed
G1FromCardCachewith a per-worker local cache.After JEP 522, additions to
G1CardSetsare performed during linear heap scans: Concurrent refinement sweeps and Concurrent remset rebuild. The linear traversal does not need to cache state for previously processed cards. We can maintain only the cache state for the current card, then discard the state when traversal advances.The new cache maintains the current source card and an array of cardsets already visited for that card. This reduces the memory overhead of the FromCardCache from
O(number of regions × number of workers)toO(maximum references per card × number of active workers).The old cache provided constant-time lookups, while the new cache linearly searches the array of cardsets. These arrays are normally short (the benchmarks show approximately 1.3 comparisons per lookup) and in the worst case bounded by the maximum references per card.
Testing:
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32479/head:pull/32479$ git checkout pull/32479Update a local copy of the PR:
$ git checkout pull/32479$ git pull https://git.openjdk.org/jdk.git pull/32479/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 32479View PR using the GUI difftool:
$ git pr show -t 32479Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32479.diff
Using Webrev
Link to Webrev Comment