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

Fixup continuation lists for concurrent scavenge backout case #19562

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

LinHu2016
Copy link
Contributor

the Objects, which have been copied to survivor or tenure during concurrent scavenge, would not roll back for back out case, so in the following global marking, we need to update the forwardObject in the continuation list.

@amicic amicic added comp:gc project:loom Used to track Project Loom related work labels May 28, 2024

if (NULL != forwardPtr) {
Assert_MM_false(_markingScheme->isMarked(object));
if (!forwardHeader.isSelfForwardedPointer()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

invert the logic (don't use '!') and swap the order

@@ -329,6 +330,22 @@ MM_MarkingSchemeRootClearer::scanContinuationObjects(MM_EnvironmentBase *env)
while (NULL != object) {
gcEnv->_markJavaStats._continuationCandidates += 1;
omrobjectptr_t next = _extensions->accessBarrier->getContinuationLink(object);

{
/* fixup leftover from backout concurrent scavenge */
Copy link
Contributor

@amicic amicic May 28, 2024

Choose a reason for hiding this comment

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

be more specific.... for example: in case of CS backout make sure the list contains the new version of the objects or if there is only one version, due to being self-forwarded, restore the self-forwarded bit

we could even check that CS backout was on before proceeding with this step, but probably not much savings anyway

}
regionExtension->_continuationObjectLists[i].backoutList();
Copy link
Contributor

@amicic amicic May 28, 2024

Choose a reason for hiding this comment

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

i think this would be easier to read if

  1. CS check is repeated only once, at the highest possible point (still within while loop), while admittedly at the cost of repeating backout call for evac region
while 
    if CS
       if evac region then backout
    else (if not CS)
       same as we used to do before the changes
  1. do 'if evac region' based on lowAddress, rather than the first element of the list

@LinHu2016 LinHu2016 force-pushed the backout_concurrentscavenge branch 2 times, most recently from 4e45d96 to 237b446 Compare May 28, 2024 21:13
@@ -329,6 +330,26 @@ MM_MarkingSchemeRootClearer::scanContinuationObjects(MM_EnvironmentBase *env)
while (NULL != object) {
gcEnv->_markJavaStats._continuationCandidates += 1;
omrobjectptr_t next = _extensions->accessBarrier->getContinuationLink(object);

Copy link
Contributor

Choose a reason for hiding this comment

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

We should put this block within

#if defined(OMR_GC_CONCURRENT_SCAVENGER)

We do it for other CS aware code in Marking (for example in OMR's MM_MarkingScheme::fixupForwardedSlot)

Still thinking if we should add any runtime check... @dmitripivkine, an opinion?

regionExtension->_continuationObjectLists[i].backoutList();
}
}
} else {
for (uintptr_t i = 0; i < regionExtension->_maxListIndex; i++) {
Copy link
Contributor

@amicic amicic May 29, 2024

Choose a reason for hiding this comment

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

we could pull out even the 2 for loops in front of 'if CS' check'
it's a tradeoff between more code sharing vs performance (check CS for each sublist)
I slightly prefer simpler code, but again asking @dmitripivkine for an opinion

also, please convert the comments to C style /* */

Copy link
Contributor

Choose a reason for hiding this comment

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

For this case my vote is for more code sharing indeed. May be caching _extensions->isConcurrentScavengerEnabled() locally in the const bool variable can improve performance (but good compiler should do it already).

Copy link
Contributor

Choose a reason for hiding this comment

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

@LinHu2016 sorry for all the confusion
more sharing would mean to push CS check more inside the loops (even inside the for loops)
but still keeping CS if check in front of other if checks for easier understanding
it is not optimal from perf point (to repeat same checks for same regions, while iterating through its sublists), but this is anyway very cheap processing, so we can live with it for the sake of code sharing and clarity

while regions
    for region lists 
       if CS
          if evac region then backout list
       else (if not CS)
          same as we used to do before the changes

Copy link
Contributor

Choose a reason for hiding this comment

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

no need to cache isCS enabled flag. as Dmitri said it's probably optimized out, and even if it's not, again, this processing in total is very short, one way or another

@LinHu2016 LinHu2016 force-pushed the backout_concurrentscavenge branch 2 times, most recently from 6c41e94 to bbf14b0 Compare May 30, 2024 17:41
/**
* In case of CS backout make sure the list contains the new version of the objects or if there is only one version,
* due to being self-forwarded, restore the self-forwarded bit.
* we could even check that CS backout was on before proceeding with this step, but probably not much savings anyway.
Copy link
Contributor

Choose a reason for hiding this comment

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

actually, let's remove this line of the comment and put the runtime checks instead (I believe at this point backout flag has not been cleared yet)

_extensions->isConcurrentScavengerEnabled() && _extensions->isScavengerBackOutFlagRaised()

@@ -66,6 +66,8 @@ MM_ScavengerRootScanner::startContinuationProcessing(MM_EnvironmentBase *env)
if (!list->wasEmpty()) {
_scavengerDelegate->setShouldScavengeContinuationObjects(true);
}
} else {
list->backupList();
Copy link
Contributor

Choose a reason for hiding this comment

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

While touching the file, fix a few coding standard problems like

  • space between if/while and '('
  • UDATA -> uintptr_t
  • * next to variable, rather next to the type

the Objects, which have been copied to survivor or tenure during
concurrent scavenge, would not roll back for back out case, so in the
following global marking, we need to update the forwardObject in the
continuation list.

Signed-off-by: hulin <linhu@ca.ibm.com>
@amicic
Copy link
Contributor

amicic commented May 31, 2024

jenkins test sanity win,aix jdk21

@amicic amicic merged commit dfa76b4 into eclipse-openj9:master Jun 3, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:gc project:loom Used to track Project Loom related work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants