RFR: 8310031: Parallel: Implement better work distribution for large object arrays in old gen [v24]
Thomas Schatzl
tschatzl at openjdk.org
Thu Oct 19 18:49:37 UTC 2023
On Thu, 19 Oct 2023 16:01:20 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> src/hotspot/share/gc/parallel/psCardTable.hpp line 49:
>>
>>> 47: // Old gen top is not card aligned.
>>> 48: size_t copy_length = align_up(stripe.byte_size(), _card_size) >> _card_shift;
>>> 49: size_t clear_length = align_down(stripe.byte_size(), _card_size) >> _card_shift;
>>
>> Can you explain why `align_down` is needed here? I remember some reason why this needs to be the case at least for the old code, and @albertnetymk also explained it to me recently, but just now I can't figure it out (and it may not be required any more). Please add a comment, this is not obvious.
>
> Since old-gen-top before scavenging might not be card-aligned, it's unsafe to clear it; hence the conservative (align-down) calculation. However, the right shift will do implicit align-down as well, so it is probably not needed. Better be explicit, I was thinking. Either is fine, I guess.
The highest value `byte_size()` can have is old_gen-end - old_gen_bottom (both card-aligned; one stripe, one slice), which is the exact length needed when covering all cards.
Any top value != end must have a committed corresponding card table entry, otherwise marking the card that contains `top` would crash. Also the copying would fail then, reading from uncommitted areas beyond the card table. The code does not do that afaics.
So the only problematic one I can see would be clearing the card exactly starting at old_gen-end, which an `align_up()` wouldn't do either.
So I do not completely get why clearing the card containing top would be unsafe. Can you give an example?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14846#discussion_r1365962741
More information about the hotspot-gc-dev
mailing list