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

WIP: RamClass: Segment allocation enhancements #20831

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

h3110n3rv3
Copy link
Contributor

@h3110n3rv3 h3110n3rv3 commented Dec 13, 2024

The changes reflect the feature request #20644.

Adding segment categories

Personal builds:
sanity.functional
sanity.perf
sanity.system
sanity.openjdk
special.functional
extended.functional
extended.perf
extended.openjdk
extended.system
Test failures seen in extended.openjdk are known: #12795

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.

if (NULL != udataFreeListBlock) {
UDATA* sub4gListBlock = udataFreeListBlock->ramClassSub4gUDATABlockFreeList;
UDATA* freqListBlock = udataFreeListBlock->ramClassFreqUDATABlockFreeList;
UDATA* inFreqListBlock = udataFreeListBlock->ramClassInFreqUDATABlockFreeList;
Copy link
Contributor

Choose a reason for hiding this comment

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

These pointer-typed variables should have right-aligned *. e.g. UDATA *inFreqListBlock = udataFreeListBlock...

struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList;
} J9RAMClassFreeListBlockType;
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 Type in the struct name is a little ambiguous here. Could we think of a better name? Something like: J9RAMClassFreeLists.

Also, nit: the members should be from Tiny to Large, not the inverse.

struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList;
} J9RAMClassFreeListBlockType;

typedef struct RamClassUDATABlockFreelist {
Copy link
Contributor

Choose a reason for hiding this comment

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

The l in list should be capitalized. Also, we should keep consistency in struct naming:
RamClassUDATABlockFreelist should be J9RAMClassUDATABlockFreeList.

Though a higher level discussion point is: why are some types/variables FreeListBlock and others BlockFreeList?

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.

@@ -3745,19 +3766,19 @@ addBlockToFreeList(J9ClassLoader *classLoader, UDATA address, UDATA size)
}
if (sizeof(UDATA) == size) {
UDATA *block = (UDATA *) address;
*block = (UDATA) classLoader->ramClassUDATABlockFreeList;
classLoader->ramClassUDATABlockFreeList = block;
*block = (UDATA) ramClassUDATABlockFreelist;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove space after cast ) (for all casts lines changed in the PR).

allocateFreeListBlock (request, classLoader, prev, &classLoader->frequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassFreqUDATABlockFreeList);
} else if (INFREQUENTLY_ACCESSED == request->segmentType)
{
allocateFreeListBlock (request, classLoader, prev, &classLoader->inFrequentlyAccessedBlock, classLoader->ramClassUDATABlocks.ramClassInFreqUDATABlockFreeList);
Copy link
Contributor

Choose a reason for hiding this comment

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

The formatting of this if chain is incorrect, here is a link to the coding standards that we follow if you don't already have it.

Particularly, the if and else if blocks should be:

if (...) {
    ...
} else if (...) {
    ...
} else {
    ...
}

with the opening brace on the same line as the statement keyword, and a space between the keyword and the opening (, if any. Of course there are exceptions to this (e.g. splitting long conditions across multiple lines), but in general we follow the example above.

@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
}
while (NULL != inFreqListBlock) {
used -= sizeof(UDATA);
inFreqListBlock = *(UDATA **) inFreqListBlock;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove these spaces. e.g. *(UDATA **) inFreqListBlock; change to *(UDATA **)inFreqListBlock;

typedef struct RAMClassAllocationRequest {
UDATA prefixSize;
UDATA alignment;
UDATA alignedSize;
UDATA *address;
UDATA index;
UDATA fragmentSize;
SegmentKind segmentType;
Copy link
Contributor

Choose a reason for hiding this comment

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

We can also change the variable name to match the type name here.

@@ -1641,7 +1641,7 @@ typedef struct J9MethodParametersData {
J9MethodParameter parameters;
} J9MethodParametersData;

#if defined(__xlC__) || defined(__ibmxl__) || defined(__open_xl__) || defined(__GNUC__) || defined(_MSC_VER) || defined(J9ZOS390) || defined(LINUX) || defined(AIXPPC) || defined(WIN32)
#if defined(__xlC__) || defined(__ibmxl__) || defined(__GNUC__) || defined(_MSC_VER) || defined(J9ZOS390) || defined(LINUX) || defined(AIXPPC) || defined(WIN32)
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll need to be careful when rebasing. You've accidentally included reverts to recent patches that shouldn't be reverted. Please make sure that only the code that you are wanting to change is included in the PR.

@@ -4950,9 +4961,6 @@ typedef struct J9InternalVMFunctions {
void ( *printThreadInfo)(struct J9JavaVM *vm, struct J9VMThread *self, char *toFile, BOOLEAN allThreads) ;
void (JNICALL *initializeAttachedThread)(struct J9VMThread *vmContext, const char *name, j9object_t *group, UDATA daemon, struct J9VMThread *initializee) ;
void ( *initializeMethodRunAddressNoHook)(struct J9JavaVM* vm, J9Method *method) ;
#if defined(J9VM_OPT_SNAPSHOTS)
void ( *initializeMethodRunAddressForSnapshot)(struct J9JavaVM *vm, struct J9Method *method) ;
#endif /* defined(J9VM_OPT_SNAPSHOTS) */
Copy link
Contributor

Choose a reason for hiding this comment

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

Same rebasing comment here. This shouldn't be removed.

continue;
}
if(SUB4G == request->segmentType)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

if(SUB4G == request->segmentType)
{

should be:

if (SUB4G == request->segmentType) {

addBlockToFreeList(classLoader, fragmentAddress, allocationRequests[i].fragmentSize);
UDATA fragmentAddress = ((UDATA)allocationRequests[i].address) - allocationRequests[i].prefixSize;
if(SUB4G == allocationRequests[i].segmentType)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

if(SUB4G == allocationRequests[i].segmentType)
{

should be:

if (SUB4G == allocationRequests[i].segmentType) {

@@ -3828,20 +3849,20 @@ allocateRAMClassFragmentFromFreeList(RAMClassAllocationRequest *request, J9RAMCl
Trc_VM_internalAllocateRAMClass_AllocatedFromFreeList(request->index, freeListBlock, freeListBlock->size, request->address, request->prefixSize, request->alignedSize, request->alignment);

if (islargeBlocksList) {
removeBlockFromLargeFreeList(classLoader, (J9RAMClassFreeListLargeBlock **) freeListBlockPtr, (J9RAMClassFreeListLargeBlock *) freeListBlock);
removeBlockFromLargeFreeList(classLoader, (J9RAMClassFreeListLargeBlock **) freeListBlockPtr, (J9RAMClassFreeListLargeBlock *) freeListBlock, blockType);
Copy link
Contributor

@ThanHenderson ThanHenderson Dec 17, 2024

Choose a reason for hiding this comment

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

Remove spaces between casts and variable names; here and throughout the PR.

@@ -4035,24 +4086,28 @@ internalAllocateRAMClass(J9JavaVM *javaVM, J9ClassLoader *classLoader, RAMClassA

/* Add a new block with the remaining space at the start of this block, if any, to an appropriate free list */
if (0 != alignmentShift) {
addBlockToFreeList(classLoader, (UDATA) allocAddress, alignmentShift);
if(SUB4G == request->segmentType)
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as other ifs


block->nextFreeListBlock = tailBlock;
classLoader->ramClassLargeBlockFreeList = (J9RAMClassFreeListBlock *) block;
blockType->ramClassLargeBlockFreeList = (J9RAMClassFreeListBlock *) block;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should now change blockType to something like freeLists or blockFreeLists.

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
2 participants