Skip to content

Conversation

@albertnetymk
Copy link
Member

@albertnetymk albertnetymk commented Oct 23, 2023

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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8318647: Serial: Refactor BlockOffsetTable (Enhancement - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/16304/head:pull/16304
$ git checkout pull/16304

Update a local copy of the PR:
$ git checkout pull/16304
$ git pull https://git.openjdk.org/jdk.git pull/16304/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16304

View PR using the GUI difftool:
$ git pr show -t 16304

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16304.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 23, 2023

👋 Welcome back ayang! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title 8318647 8318647: Serial: Refactor BlockOffsetTable Oct 23, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 23, 2023
@openjdk
Copy link

openjdk bot commented Oct 23, 2023

@albertnetymk The following label will be automatically applied to this pull request:

  • hotspot-gc

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.

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Oct 23, 2023
@mlbridge
Copy link

mlbridge bot commented Oct 23, 2023

Webrevs

Copy link
Contributor

@tschatzl tschatzl left a 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> {
Copy link
Contributor

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.

Copy link
Member Author

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.

Comment on lines 39 to 43
// 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.
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

@tschatzl tschatzl Oct 25, 2023

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.

Copy link
Member Author

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> {
Copy link
Contributor

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).

Copy link
Member Author

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
Copy link
Contributor

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;
};


Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Write the backskip value for each region.
// Write the backskip value for the given region.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
Copy link
Contributor

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?

Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Member Author

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.

Comment on lines 137 to 143
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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).

Copy link
Contributor

@tschatzl tschatzl left a 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 {
Copy link
Contributor

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.

@openjdk
Copy link

openjdk bot commented Oct 30, 2023

@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:

8318647: Serial: Refactor BlockOffsetTable

Reviewed-by: tschatzl, iwalulya

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 master branch:

  • b4f5379: 8304939: os::win32::exit_process_or_thread should be marked noreturn
  • 0461d9a: 8318016: Per-compilation memory ceiling
  • 2a76ad9: 8318683: compiler/c2/irTests/TestPhiDuplicatedConversion.java "Failed IR Rules (2) of Methods (2)"
  • b3fec6b: 8306980: Generated docs should contain correct Legal Documents
  • 1139482: 8316132: CDSProtectionDomain::get_shared_protection_domain should check for exception
  • 2182c93: 8313643: Update HarfBuzz to 8.2.2
  • 613a3cc: 8301846: Invalid TargetDataLine after screen lock when using JFileChooser or COM library
  • 613d32c: 8169475: WheelModifier.java fails by timeout
  • f1e8787: 8317609: Classfile API fails to verify /jdk.jcmd/sun/tools/jstat/Alignment.class
  • 47624f6: 8299058: AssertionError in sun.net.httpserver.ServerImpl when connection is idle
  • ... and 23 more: https://git.openjdk.org/jdk/compare/3934127b087ade1c1286008df3497ca6d84778a5...master

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 master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 30, 2023
@albertnetymk
Copy link
Member Author

Renamed class and u_char. Split into their own commits for easier reviewing.

Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@albertnetymk
Copy link
Member Author

Thanks for the review.

/integrate

@openjdk
Copy link

openjdk bot commented Nov 1, 2023

Going to push as commit ab19348.
Since your change was applied there have been 33 commits pushed to the master branch:

  • b4f5379: 8304939: os::win32::exit_process_or_thread should be marked noreturn
  • 0461d9a: 8318016: Per-compilation memory ceiling
  • 2a76ad9: 8318683: compiler/c2/irTests/TestPhiDuplicatedConversion.java "Failed IR Rules (2) of Methods (2)"
  • b3fec6b: 8306980: Generated docs should contain correct Legal Documents
  • 1139482: 8316132: CDSProtectionDomain::get_shared_protection_domain should check for exception
  • 2182c93: 8313643: Update HarfBuzz to 8.2.2
  • 613a3cc: 8301846: Invalid TargetDataLine after screen lock when using JFileChooser or COM library
  • 613d32c: 8169475: WheelModifier.java fails by timeout
  • f1e8787: 8317609: Classfile API fails to verify /jdk.jcmd/sun/tools/jstat/Alignment.class
  • 47624f6: 8299058: AssertionError in sun.net.httpserver.ServerImpl when connection is idle
  • ... and 23 more: https://git.openjdk.org/jdk/compare/3934127b087ade1c1286008df3497ca6d84778a5...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 1, 2023
@openjdk openjdk bot closed this Nov 1, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 1, 2023
@openjdk
Copy link

openjdk bot commented Nov 1, 2023

@albertnetymk Pushed as commit ab19348.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@albertnetymk albertnetymk deleted the s1-bot branch November 1, 2023 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants