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

Add Xgc options for suballocator heap size and quick allocation #7414

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

ThanHenderson
Copy link
Contributor

@ThanHenderson ThanHenderson commented Jul 18, 2024

  1. Use VMEM_ALLOC_QUICK by default for allocateRegion in
    allocate_memory32
  2. Adds -Xgc:suballocatorQuickAllocDisable option that
    disables the default VMEM_ALLOC_QUICK
  3. Adds -Xgc:suballocatorIncrementSize option that replaces the
    HEAP_SIZE_BYTES macro and controls the heap increment size
  4. Adds an omrport_copy_suballocator_globals procedure that correctly
    initializes the PPG suballoctor globals for memCheckPortLib when
    -Xcheck is provided
  5. Updates related documentation

Addresses: #7190
Signed-off-by: Nathan Henderson nathan.henderson@ibm.com

@ThanHenderson
Copy link
Contributor Author

ThanHenderson commented Jul 18, 2024

FYI @babsingh

This relates to #7190 (comment)

However, there are a few issues that arose during testing.

The patch adds fields to the PPG_mem_mem32_subAllocHeapMem32 structure for the suballocatorIncrementSize (heap size) and suballocatorQuickAlloc, both of which are set from the corresponding GC extensions fields that are either the default values or the values specified via added the command line options.

In omrmem32helpers.c, startup_memory32 zeroes out the PPG_mem_mem32_subAllocHeapMem32 fields and is called during port library initialization. Then, MM_MemoryManager::createVirtualMemoryForHeap calls omrport_control to set the PPG_mem_mem32_subAllocHeapMem32 suballocatorIncrementSize and suballocatorQuickAlloc to the default or user supplied value. I chose this approach because it is also what is done for the previously implemented suballocatorCommitSize option.

PPG_mem_mem32_subAllocHeapMem32.suballocatorIncrementSize replaces the previous macro HEAP_SIZE_BYTES and is used in the allocate_memory32 procedure. The problem is that it turns out that createVirtualMemoryForHeap isn't always called before allocate_memory32, this is observable in some sanity.functional tests (3 of them resulting in failures on PPCAIX), and thus in those cases, it isn't updated from 0 to the default value or user defined value.

I am trying to figure out where/when the best time to set these PPG values to ensure that it precedes all calls to allocate_memory32. An obvious answer would be to set them just in startup_memory32, but that would talk some work around integration of GCExtensionsBase.hpp C++ code into the omrmem32helpers.c C code. I am going to go that route initially, but I am open to suggestions here.

Update edit:
PPG_mem_mem32_subAllocHeapMem32.suballocatorIncrementSize is only not set properly if -Xcheck is passed because memCheck_initialize sets up its own port lib and doesn't call createVirtualMemoryForHeap. All the allocations done via the memcheck port lib do not have the PPG_mem_mem32 options set apart from in startup_memory32.

@babsingh
Copy link
Contributor

where/when the best time to set these PPG values ...

Try setting PPG values before protectedInitializeJavaVM is invoked; see jvminit.c; there are calls to j9port_control for initializing port library globals (PPG).

@ThanHenderson
Copy link
Contributor Author

Try setting PPG values before protectedInitializeJavaVM is invoked

The problem is that we need to update the PPG values on the memCheckPortLib. They are set correctly for the normal port library for the VM, just not propagated to memcheck.

I've got something working where the memCheckPortLib PPG values are set when entering the memoryCheck_allocate_memory32 function that is used exclusively by and only for memcheck and precedes each call to allocate_memory32. It calls a port function called omrport_copy_subAllocHeapGlobals that then calls omrport_control on the memCheckPortLib with the fields of interest.

The only potential issue that I see with this is that there is more control flow in every call to memoryCheck_allocate_memory32, however modern branch predictors should be able to handle this quite readily since the PPG values only change on the first call to memoryCheck_allocate_memory32, every other call would see the same control flow without any memory writes on the subsequent calls.

@ThanHenderson ThanHenderson force-pushed the cmdline-subincr branch 3 times, most recently from 597a9cb to c9bfe5f Compare July 21, 2024 00:27
@ThanHenderson ThanHenderson changed the title WIP Add Xgc options for suballocator heap size and quick allocation Add Xgc options for suballocator heap size and quick allocation Jul 21, 2024
@ThanHenderson ThanHenderson marked this pull request as ready for review July 21, 2024 00:34
Copy link
Contributor

@babsingh babsingh left a comment

Choose a reason for hiding this comment

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

Minor formatting nitpicks.

gc/base/GCExtensionsBase.hpp Outdated Show resolved Hide resolved
port/common/omrmem32helpers.c Outdated Show resolved Hide resolved
port/common/omrmem32helpers.c Outdated Show resolved Hide resolved
port/common/omrmem32helpers.c Outdated Show resolved Hide resolved
port/common/omrportcontrol.c Outdated Show resolved Hide resolved
@babsingh
Copy link
Contributor

