-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8318647: Serial: Refactor BlockOffsetTable #16304
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
Conversation
|
👋 Welcome back ayang! A progress list of the required criteria for merging this PR into |
|
@albertnetymk The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
tschatzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial batch of comments.
| ////////////////////////////////////////////////////////////////////////// | ||
| // BlockOffsetSharedArray | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| class BlockOffsetSharedArray: public CHeapObj<mtGC> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BlockOffsetSharedArray could probably be moved to the .cpp file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resize is called by TenuredGeneration for heap-resizing.
| // The CollectedHeap type requires subtypes to implement a method | ||
| // "block_start". For some subtypes, notably generational | ||
| // systems using card-table-based write barriers, the efficiency of this | ||
| // operation may be important. Implementations of the "BlockOffsetArray" | ||
| // operation may be important. Implementations of the BlockOffsetTable | ||
| // class may be useful in providing such efficient implementations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is completely outdated, talking about subtypes where there are none any more of this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the subtypes refer to heaps from different collectors. Not sth around BlockOffsetArray.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still it isn't worth (and somewhat confusing) imo to talk about subtypes when there are none, particularly because the change deleted the comment about subtypes below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removed.
| ////////////////////////////////////////////////////////////////////////// | ||
| // BlockOffsetSharedArray | ||
| ////////////////////////////////////////////////////////////////////////// | ||
| class BlockOffsetSharedArray: public CHeapObj<mtGC> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be prefixed by Serial, same as BlockOffsetTable (since this is a complete reimplementation anyway).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this renaming can be done in its own (trivial) PR for easier reviewing.
| static bool is_crossing_card_boundary(HeapWord* const obj_start, | ||
| HeapWord* const obj_end) { | ||
| HeapWord* cur_card_boundary = align_up_by_card_size(obj_start); | ||
| // strictly greater-than |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should not only mention what the code below does but also why.
| virtual size_t last_active_index() const; | ||
| }; | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra newline
| void BlockOffsetTable::update_for_block_work(HeapWord* blk_start, | ||
| HeapWord* blk_end) { | ||
| HeapWord* const cur_card_boundary = align_up_by_card_size(blk_start); | ||
| size_t const offset_card = _array->index_for(cur_card_boundary); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| size_t const offset_card = _array->index_for(cur_card_boundary); | |
| size_t const offset_card = _array->index_for(cur_card_boundary); |
| offset = BOTConstants::card_size_in_words() + i; | ||
| if (reach >= end_card) { | ||
| _array->set_offset_array(start_card_for_region, end_card, offset, reducing); | ||
| // Write the backskip value for each region. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Write the backskip value for each region. | |
| // Write the backskip value for the given region. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that region isn't defined very exactly. Here it is (apparently) the memory from blk_start to blk_end, but later it is also used as "area containing the same backskip value". Maybe there is some better wording to be found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"region" in this file always means "logarithmic region". If we refer to [blk_start, blk_end], "block" should be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed just now. It would be nice to define that somewhere. 👍
| for (uint i = 0; i < BOTConstants::N_powers; i++) { | ||
| // -1 so that the reach ends in this region and not at the start | ||
| // of the next. | ||
| size_t reach = offset_card + BOTConstants::power_to_cards_back(i+1) - 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| size_t reach = offset_card + BOTConstants::power_to_cards_back(i+1) - 1; | |
| size_t reach = offset_card + BOTConstants::power_to_cards_back(i + 1) - 1; |
|
|
||
| if (offset_card != end_card) { | ||
| // Handling remaining cards. | ||
| size_t start_card_for_region = offset_card + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe start_card_for/to_update is a better name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obsolete given a definition of a "region".
| // Array for keeping offsets for retrieving object start fast given an | ||
| // address. | ||
| VirtualSpace _vs; | ||
| u_char* _offset_array; // byte array keeping backwards offsets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I always wondered whether u_char is what we want here, maybe uint8_t is more appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can probably be done in its own PR.
| if (reach >= end_card) { | ||
| _array->set_offset_array(start_card_for_region, end_card, value); | ||
| start_card_for_region = reach + 1; | ||
| break; | ||
| } | ||
| _array->set_offset_array(start_card_for_region, reach, value); | ||
| start_card_for_region = reach + 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (reach >= end_card) { | |
| _array->set_offset_array(start_card_for_region, end_card, value); | |
| start_card_for_region = reach + 1; | |
| break; | |
| } | |
| _array->set_offset_array(start_card_for_region, reach, value); | |
| start_card_for_region = reach + 1; | |
| _array->set_offset_array(start_card_for_region, MIN2(end_card, reach), value); | |
| start_card_for_region = reach + 1; | |
| if (reach >= end_card) { | |
| // Set all the cards covered by this region. | |
| break; | |
| } |
I would probably try to merge these two paths as much as possible as suggested above (untested).
tschatzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have renamed the classes as suggested as well when renaming the files; there does not seem to be much meaning to just renaming the files to me.
However assuming you will finish the renaming in an upcoming change anyway, I'll approve this.
| // "N" = 2^"LogN". An array with an entry for each such subregion indicates | ||
| // how far back one must go to find the start of the chunk that includes the | ||
| // first word of the subregion. | ||
| class BlockOffsetTable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file has been renamed which is great, but the class is still called BlockOffsetTable without the prefix.
|
@albertnetymk This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 33 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
Renamed class and |
tschatzl
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you.
|
Thanks for the review. /integrate |
|
Going to push as commit ab19348.
Your commit was automatically rebased without conflicts. |
|
@albertnetymk Pushed as commit ab19348. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The diff is too large; maybe it's better to read the new impl directly, which I believe is much easier to follow.
There is some duplication with G1's implementation, which should probably be dealt with in its own PR.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16304/head:pull/16304$ git checkout pull/16304Update a local copy of the PR:
$ git checkout pull/16304$ git pull https://git.openjdk.org/jdk.git pull/16304/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 16304View PR using the GUI difftool:
$ git pr show -t 16304Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16304.diff
Webrev
Link to Webrev Comment