Skip to content

Add support for Nursery only compact#8248

Open
shadman2606 wants to merge 1 commit into
eclipse-omr:masterfrom
shadman2606:slide-compact
Open

Add support for Nursery only compact#8248
shadman2606 wants to merge 1 commit into
eclipse-omr:masterfrom
shadman2606:slide-compact

Conversation

@shadman2606

@shadman2606 shadman2606 commented May 11, 2026

Copy link
Copy Markdown
Contributor

Add support for Nursery only compact

  • add a flag to control if whole heap compacted or Nursery only
  • use the fixup_only subarea state to skip moving Tenure objects

Issue: eclipse-openj9/openj9#20515

Signed-off-by: Shadman Siddiqui shadman2606@gmail.com

@amicic amicic added the comp:gc label May 12, 2026
@@ -48,6 +48,7 @@ class MM_ParallelCompactTask : public MM_ParallelTask
MM_CompactScheme *_compactScheme;
bool _rebuildMarkBits;
bool _aggressive;
bool nurseryOnly;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

members should start with '_'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread gc/base/standard/ParallelGlobalGC.cpp Outdated
if (CompactReason::COMPACT_ABORTED_SCAVENGE == compactStats->_compactReason)
{
nurseryOnly = true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you can collapse it into one line:

bool nurseryOnly = (CompactReason::COMPACT_ABORTED_SCAVENGE == compactStats->_compactReason);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

{
nurseryOnly = true;
}
MM_ParallelCompactTask compactTask(env, _dispatcher, _compactScheme, rebuildMarkBits, env->_cycleState->_gcCode.shouldAggressivelyCompact(), nurseryOnly);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Honestly, don't know why rebuildMarkBits and aggressive (and now nurseryOnly) are passed to the CompactTask, rather than CompactScheme.

If they were part of CompactScheme then we would not need to pass them later through various methods via params, instead of just fetching them from CompactScheme when needed.

Perhaps we can fix/simplify that later. For now, let's keep the focus on minimal changes.

@shadman2606 shadman2606 force-pushed the slide-compact branch 2 times, most recently from 6c15ce7 to a4b04f0 Compare May 14, 2026 15:51
if(nurseryOnly && MEMORY_TYPE_OLD == memorySubSpace->getTypeFlags())
{
state = SubAreaEntry::fixup_only;
}

@amicic amicic May 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
if (nurseryOnly && (MEMORY_TYPE_OLD == memorySubSpace->getTypeFlags())) {
state = SubAreaEntry::fixup_only;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fix the formatting for other similar spots accordingly

  1. add extra oval brackets
  2. curly bracket is up one line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

fully correct check is actually

MEMORY_TYPE_OLD == (getTypeFlags() & MEMORY_TYPE_OLD))

since other bit-wise flags could be set too (like MEMORY_TYPE_RAM)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread gc/base/standard/CompactScheme.cpp Outdated
if (changeSubAreaAction(env, &subAreaTable[i], SubAreaEntry::fixing_heap_for_walk)) {
omrobjectptr_t start = subAreaTable[i].firstObject;
omrobjectptr_t end = subAreaTable[i].firstObject;
omrobjectptr_t end = subAreaTable[i+1].firstObject;

@amicic amicic May 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we typically provide extra space around binary operators

[i + 1]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@shadman2606 shadman2606 changed the title Optimize sliding compact for tenure after aborted scavenge Add support for Nursery only compact May 20, 2026
Comment thread gc/base/standard/CompactScheme.cpp Outdated

while(NULL != (memoryPool = poolIterator.nextPool())) {
memoryPool->postProcess(env, MM_MemoryPool::forCompact);
if(!nurseryOnly || (MEMORY_TYPE_OLD != (memoryPool->getSubSpace()->getTypeFlags() & MEMORY_TYPE_OLD))) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there should be space between keywords if, while, for,... and opening oval bracket

fix anywhere in the code you updated or even in vicinity of those that you have not updated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

MM_CompactScheme *_compactScheme;
bool _rebuildMarkBits;
bool _aggressive;
bool _nurseryOnly;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add comment
/**< if true, Nursery is only compacted and Tenure fixed-up via RS, otherwise whole heap is compacted/fixed-up */

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread gc/base/standard/ParallelGlobalGC.cpp Outdated
compactStats->_startTime = omrtime_hires_clock();
MM_ParallelCompactTask compactTask(env, _dispatcher, _compactScheme, rebuildMarkBits, env->_cycleState->_gcCode.shouldAggressivelyCompact());
bool nurseryOnly = false;
nurseryOnly = (CompactReason::COMPACT_ABORTED_SCAVENGE == compactStats->_compactReason);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could be one line:

bool nurseryOnly = (CompactReason::COMPACT_ABORTED_SCAVENGE == compactStats->_compactReason);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@shadman2606 shadman2606 force-pushed the slide-compact branch 2 times, most recently from 1820145 to 7cf582c Compare May 22, 2026 17:45
- add a flag to control if whole heap compacted or Nursery only
- use the fixup_only subarea state to skip moving Tenure objects

Issue: eclipse-openj9/openj9#20515

Signed-off-by: Shadman Siddiqui shadman2606@gmail.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants