Skip to content
This repository has been archived by the owner. It is now read-only.

8268265: MutableSpaceUsedHelper::take_sample() hits assert(left >= right) failed: avoid overflow #65

Closed
wants to merge 3 commits into from

Conversation

kimbarrett
Copy link
Contributor

@kimbarrett kimbarrett commented Jun 15, 2021

Please review this change to PerfData-based heap usage reporting by SerialGC
and ParallelGC.

For both of these collectors, the periodic heap usage sampling and reporting
by the Watcher thread involves sampling the difference between each space's
current allocation pointer and its base pointer. But the Watcher thread
runs during GC safepoints, which means that sampling may occasionally occur
while the GC is in the process of updating the space being sampled. This
can result in a sample with a bogus value or even an assertion failure after
JDK-8260046.

Other collectors seem to avoid this by sampling and recording the heap usage
value at specific synchronous times rather than asynchronously by the
Watcher thread.

There isn't a particularly good place for synchronous updates for ParallelGC
and SerialGC, so this change doesn't do so. Instead, it makes the existing
asynchronous updates safe from interference by an in-progress GC. This is
done by having the update done under the Heap_lock. Introducing a more
fine-grained lock has the same problem as doing synchronous updates. Rather
than possibly blocking the sampling Watcher thread for the duration of a GC,
it tries to lock the Heap_lock and skips sampling if it's not available.

Testing:
mach5 tier1-3, 5, 7 (3,5,7 are where focused Serial and ParallelGC testing is done).


Progress

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

Issue

  • JDK-8268265: MutableSpaceUsedHelper::take_sample() hits assert(left >= right) failed: avoid overflow

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/65/head:pull/65
$ git checkout pull/65

Update a local copy of the PR:
$ git checkout pull/65
$ git pull https://git.openjdk.java.net/jdk17 pull/65/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 65

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/65.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jun 15, 2021

👋 Welcome back kbarrett! 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 added the rfr label Jun 15, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 15, 2021

@kimbarrett 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 label Jun 15, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jun 15, 2021

Webrevs

Copy link
Contributor

@tschatzl tschatzl left a comment

Lgtm.

@openjdk
Copy link

@openjdk openjdk bot commented Jun 16, 2021

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

8268265: MutableSpaceUsedHelper::take_sample() hits assert(left >= right) failed: avoid overflow

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 label Jun 16, 2021
Copy link
Member

@walulyai walulyai left a comment

lgtm!

@kimbarrett
Copy link
Contributor Author

@kimbarrett kimbarrett commented Jun 17, 2021

Thansk @tschatzl and @walulyai for reviews.

@kimbarrett
Copy link
Contributor Author

@kimbarrett kimbarrett commented Jun 17, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jun 17, 2021

Going to push as commit c98d508.

@openjdk openjdk bot closed this Jun 17, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jun 17, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jun 17, 2021

@kimbarrett Pushed as commit c98d508.

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

@kimbarrett kimbarrett deleted the lock_heap branch Jun 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hotspot-gc integrated
3 participants