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

RamClass: Segment allocation enhancements #20831

Closed

Conversation

h3110n3rv3
Copy link
Contributor

@h3110n3rv3 h3110n3rv3 commented Dec 13, 2024

The changes reflect the feature request #20644.

Adding segment categories for RAMCLass fragments:

  • sub4G
  • Frequently accessed
  • Infrequently accessed

Closes: #20644
Signed-off-by: Nick Kamal <[email protected]>

Copy link
Contributor

@ThanHenderson ThanHenderson left a comment

Choose a reason for hiding this comment

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

Given that this is still a WIP, my initial review focused on more superficial - but still important - things that should be addressed. Once it is changed to a non-WIP, I will focus on semantics and functionality. Feel free to start a discussion on any of my comments if something isn't clear or you disagree.

Additionally, we typically squash all the commits in a PR into one commit before merge. This doesn't mean that we can't have multiple commits before merging, but in the case of this PR where the commits are initial changes, compiling versions, and remove prints, and not logical units of added functionality, I suggest you consider squashing them.

runtime/jcl/common/mgmtmemory.c Outdated Show resolved Hide resolved
runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
SUB4G = 0,
FREQUENTLY_ACCESSED,
INFREQUENTLY_ACCESSED
};
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's rename this enum to SegmentKind.

Copy link
Contributor

Choose a reason for hiding this comment

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

We also support enum class. Those are scoped types and are generally safer.

runtime/vm/createramclass.cpp Outdated Show resolved Hide resolved
runtime/vm/createramclass.cpp Show resolved Hide resolved
@h3110n3rv3 h3110n3rv3 force-pushed the ramClass-segment-allocation branch 2 times, most recently from 954942c to 2e22055 Compare December 16, 2024 23:59
The changes reflect the feature request eclipse-openj9#20644.

Adding segment categories

Closes: eclipse-openj9#20644
Signed-off-by: Nick Kamal <[email protected]>
@h3110n3rv3 h3110n3rv3 force-pushed the ramClass-segment-allocation branch from 1037394 to 343b33b Compare December 17, 2024 12:54
@h3110n3rv3
Copy link
Contributor Author

@h3110n3rv3 h3110n3rv3 changed the title WIP: RamClass: Segment allocation enhancements RamClass: Segment allocation enhancements Dec 19, 2024
@tajila tajila requested review from theresa-m and ThanHenderson and removed request for ThanHenderson January 2, 2025 14:32
@@ -4005,8 +4048,14 @@ internalAllocateRAMClass(J9JavaVM *javaVM, J9ClassLoader *classLoader, RAMClassA
/* TODO attempt to coalesce free blocks? */
Copy link
Contributor

Choose a reason for hiding this comment

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

line 4020->4103 should be done in a separate function since you need to do it 3 times for each segment kind.

For example

		for (request = requests; NULL != request; request = request->next) {
			fragmentsLeftToAllocate++;
			newSegmentSize += request->fragmentSize + request->alignment;
		}

That part needs to be calculated for a specific segment kind.

Copy link
Contributor

Choose a reason for hiding this comment

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


		/* Add sizeof(UDATA) to hold the "lastAllocatedClass" pointer */
		newSegmentSize += sizeof(UDATA);

The following should only be done in the sub4g segment

Copy link
Contributor

@theresa-m theresa-m left a comment

Choose a reason for hiding this comment

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

First pass. I'll have a closer look at createramclass.cpp tomorrow.

Comment on lines 3602 to +3608
struct J9MemorySegment* classSegments;
struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList;
UDATA* ramClassUDATABlockFreeList;
struct J9RAMClassFreeLists sub4gBlock;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these names would be more descriptive as something like "sub4gFreeLists". I'm not sure what block is referring to here.

runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList;
} J9RAMClassFreeLists;

