-
Notifications
You must be signed in to change notification settings - Fork 788
Fix PGC edenSurvivalRate overflow issue #24273
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
Closed
LinHu2016
wants to merge
2
commits into
eclipse-openj9:master
from
LinHu2016:fix_edenSurvivalRateCopyForward
+35
−3
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -372,7 +372,15 @@ MM_SchedulingDelegate::partialGarbageCollectCompleted(MM_EnvironmentVLHGC *env, | |
| bool globalSweepHappened = _globalSweepRequired; | ||
| _globalSweepRequired = false; | ||
| /* copy out the Eden size of the previous interval (between the last PGC and this one) before we recalculate the next one */ | ||
| uintptr_t edenCountBeforeCollect = getCurrentEdenSizeInRegions(env); | ||
| /* During GC, the heap may expand to allow the current collection to continue. | ||
| * A heap resize triggers an eden size recalculation without allowing further | ||
| * heap expansion (heap reconfiguration). As a result, the newly calculated | ||
| * eden size can differ significantly from the eden size at the start of the | ||
| * collection, causing the SurvivalRate calculation to become inaccurate. | ||
| * Therefore, set copyForwardStats->_edenEvacuateRegionCount (instead of getCurrentEdenSizeInRegions(env)) to | ||
| * edenCountBeforeCollect. | ||
| */ | ||
| uintptr_t edenCountBeforeCollect = copyForwardStats->_edenEvacuateRegionCount; | ||
|
|
||
| Trc_MM_SchedulingDelegate_partialGarbageCollectCompleted_stats(env->getLanguageVMThread(), | ||
| copyForwardStats->_edenEvacuateRegionCount, | ||
|
|
@@ -393,12 +401,27 @@ MM_SchedulingDelegate::partialGarbageCollectCompleted(MM_EnvironmentVLHGC *env, | |
| Assert_MM_true( (0 == copyForwardStats->_scanBytesEden) || copyForwardStats->_aborted || (0 != copyForwardStats->_nonEvacuateRegionCount)); | ||
| Assert_MM_true( (0 == copyForwardStats->_scanBytesNonEden) || copyForwardStats->_aborted || (0 != copyForwardStats->_nonEvacuateRegionCount)); | ||
| edenSurvivorCount += (copyForwardStats->_scanBytesEden + regionSize - 1) / regionSize; | ||
| Assert_GC_true_with_message(env, copyForwardStats->_edenSurvivorRegionCount <= edenCountBeforeCollect, | ||
| "partialGarbageCollectCompleted copyForwardStats->_edenSurvivorRegionCount=%zu, copyForwardStats->_edenEvacuateRegionCount=%zu, edenCountBeforeCollect=%zu, edenSurvivorCount=%zu, copyForwardStats->_aborted=%zu, getCurrentEdenSizeInRegions(env)=%zu\n", | ||
| copyForwardStats->_edenSurvivorRegionCount, copyForwardStats->_edenEvacuateRegionCount, edenCountBeforeCollect, edenSurvivorCount, copyForwardStats->_aborted, getCurrentEdenSizeInRegions(env)); | ||
| if (edenSurvivorCount > edenCountBeforeCollect) { | ||
| /* when abort is in progress, every Eden object scanned in abort-recovery contributes to _scannedBytes. | ||
| * But an object that was partially copied before abort (the copy succeeded, | ||
| * the forwarding pointer was installed) is also counted again during the abort scan of the source region. | ||
| * So _scanBytesEden might be double-counted, then cause edenSurvivorCount is bigger than edenCountBeforeCollect. | ||
| * for this case, set edenSurvivorCount = edenCountBeforeCollect. | ||
| */ | ||
| Assert_MM_true(copyForwardStats->_aborted); | ||
| edenSurvivorCount = edenCountBeforeCollect; | ||
| } | ||
| nonEdenSurvivorCount += (copyForwardStats->_scanBytesNonEden + regionSize - 1) / regionSize; | ||
|
|
||
| /* Eden count could be 0 in special case, after compaction if there is still no free region for scheduling eden(eden count = 0), | ||
| will skip update Survival Rate */ | ||
| if (0 != edenCountBeforeCollect) { | ||
| /* SurvivalRate should never be over 1.0 */ | ||
|
Contributor
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. let's assert it |
||
| double thisSurvivalRate = (double)edenSurvivorCount / (double)edenCountBeforeCollect; | ||
| Assert_MM_true(1.0 >= thisSurvivalRate); | ||
| updateSurvivalRatesAfterCopyForward(thisSurvivalRate, nonEdenSurvivorCount); | ||
| } | ||
|
|
||
|
|
||
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.
let's assert that abort was in progress