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

8264223: CodeHeap::verify fails extra_hops assertion in fastdebug test #3212

Closed
wants to merge 3 commits into from

Conversation

@huishi-hs
Copy link

@huishi-hs huishi-hs commented Mar 26, 2021

When test with -XX:+VerifyCodeCache, many tests fail due to extra_hops assertion in CodeHeap::verify. See full dump in JBS.

Internal Error (src/hotspot/share/memory/heap.cpp:838), pid=1525697, tid=1525715

assert((count == 0) || (extra_hops < (16 + 2*count))) failed: CodeHeap: many extra hops due to optimization. blocks: 234, extra hops: 484.

Discussion in https://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2019-October/035508.html doesn't tell where assertion (extra_hops < (16 + 2*count) comes from.

In CodeHeap::mark_segmap_as_used wehn is_FreeBlock_join is true, it creates extra hops in _segmap. _fragmentation_count in inced and trigger defrag_segmap when reach threshold. In my understanding, extra hop can not guarantee under (16 + 2*count).

In following extreme case, before HeapBlock free, segmap is all 0 (each blob use 1 smallest segment), suppose free action is applied from right to left. This increase 9 unnecessary hop for 1 continous HeapBlock. assertion (extra_hops < (16 + 2*count) is not safe.
|0|0|0|0|0|0|0|0|0|0|
after free, it will be
|0|1|1|1|1|1|1|1|1|1|

Proposed fix is assert extra hops not exceed _fragmentation_count. And if it exceeds (16 + 2 * count), give warning on two many extra hops.

fastdebug tier1, tier2 with VerifyCodeCache passed on X86_64 linux, no extra assertion found.


Progress

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

Issue

  • JDK-8264223: CodeHeap::verify fails extra_hops assertion in fastdebug test

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3212

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 26, 2021

👋 Welcome back hshi! 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 Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@huishi-hs The following label will be automatically applied to this pull request:

  • hotspot-runtime

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.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 26, 2021

Webrevs

@DamonFool
Copy link
Member

@DamonFool DamonFool commented Mar 26, 2021

It would be better to add a test run with -XX:+VerifyCodeCache into one of the failing tests.
Thanks.

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Mar 26, 2021

It would be better to add a test run with -XX:+VerifyCodeCache into one of the failing tests.
Thanks.

Thanks! Test is addded for one previously fail case.

@DamonFool
Copy link
Member

@DamonFool DamonFool commented Mar 26, 2021

Thanks! Test is addded for one previously fail case.

Thanks for your update.

@dcubed-ojdk
Copy link
Member

@dcubed-ojdk dcubed-ojdk commented Mar 26, 2021

This is a hotspot/compiler bug. This review should have gone to the hotspot-compiler
alias and not the hotspot-runtime alias.

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Mar 26, 2021

/label add hotspot-compiler

@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@huishi-hs
The hotspot-compiler label was successfully added.

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Mar 26, 2021

/label remove hotspot-runtime

@openjdk openjdk bot removed the hotspot-runtime label Mar 26, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 26, 2021

@huishi-hs
The hotspot-runtime label was successfully removed.

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Mar 26, 2021

This is a hotspot/compiler bug. This review should have gone to the hotspot-compiler
alias and not the hotspot-runtime alias.

Thanks! Daniel

@dholmes-ora
Copy link
Member

@dholmes-ora dholmes-ora commented Mar 29, 2021

This is a hotspot/compiler bug. This review should have gone to the hotspot-compiler
alias and not the hotspot-runtime alias.

@dcubed-ojdk The bot assigned it to runtime, so we probably need to check the file matching rules.

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Mar 30, 2021

Would someone help review this PR?

@RealLucy the failure assertion is introduced in CodeHeap management earlier, could you help comment and review?

@RealLucy
Copy link

@RealLucy RealLucy commented Mar 31, 2021

Will look into this and comment/review asap.

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Mar 31, 2021

Will look into this and comment/review asap.

Thanks!

Copy link

@RealLucy RealLucy left a comment

The change looks good to me.
Thank you for digging into the tricky code to understand what's happening. The previous limit (16+2*count) was purely heuristic. Obviously, you have a more pathological test case.

@openjdk
Copy link

@openjdk openjdk bot commented Mar 31, 2021

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

8264223: CodeHeap::verify fails extra_hops assertion in fastdebug test

Reviewed-by: lucy, 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 104 new commits pushed to the master branch:

  • 0696fd0: 8263496: MetalHighContrastTheme.getControlHighlight cleanup
  • 6cf1095: 8264484: Replace uses of StringBuffer with StringBuilder in jdk.hotspot.agent
  • d2df9a7: 8264331: Use the blessed modifier order in jdk.compiler
  • 0228734: 8262470: Printed GlyphVector outline with low DPI has bad quality on Windows
  • 3997c99: 8264222: Use switch expression in jshell where possible
  • 39f0b27: 8176026: SA: Huge heap sizes cause a negative value to be displayed in the jhisto heap total
  • de495df: 8264413: Data is written to file header even if its CRC32 was calculated
  • 52d8a22: 8264054: Bad XMM performance on java.lang.MathBench.sqrtDouble
  • 16acfaf: 8012229: [lcms] Improve performance of color conversion for images with alpha channel
  • cb70ab0: 8263235: sanity/client/SwingSet/src/ColorChooserDemoTest.java failed throwing java.lang.NoClassDefFoundError
  • ... and 94 more: https://git.openjdk.java.net/jdk/compare/3e18330a33386f48e691d358a73521e23ef0618d...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 (@RealLucy, @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 label Mar 31, 2021
@RealLucy
Copy link

@RealLucy RealLucy commented Mar 31, 2021

I would volunteer to sponsor this PR

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Apr 1, 2021

/integrate

@huishi-hs
Copy link
Author

@huishi-hs huishi-hs commented Apr 1, 2021

The change looks good to me.
Thank you for digging into the tricky code to understand what's happening. The previous limit (16+2*count) was purely heuristic. Obviously, you have a more pathological test case.

Thanks! The entire CodeHeap optimization is great!

@openjdk openjdk bot added the sponsor label Apr 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 1, 2021

@huishi-hs
Your change (at version f9c5cf9) is now ready to be sponsored by a Committer.

@RealLucy
Copy link

@RealLucy RealLucy commented Apr 1, 2021

You will need a second review before the fix can be integrated.

Copy link
Contributor

@shipilev shipilev left a comment

It looks fine. But I have a question: are we reasonably sure that extra_hops <= _fragmentation_count always. More specifically, when _fragmentation_count drops to 0, are extra_hops guaranteed to be 0 as well?

@RealLucy
Copy link

@RealLucy RealLucy commented Apr 1, 2021

@shipilev Short answer: yes.
Long answer:
_fragmentation_count is incremented every time the segment map becomes potentially more fragmented by introducing an additional chunk, see mark_segmap_as_used(). Therefore, _fragmentation_count overestimates the actual segmap fragmentation.

Once _fragmentation_count hits the limit, defragmentation is triggered (defrag_segmap(true)) and the counter is set to zero. After defragmentation, segmap should not contain any extra hops - that's the purpose of defragmentation. If is does, I would classify that as a bug.

Copy link
Contributor

@shipilev shipilev left a comment

Okay then, thanks.

@RealLucy
Copy link

@RealLucy RealLucy commented Apr 1, 2021

/sponsor

@openjdk openjdk bot closed this Apr 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 1, 2021

@RealLucy @huishi-hs Since your change was applied there have been 104 commits pushed to the master branch:

  • 0696fd0: 8263496: MetalHighContrastTheme.getControlHighlight cleanup
  • 6cf1095: 8264484: Replace uses of StringBuffer with StringBuilder in jdk.hotspot.agent
  • d2df9a7: 8264331: Use the blessed modifier order in jdk.compiler
  • 0228734: 8262470: Printed GlyphVector outline with low DPI has bad quality on Windows
  • 3997c99: 8264222: Use switch expression in jshell where possible
  • 39f0b27: 8176026: SA: Huge heap sizes cause a negative value to be displayed in the jhisto heap total
  • de495df: 8264413: Data is written to file header even if its CRC32 was calculated
  • 52d8a22: 8264054: Bad XMM performance on java.lang.MathBench.sqrtDouble
  • 16acfaf: 8012229: [lcms] Improve performance of color conversion for images with alpha channel
  • cb70ab0: 8263235: sanity/client/SwingSet/src/ColorChooserDemoTest.java failed throwing java.lang.NoClassDefFoundError
  • ... and 94 more: https://git.openjdk.java.net/jdk/compare/3e18330a33386f48e691d358a73521e23ef0618d...master

Your commit was automatically rebased without conflicts.

Pushed as commit 011f6d1.

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

@huishi-hs huishi-hs deleted the huishi-hs:CodeHeapVerify branch Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
6 participants