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

8259231: Epsilon: improve performance under contention during virtual space expansion #1794

Closed
wants to merge 5 commits into from

Conversation

lhtin
Copy link
Contributor

@lhtin lhtin commented Dec 16, 2020

Hi all,

The EpsilonHeap::allocate_work method maybe can be fixed and improved by this:

  1. it can prevent allocate failure by retry _space->par_allocate before expanding virtual space, when there not enough virtual space but another thread expanding succeeded just and has enough space.
  2. it can reduce the lock time by move res = _space->par_allocate(size); out of lock scope.

Test on macosx-x86_64-server-{release, fastdebug, slowdebug} with current test case.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8259231: Epsilon: improve performance under contention during virtual space expansion

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/1794/head:pull/1794
$ git checkout pull/1794

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Dec 16, 2020
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 16, 2020

Hi @lhtin, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user lhtin" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

openjdk bot commented Dec 16, 2020

@lhtin 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 Dec 16, 2020
@lhtin
Copy link
Contributor Author

lhtin commented Dec 16, 2020

/covered
Tencent

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label Dec 16, 2020
@bridgekeeper
Copy link

bridgekeeper bot commented Dec 16, 2020

Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Dec 16, 2020
@lhtin
Copy link
Contributor Author

lhtin commented Dec 18, 2020

/test

@openjdk
Copy link

openjdk bot commented Dec 18, 2020

@lhtin you need to get approval to run the tests in tier1 for commits up until 83db636

@openjdk openjdk bot added the test-request label Dec 18, 2020
@lhtin lhtin changed the title Epsilon: improve speed and quality of EpsilonHeap::allocate_work Epsilon: fix the chance to allocate failure and improve the speed and quality of EpsilonHeap::allocate_work Jan 5, 2021
@lhtin
Copy link
Contributor Author

lhtin commented Jan 5, 2021

/issue add JDK-8259231

@openjdk openjdk bot changed the title Epsilon: fix the chance to allocate failure and improve the speed and quality of EpsilonHeap::allocate_work 8259231: Fix the chance to allocate failure and improve the speed and quality of EpsilonHeap::allocate_work Jan 5, 2021
@openjdk
Copy link

openjdk bot commented Jan 5, 2021

@lhtin The primary solved issue for a PR is set through the PR title. Since the current title does not contain an issue reference, it will now be updated.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 5, 2021
@mlbridge
Copy link

mlbridge bot commented Jan 5, 2021

Webrevs

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Good find! Comments below:

