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 3 commits into
base: master
Choose a base branch
from

Conversation

h3110n3rv3
Copy link
Contributor

The changes reflect the feature request #20644.

Adding segment categories

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.

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