-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8260267: vmTestbase/gc/gctests/FinalizeLock/FinalizeLock.java fails with fatal error: Mark stack space exhausted #3262
Closed
+61
−3
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
#include "gc/z/zLock.inline.hpp" | ||
#include "gc/z/zMarkStack.inline.hpp" | ||
#include "gc/z/zMarkStackAllocator.hpp" | ||
#include "gc/z/zMark.hpp" | ||
#include "logging/log.hpp" | ||
#include "runtime/atomic.hpp" | ||
#include "runtime/os.hpp" | ||
|
@@ -128,7 +129,8 @@ uintptr_t ZMarkStackSpace::alloc(size_t size) { | |
|
||
ZMarkStackAllocator::ZMarkStackAllocator() : | ||
_freelist(), | ||
_space() { | ||
_space(), | ||
_nmagazine(0) { | ||
// Prime free list to avoid an immediate space | ||
// expansion when marking starts. | ||
if (_space.is_initialized()) { | ||
|
@@ -159,13 +161,45 @@ ZMarkStackMagazine* ZMarkStackAllocator::create_magazine_from_space(uintptr_t ad | |
assert(success, "Magazine should never get full"); | ||
} | ||
|
||
inc_nmagazine(); | ||
|
||
return magazine; | ||
} | ||
|
||
void ZMarkStackAllocator::inc_nmagazine() { | ||
int cur = Atomic::add(&_nmagazine, 1); | ||
if (!ZMark::push_local_stripe() && | ||
cur * ZMarkStackMagazineSize >= ZMarkStackSpaceLimit * ZStackModeChangeRatio) { | ||
ZMark::set_push_local_stripe(true); | ||
} | ||
} | ||
|
||
void ZMarkStackAllocator::dec_nmagazine() { | ||
int nmagazine = Atomic::load(&_nmagazine); | ||
|
||
for (;;) { | ||
if (nmagazine == 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's confusing here _nmagazine can be negative after dec. might add some comment on this method. |
||
break; | ||
} | ||
const int new_nmagazine = nmagazine - 1; | ||
const int prev_nmagazine = Atomic::cmpxchg(&_nmagazine, nmagazine, new_nmagazine); | ||
if (prev_nmagazine == nmagazine) { | ||
break; | ||
} | ||
nmagazine = prev_nmagazine; | ||
} | ||
|
||
if (ZMark::push_local_stripe() && | ||
nmagazine * ZMarkStackMagazineSize * 2.0 < ZMarkStackSpaceLimit * ZStackModeChangeRatio) { | ||
ZMark::set_push_local_stripe(false); | ||
} | ||
} | ||
|
||
ZMarkStackMagazine* ZMarkStackAllocator::alloc_magazine() { | ||
// Try allocating from the free list first | ||
ZMarkStackMagazine* const magazine = _freelist.pop(); | ||
if (magazine != NULL) { | ||
inc_nmagazine(); | ||
return magazine; | ||
} | ||
|
||
|
@@ -180,4 +214,5 @@ ZMarkStackMagazine* ZMarkStackAllocator::alloc_magazine() { | |
|
||
void ZMarkStackAllocator::free_magazine(ZMarkStackMagazine* magazine) { | ||
_freelist.push(magazine); | ||
dec_nmagazine(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 introduces a volatile read in every object mark, do you have concurrent mark time mesaurement with this check?
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 volatile read has impact on the mark time, the average mark time increased by 4.7%
Jdk17 zgc origin:
RUN RESULT: hbIR (max attempted) = 124943, hbIR (settled) = 121646, max-jOPS = 111199, critical-jOPS = 91446
RUN RESULT: hbIR (max attempted) = 122581, hbIR (settled) = 118652, max-jOPS = 111549, critical-jOPS = 92803
RUN RESULT: hbIR (max attempted) = 130653, hbIR (settled) = 119162, max-jOPS = 111055, critical-jOPS = 95202
[2021-03-26T16:49:41.474+0800][info ][gc,stats ] Phase: Concurrent Mark 0.000 / 0.000 1142.885 / 1689.873 800.652 / 3473.744 800.652 / 3473.744 ms
[2021-03-26T19:03:55.173+0800][info ][gc,stats ] Phase: Concurrent Mark 0.000 / 0.000 1204.003 / 1975.038 843.825 / 3006.138 843.825 / 3006.138 ms
[2021-03-26T21:14:13.816+0800][info ][gc,stats ] Phase: Concurrent Mark 0.000 / 0.000 1147.566 / 2477.271 827.487 / 2982.508 827.487 / 2982.508 ms
Jdk17 zgc patch:
RUN RESULT: hbIR (max attempted) = 130653, hbIR (settled) = 116479, max-jOPS = 111055, critical-jOPS = 94165
RUN RESULT: hbIR (max attempted) = 130653, hbIR (settled) = 116752, max-jOPS = 109749, critical-jOPS = 97445
RUN RESULT: hbIR (max attempted) = 130653, hbIR (settled) = 118685, max-jOPS = 111055, critical-jOPS = 93540
[2021-03-30T20:53:35.593+0800][info ][gc,stats ] Phase: Concurrent Mark 0.000 / 0.000 1198.332 / 3098.680 860.451 / 3198.799 860.451 / 3198.799 ms
[2021-03-30T23:07:36.532+0800][info ][gc,stats ] Phase: Concurrent Mark 0.000 / 0.000 1155.819 / 1550.257 842.028 / 3189.933 842.028 / 3189.933 ms
[2021-03-31T01:27:26.091+0800][info ][gc,stats ] Phase: Concurrent Mark 0.000 / 0.000 1211.280 / 1964.112 883.528 / 3053.926 883.528 / 3053.926 ms