@@ -64,7 +64,7 @@
"smaller TLABs until policy catches up.") \
\
product(bool, EpsilonElasticTLABDecay, true, EXPERIMENTAL, \
"Use timed decays to shrik TLAB sizes. This conserves memory " \
"Use timed decays to shrink TLAB sizes. This conserves memory " \
Copy link
Member

Choose a reason for hiding this comment

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

Let's not do the typo fixes in this PR. Maybe there are other spelling problems elsewhere in gc/epsilon that we could fix wholesale in another PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will revert the typo fixes change.

// No space left:
return NULL;
}
{
Copy link
Member

Choose a reason for hiding this comment

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

I see what you are trying to do, and it makes sense. I believe this form would be cleaner:

HeapWord* res = NULL;
while (true) {
  // Try to allocate, assume space is available
  res = par_allocate(size);
  if (res != NULL) {
    break;
  }

  MutexLocker ml(Heap_Lock);

  // Try to allocate under the lock, assume another thread was able to expand
  res = par_allocate(size);
  if (res != NULL) {
    break;
  }

  // Expand and loop back if space is available
  size_t space_left = max_capacity() - capacity();
  size_t want_space = MAX2(size, EpsilonMinHeapExpand);
   ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the new form is cleaner very. And I think it would be a little cleaner if wrap the lock scope in curly braces. like this:

HeapWord* res = NULL;
while (true) {
  // Try to allocate, assume space is available
  res = par_allocate(size);
  if (res != NULL) {
    break;
  }

  {
    MutexLocker ml(Heap_Lock);
  
    // Try to allocate under the lock, assume another thread was able to expand
    res = par_allocate(size);
    if (res != NULL) {
      break;
    }
  
    // Expand and loop back if space is available
    size_t space_left = max_capacity() - capacity();
    size_t want_space = MAX2(size, EpsilonMinHeapExpand);
     ...
  }
}

@openjdk openjdk bot removed the rfr Pull request is ready for review label Jan 6, 2021
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 6, 2021
@lhtin lhtin changed the title 8259231: Fix the chance to allocate failure and improve the speed and quality of EpsilonHeap::allocate_work 8259231: Epsilon: improve performance under contention during virtual space expansion Jan 6, 2021
Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Okay, this is good. Please also run make run-test TEST=gc/epsilon explicitly; it is supposed to run in tier1 already, but better be safe than sorry.

@openjdk
Copy link

openjdk bot commented Jan 6, 2021

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

8259231: Epsilon: improve performance under contention during virtual space expansion

Reviewed-by: shade

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 183 new commits pushed to the master branch:

  • f6cb8c5: 8258908: Remove JVM option CleanChunkPoolAsync
  • c0540ff: 8231627: ThreadsListHandleInErrorHandlingTest.java fails in printing all threads
  • 7e01bc9: 8255264: Support for identifying the full range of IPv4 localhost addresses on Windows
  • 8a05d60: 8259042: Inconsistent use of general primitives loops
  • e3b9da1: 8259287: AbstractCompiler marks const in wrong position for is_c1/is_c2/is_jvmci
  • 32538b5: 8193942: Regression automated test '/open/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java' fails
  • 52d3fee: 8258813: [TESTBUG] Fix incorrect Vector API test output message
  • 8b45497: 8259037: livenmethods cannot find hsdis library
  • 7d76966: 8255757: Javac emits duplicate pool entries on array::clone
  • cf9908b: 8258937: Remove JVM IgnoreRewrites flag
  • ... and 173 more: https://git.openjdk.java.net/jdk/compare/381021aebf0bfd2aeb730cb2e073401a8c2ff358...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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@shipilev) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 6, 2021
@lhtin
Copy link
Contributor Author

lhtin commented Jan 6, 2021

Tests of gc/epsilon have passed on {macosx,linux}-x86_64-server-{release,fastdebug,slowdebug}.

@lhtin
Copy link
Contributor Author

lhtin commented Jan 6, 2021

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jan 6, 2021
@openjdk
Copy link

openjdk bot commented Jan 6, 2021

@lhtin
Your change (at version 4ae547f) is now ready to be sponsored by a Committer.

@shipilev
Copy link
Member

shipilev commented Jan 6, 2021

/sponsor

@openjdk openjdk bot closed this Jan 6, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed sponsor Pull request is ready to be sponsored ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 6, 2021
@openjdk
Copy link

openjdk bot commented Jan 6, 2021

@shipilev @lhtin Since your change was applied there have been 183 commits pushed to the master branch:

  • f6cb8c5: 8258908: Remove JVM option CleanChunkPoolAsync
  • c0540ff: 8231627: ThreadsListHandleInErrorHandlingTest.java fails in printing all threads
  • 7e01bc9: 8255264: Support for identifying the full range of IPv4 localhost addresses on Windows
  • 8a05d60: 8259042: Inconsistent use of general primitives loops
  • e3b9da1: 8259287: AbstractCompiler marks const in wrong position for is_c1/is_c2/is_jvmci
  • 32538b5: 8193942: Regression automated test '/open/test/jdk/javax/swing/JFrame/8175301/ScaledFrameBackgroundTest.java' fails
  • 52d3fee: 8258813: [TESTBUG] Fix incorrect Vector API test output message
  • 8b45497: 8259037: livenmethods cannot find hsdis library
  • 7d76966: 8255757: Javac emits duplicate pool entries on array::clone
  • cf9908b: 8258937: Remove JVM IgnoreRewrites flag
  • ... and 173 more: https://git.openjdk.java.net/jdk/compare/381021aebf0bfd2aeb730cb2e073401a8c2ff358...master

Your commit was automatically rebased without conflicts.

Pushed as commit 722f236.

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

@lhtin
Copy link
Contributor Author

lhtin commented Jan 6, 2021

Thank you @shipilev for reviewing and sponsoring.

@lhtin lhtin deleted the improve-epsilon-gc-allocation branch January 6, 2021 15:49
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 test-request
Development

Successfully merging this pull request may close these issues.

2 participants