@keithc-ca @dmitripivkine Can you also review this PR?

@dmitripivkine
Copy link
Contributor

@amicic FYI

@keithc-ca
Copy link
Contributor

Depends on: eclipse-openj9/openj9#19872

A dependency in that direction is not reasonable; and cyclic dependencies even less so.

port/common/omrmem32helpers.c Outdated Show resolved Hide resolved
port/common/omrmem32struct.h Outdated Show resolved Hide resolved
port/common/omrport.c Outdated Show resolved Hide resolved
port/common/omrportcontrol.c Outdated Show resolved Hide resolved
port/common/omrportcontrol.c Outdated Show resolved Hide resolved
port/common/omrportcontrol.c Outdated Show resolved Hide resolved
@ThanHenderson ThanHenderson force-pushed the cmdline-subincr branch 3 times, most recently from 8be8a2f to 576481c Compare July 23, 2024 18:19
Copy link
Contributor

@dmitripivkine dmitripivkine left a comment

Choose a reason for hiding this comment

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

Looks good to me

@ThanHenderson
Copy link
Contributor Author

ThanHenderson commented Jul 26, 2024

@0xdaryl could you start testing and get this merged?

fvtest/porttest/omrmemTest.cpp Outdated Show resolved Hide resolved
include_core/omrgcconsts.h Outdated Show resolved Hide resolved
port/common/omrmem32struct.h Outdated Show resolved Hide resolved
@0xdaryl
Copy link
Contributor

0xdaryl commented Jul 27, 2024

Jenkins build all

Running initial testing on commits that are here.

@ThanHenderson
Copy link
Contributor Author

I had forgotten to add some #if defined(OMR_ENV_DATA64) around some definitions so some of the builds were failing. They will need to be relaunched.

@0xdaryl
Copy link
Contributor

0xdaryl commented Jul 29, 2024

Jenkins build all

@0xdaryl
Copy link
Contributor

0xdaryl commented Jul 30, 2024

Jenkins build all

@ThanHenderson
Copy link
Contributor Author

Who can I contact about the CI machines? The windows machines have been offline for a while now.

port/common/omrport.c Outdated Show resolved Hide resolved
include_core/omrport.h Outdated Show resolved Hide resolved
@0xdaryl
Copy link
Contributor

0xdaryl commented Jul 30, 2024

re/ Windows CI machines. They were offline pending critical security updates. I understand that's been completed, but additional work needs to be done to verify that and get them back online.

@ThanHenderson
Copy link
Contributor Author

Adam told me that there is no ETA for the Windows machines to be back online. All of the other ci builds passed. I have one more commit to push addressing Keith's issues with the comments. They won't affect the behaviour at all so I don't think we need to rerun all the builds.

1. Use VMEM_ALLOC_QUICK by default for allocateRegion in
   allocate_memory32
2. Adds -Xgc:suballocatorQuickAllocDisable option that
   disables the default VMEM_ALLOC_QUICK
3. Adds -Xgc:suballocatorIncrementSize option that replaces the
   HEAP_SIZE_BYTES macro and controls the heap increment size
4. Adds an omrport_copy_suballocator_globals procedure that correctly
   initializes the PPG suballoctor globals for memCheckPortLib when
   -Xcheck is provided
5. Updates related documentation

Addresses: eclipse-omr#7190
Signed-off-by: Nathan Henderson <nathan.henderson@ibm.com>
@0xdaryl
Copy link
Contributor

0xdaryl commented Jul 31, 2024

@keithc-ca : please formally approve if you're OK with the final changes

@0xdaryl 0xdaryl merged commit 11b61af into eclipse-omr:master Jul 31, 2024
6 checks passed
@pshipton
Copy link
Contributor

pshipton commented Aug 2, 2024

These changes are causing failures on AIX across all Java versions.
memleaksTest_0,cmdLineTester_GCRegressionTests_2,cmdLineTester_GCRegressionTests_3
WARNING: Out of memory in allocate_memory at /home/jenkins/workspace/Build_JDK8_ppc64_aix_OMR/openj9/runtime/vm/montable.c:153, returning NULL (3664 bytes were requested)

I created a build without this change and the failing tests pass.
https://hyc-runtimes-jenkins.swg-devops.com/view/Test_grinder/job/Grinder/42578

I'm creating a revert PR so we can get the pending OMR changes promoted.

@ThanHenderson
Copy link
Contributor Author

These changes are causing failures on AIX across all Java versions.

This happens when -Xcheck is passed. And since the corresponding OpenJ9 patch wasn't used to build, the memCheckPortLib isn't initialized properly. The OMR acceptance needs to be built with the corresponding OpenJ9 patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants