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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 69 additions & 16 deletions runtime/jcl/common/mgmtmemory.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,78 @@ Java_com_ibm_java_lang_management_internal_MemoryMXBeanImpl_getNonHeapMemoryUsag
omrthread_monitor_enter(javaVM->classTableMutex);
classLoader = javaVM->internalVMFunctions->allClassLoadersStartDo(&walkState, javaVM, 0);
while (NULL != classLoader) {
UDATA *udataFreeListBlock = classLoader->ramClassUDATABlockFreeList;
J9RAMClassFreeListBlock *tinyFreeListBlock = classLoader->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = classLoader->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = classLoader->ramClassLargeBlockFreeList;
while (NULL != udataFreeListBlock) {
used -= sizeof(UDATA);
udataFreeListBlock = *(UDATA **) udataFreeListBlock;

RamClassUDATABlockFreelist *udataFreeListBlock = &classLoader->ramClassUDATABlocks;
J9RAMClassFreeListBlockType *sub4gFreeListBlock = &classLoader->sub4gBlock;
J9RAMClassFreeListBlockType *freqFreeListBlock = &classLoader->frequentlyAccessedBlock;
J9RAMClassFreeListBlockType *InFreqFreeListBlock = &classLoader->inFrequentlyAccessedBlock;
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...

while (NULL != sub4gListBlock) {
used -= sizeof(UDATA);
sub4gListBlock = *(UDATA **) sub4gListBlock;
}
while (NULL != freqListBlock) {
used -= sizeof(UDATA);
freqListBlock = *(UDATA **) freqListBlock;
}
while (NULL != inFreqListBlock) {
used -= sizeof(UDATA);
inFreqListBlock = *(UDATA **) inFreqListBlock;
}
}
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
if (NULL != sub4gFreeListBlock) {
J9RAMClassFreeListBlock *tinyFreeListBlock = sub4gFreeListBlock->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = sub4gFreeListBlock->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = sub4gFreeListBlock->ramClassLargeBlockFreeList;
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
}
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
if (NULL != freqFreeListBlock) {
J9RAMClassFreeListBlock *tinyFreeListBlock = freqFreeListBlock->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = freqFreeListBlock->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = freqFreeListBlock->ramClassLargeBlockFreeList;
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
}
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
if (NULL != InFreqFreeListBlock) {
J9RAMClassFreeListBlock *tinyFreeListBlock = InFreqFreeListBlock->ramClassTinyBlockFreeList;
J9RAMClassFreeListBlock *smallFreeListBlock = InFreqFreeListBlock->ramClassSmallBlockFreeList;
J9RAMClassFreeListBlock *largeFreeListBlock = InFreqFreeListBlock->ramClassLargeBlockFreeList;
while (NULL != tinyFreeListBlock) {
used -= tinyFreeListBlock->size;
tinyFreeListBlock = tinyFreeListBlock->nextFreeListBlock;
}
while (NULL != smallFreeListBlock) {
used -= smallFreeListBlock->size;
smallFreeListBlock = smallFreeListBlock->nextFreeListBlock;
}
while (NULL != largeFreeListBlock) {
used -= largeFreeListBlock->size;
largeFreeListBlock = largeFreeListBlock->nextFreeListBlock;
}
}
classLoader = javaVM->internalVMFunctions->allClassLoadersNextDo(&walkState);
}
Expand Down
19 changes: 15 additions & 4 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -3563,6 +3563,17 @@ typedef struct J9HookedNative {
} J9HookedNative;

/* @ddr_namespace: map_to_type=J9ClassLoader */
typedef struct J9RAMClassFreeListBlockType {
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.


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?

UDATA* ramClassSub4gUDATABlockFreeList;
UDATA* ramClassFreqUDATABlockFreeList;
UDATA* ramClassInFreqUDATABlockFreeList;
} RamClassUDATABlockFreelist;

typedef struct J9ClassLoader {
struct J9Pool* sharedLibraries;
Expand All @@ -3583,10 +3594,10 @@ typedef struct J9ClassLoader {
#endif /* defined(J9VM_NEEDS_JNI_REDIRECTION) */
struct J9JITExceptionTable* jitMetaDataList;
struct J9MemorySegment* classSegments;
struct J9RAMClassFreeListBlock* ramClassLargeBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassSmallBlockFreeList;
struct J9RAMClassFreeListBlock* ramClassTinyBlockFreeList;
UDATA* ramClassUDATABlockFreeList;
struct J9RAMClassFreeListBlockType sub4gBlock;
struct J9RAMClassFreeListBlockType frequentlyAccessedBlock;
struct J9RAMClassFreeListBlockType inFrequentlyAccessedBlock;
struct RamClassUDATABlockFreelist ramClassUDATABlocks;
struct J9HashTable* redefinedClasses;
struct J9NativeLibrary* librariesHead;
struct J9NativeLibrary* librariesTail;
Expand Down
Loading