typedef struct J9RAMClassUDATABlockFreeList {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest adding a UDATA * field to J9RAMClassFreeLists instead of having a separate structure to hold these values.

runtime/jcl/common/mgmtmemory.c Outdated Show resolved Hide resolved
J9RAMClassFreeLists *sub4gFreeListBlock = &classLoader->sub4gBlock;
J9RAMClassFreeLists *freqFreeListBlock = &classLoader->frequentlyAccessedBlock;
J9RAMClassFreeLists *InFreqFreeListBlock = &classLoader->inFrequentlyAccessedBlock;
if (NULL != udataFreeListBlock) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This check is not necessary since classLoader->ramClassUDATABlocks is not a pointer. This applies to the J9RAMClassFreeLists's as well.

runtime/jcl/common/mgmtmemory.c Outdated Show resolved Hide resolved
runtime/oti/j9nonbuilder.h Outdated Show resolved Hide resolved
enum SegmentKind {
SUB4G = 0,
FREQUENTLY_ACCESSED,
INFREQUENTLY_ACCESSED
Copy link
Contributor

Choose a reason for hiding this comment

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

INFREQUENTLY_ACCESSED is never assigned as a segment type. Is that intentional?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, following this PR the plan is to do some benchmarking to determine which fragments are infrequently accessed.

if (request->prefixSize != 0) {
request->address++;
}
Trc_VM_internalAllocateRAMClass_AllocatedFromFreeList(request->index, block, sizeof(UDATA), request->address, request->prefixSize, request->alignedSize, request->alignment);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this may be more useful if information was provided on which list the block is coming from

h3110n3rv3 and others added 20 commits January 9, 2025 09:58
The changes reflect the feature request eclipse-openj9#20644.

Adding segment categories

Closes: eclipse-openj9#20644
Signed-off-by: Nick Kamal <[email protected]>
Remove "-zos" suffix before checking whether the version is "next".

Signed-off-by: Keith W. Campbell <[email protected]>
A test level of "sanity" previously mapped to "sanity.functional", but
now maps to "sanity.functional,sanity.openjdk".  This change updates
build documentation to reflect that.  It also adds "openjdk" to the
list of recognized test groups, "functional" and "system".

Signed-off-by:  Henry Zongaro <[email protected]>
If null-restricted array is enabled and the class is an array class,
the null-restricted array class and the nullable array class share
the same signature. The null-restricted array can be viewed
as a sub-type of the nullable array. Therefore, the constraint cannot
be fixed class.

Related: eclipse-openj9#20522
Signed-off-by: Annabelle Huo <[email protected]>
Since the keepCycles array is zero-initialized, if the test is aborted
in the very first cycle (i == 0) the cleanup procedure at the end cannot
rely on the fact that keepCycles[j] >= i implies that segment j must
be freed. Before these changes, such a scenario would cause the test
to segfault during cleanup.

Signed-off-by: Christian Despres <[email protected]>
- explicitly initialize prevContextSwitches
- calculate switchRate with float

Related: eclipse-openj9#20725
Signed-off-by: Gengchen Tuo <[email protected]>
The IProfiler does not profile direct calls.
However, the optimizer may create artificial profiler
entries when it calls setCallCount(). These
artificial entries are marked to be non-persistent
and we only set the frequency (totalCount) ignoring
the class of the method that is called.
This commit also records the class of the method to
be called. Doing so does not require additional storage.

Signed-off-by: Marius Pirvu <[email protected]>
This change will allow createBalancedBST to be called from
places where the Compilation object is not readily available.

Signed-off-by: Marius Pirvu <[email protected]>
The goal is to use the code from TR_AggregationHT in
more places (for instance for dumping all IProfiler
info into the SCC).

Signed-off-by: Marius Pirvu <[email protected]>
This commit implements the TR_IProfiler::persistAllEntries()
method which can write all IProfiler entries into the SCC
on a ROMMethod by ROMMethod basis.

Signed-off-by: Marius Pirvu <[email protected]>
With the removal of the security manager (JEP 486) the System.security
field is not used for anything meaningful.

Signed-off-by: Theresa Mammarella <[email protected]>
These calls are not needed since System.getSecurityManager
 returns null for JDK 24+.

Signed-off-by: Theresa Mammarella <[email protected]>
Signed-off-by: Theresa Mammarella <[email protected]>
@h3110n3rv3 h3110n3rv3 force-pushed the ramClass-segment-allocation branch from c9294f1 to 61bea9f Compare January 9, 2025 14:58
@h3110n3rv3 h3110n3rv3 requested a review from dsouzai as a code owner January 9, 2025 14:58
@h3110n3rv3 h3110n3rv3 closed this Jan 9, 2025
@theresa-m
Copy link
Contributor

@h3110n3rv3 did you close this intentionally?

@h3110n3rv3
Copy link
Contributor Author

yes sorry i messed up the rebasing. I tried to fix it but couldn't so I closed this one and created another one. I am still working on changes based on Tobi's comments. I will update there once I am done.

@theresa-m
Copy link
Contributor

yes sorry i messed up the rebasing. I tried to fix it but couldn't so I closed this one and created another one. I am still working on changes based on Tobi's comments. I will update there once I am done.

Sounds good! If you need some help on this in the future let me know, it can certainly be a mess.

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.

RamClass: Segment allocation enhancements
10 participants