-
Notifications
You must be signed in to change notification settings - Fork 750
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
Optimize array access macros to reduce using is-contiguous check #20888
Optimize array access macros to reduce using is-contiguous check #20888
Conversation
38fe9a6
to
b09c9b9
Compare
runtime/oti/j9nonbuilder.h
Outdated
@@ -5647,6 +5655,10 @@ typedef struct J9VMThread { | |||
#endif /* defined(J9VM_OPT_JFR) */ | |||
} J9VMThread; | |||
|
|||
#if defined(J9VM_ENV_DATA64) | |||
#define J9VMTHREAD_ARRAYLET_ENABLED(vmThread) (J9IndexableObjectLayout_ArrayletMask & (vmThread)->indexableObjectLayout) | |||
#define J9VMTHREAD_IS_INDEXBLEDATAADDRPRESENT(vmThread) (J9IndexableObjectLayout_DataAddrMask & (vmThread)->indexableObjectLayout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add extra '_' for easier reading J9VMTHREAD_IS_INDEXBLE_DATAADDR_PRESENT
add 'IS' to J9VMTHREAD_IS_ARRAYLET_ENABLED
runtime/oti/j9nonbuilder.h
Outdated
@@ -6093,7 +6105,8 @@ typedef struct J9JavaVM { | |||
UDATA discontiguousIndexableHeaderSize; | |||
#if defined(J9VM_ENV_DATA64) | |||
U_32 isIndexableDataAddrPresent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is being explicitly used by DDR, let's revert the type back to what was before we put recent Offheap changes and what was also the type the last time we released JVM (which is UDATA)
eventually, we should remove it altogether (but that would need some extra DDR changes to handle cores with and without this field)
87e01b2
to
e94cb71
Compare
runtime/gc_modron_startup/mminit.cpp
Outdated
vm->unsafeIndexableHeaderSize = vm->contiguousIndexableHeaderSize; | ||
} | ||
/* set default unsafeIndexableHeaderSize */ | ||
vm->unsafeIndexableHeaderSize = vm->contiguousIndexableHeaderSize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do changes related to setting unsafeIndexableHeaderSize as a separate PR before we proceed with array access macro changes
that looks like something should have been done as the part of original offheap changes (we should not have queried isVirtualLargeObjectHeapEnabled in a relatively common code path). the new way is cleaner (set default, and override it for offheap enabled on its own specific path)
e94cb71
to
347dfcb
Compare
? (((vmThread)->isVirtualLargeObjectHeapEnabled) \ | ||
? J9JAVAARRAYCONTIGUOUS_WITH_DATAADDRESS_VIRTUALLARGEOBJECTHEAPENABLED_EA(vmThread, array, index, elemType) \ | ||
: J9JAVAARRAYCONTIGUOUS_WITH_DATAADDRESS_VIRTUALLARGEOBJECTHEAPDISABLED_EA(vmThread, array, index, elemType)) \ | ||
: J9JAVAARRAYCONTIGUOUS_BASE_EA(vmThread, array, index, elemType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are removing only usage of two DISABLED
macros above. These macros can be removed.
runtime/oti/j9accessbarrier.h
Outdated
(J9JAVAVM_COMPRESS_OBJECT_REFERENCES(javaVM) \ | ||
? (0 != ((J9IndexableObjectContiguousCompressed *)(array))->size) \ | ||
: (0 != ((J9IndexableObjectContiguousFull *)(array))->size)) | ||
|
||
/* TODO: queries compressed twice - optimize? */ | ||
#define J9JAVAARRAY_EA(vmThread, array, index, elemType) (J9ISCONTIGUOUSARRAY(vmThread, array) ? J9JAVAARRAYCONTIGUOUS_EA(vmThread, array, index, elemType) : J9JAVAARRAYDISCONTIGUOUS_EA(vmThread, array, index, elemType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as we discussed in person, we could optimized 32 bit similarly, although there are only 2 layouts (with and without arraylet and no dataAddr),
but let's do it in a separate change
@@ -108,7 +108,9 @@ MM_Heap * | |||
MM_ConfigurationRealtime::createHeapWithManager(MM_EnvironmentBase *env, uintptr_t heapBytesRequested, MM_HeapRegionManager *regionManager) | |||
{ | |||
MM_GCExtensionsBase *extensions = env->getExtensions(); | |||
|
|||
J9JavaVM *vm = (J9JavaVM *)extensions->getOmrVM()->_language_vm; | |||
/* set indexableObjectLayout = J9IndexableObjectLayout_NoDataAddr_Arraylet (metronome GC)*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code line is fairly self explanatory, but if you want to add a comment let's try be a bit more creative rather than just repeating the code:
"Let VM know that Metronome has discontiguous indexable object (arraylet layout)"
@@ -136,6 +136,9 @@ MM_ConfigurationIncrementalGenerational::createHeapWithManager(MM_EnvironmentBas | |||
|
|||
#if defined(J9VM_ENV_DATA64) | |||
extensions->indexableObjectModel.setIsDataAddressPresent(true); | |||
J9JavaVM *vm = (J9JavaVM *)extensions->getOmrVM()->_language_vm; | |||
/* set indexableObjectLayout = J9IndexableObjectLayout_DataAddr_Arraylet (Balanced GC and off-heap disabled) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, be a more creative, something like:
"Let VM know that indexable objects in Balanced always have dataAddr, and let's assume initially it has arraylets, which can be later overridden if Offheap is Enabled."
/* reset vm->isVirtualLargeObjectHeapEnabled and vm->unsafeIndexableHeaderSize for off-heap case */ | ||
J9JavaVM *vm = (J9JavaVM *)extensions->getOmrVM()->_language_vm; | ||
vm->isVirtualLargeObjectHeapEnabled = TRUE; | ||
/* set indexableObjectLayout = J9IndexableObjectLayout_DataAddr_NoArraylet (Balanced GC and off-heap enabled) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Overriding the original assumption that Balanced has arraylets."
Change the title to be more specific: Optimize array access macros to use is-contiguous check only in presence of arraylets |
347dfcb
to
961b71f
Compare
runtime/oti/j9nonbuilder.h
Outdated
@@ -6347,6 +6357,10 @@ typedef struct J9JavaVM { | |||
#define J9JAVAVM_OBJECT_HEADER_SIZE(vm) (J9JAVAVM_COMPRESS_OBJECT_REFERENCES(vm) ? sizeof(J9ObjectCompressed) : sizeof(J9ObjectFull)) | |||
#define J9JAVAVM_CONTIGUOUS_INDEXABLE_HEADER_SIZE(vm) ((vm)->contiguousIndexableHeaderSize) | |||
#define J9JAVAVM_DISCONTIGUOUS_INDEXABLE_HEADER_SIZE(vm) ((vm)->discontiguousIndexableHeaderSize) | |||
#if defined(J9VM_ENV_DATA64) | |||
#define J9JAVAVM_ARRAYLET_ENABLED(vm) (J9IndexableObjectLayout_ArrayletMask & (vm)->indexableObjectLayout) | |||
#define J9JAVAVM_IS_INDEXBLEDATAADDRPRESENT(vm) (J9IndexableObjectLayout_DataAddrMask & (vm)->indexableObjectLayout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make the name consistent with those that us vmThread
961b71f
to
31701a1
Compare
runtime/oti/j9nonbuilder.h
Outdated
@@ -5540,8 +5547,7 @@ typedef struct J9VMThread { | |||
UDATA contiguousIndexableHeaderSize; | |||
UDATA discontiguousIndexableHeaderSize; | |||
#if defined(J9VM_ENV_DATA64) | |||
UDATA isIndexableDataAddrPresent; | |||
U_32 isVirtualLargeObjectHeapEnabled; | |||
U_32 indexableObjectLayout; /* can be J9IndexableObjectLayout_NoDataAddr_NoArraylet,J9IndexableObjectLayout_DataAddr_NoArraylet, J9IndexableObjectLayout_NoDataAddr_Arraylet, J9IndexableObjectLayout_DataAddr_Arraylet */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either this comment should be shorter, some like "valid values are #define J9IndexableObjectLayout_xyz"
or we don't any comment here (as is the case with other fields) but we comment just above J9IndexableObjectLayout #defines that they are used in indexableObjectLayout field.
(same for J9JavaVM)
runtime/oti/j9accessbarrier.h
Outdated
* if contigious | ||
* contiguous | ||
* else | ||
* discontigous vc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the meaning of 'vc'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was a typo. removed it
31701a1
to
36c306a
Compare
runtime/oti/j9nonbuilder.h
Outdated
@@ -140,6 +140,13 @@ | |||
#define J9ArrayShape32Bit 0x2 | |||
#define J9ArrayShape64Bit 0x3 | |||
|
|||
/* J9IndexableObjectLayout_xxx are used in indexableObjectLayout fieldo */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in 'fieldo' (extra 'o' at the end)
and while you are editing it, add '... field in J9VMThread and J9JavaVM'
Optimize array access macros to use is-contiguous check only in presence of arraylets Along with new offheap feature support, Macro Array Element Access J9JAVAARRAY_EA/J9JAVAARRAY_EA_VM need 1 or 2 more runtime flags check to handle new cases/new structures. extra runtime condition checks in the Macro, which is called in hotspot, could cause certain performance regression in some platforms. especially for standard GC cases, off-heap would not contribute any benefit at all. Optimize Macro J9JAVAARRAY_EA/J9JAVAARRAY_EA_VM to avoid runtime check IsContiguousArray for stamdard GC and balanced GC with off-heap eanable cases, because there is no discontigouos array for these cases(except o size array). 1, replace isVirtualLargeObjectHeapEnabled and isIndexableDataAddrPresent flag with indexableObjectLayout in JavaVM and J9VmThread. 2, indexableObjectLayout have only 4 states J9IndexableObjectLayout_NoDataAddr_NoArraylet 0x0 /* StandardGC case */ J9IndexableObjectLayout_NoDataAddr_Arraylet 0x1 /* Metronome GC case */ J9IndexableObjectLayout_DataAddr_NoArraylet 0x2 /* Balanced GC Offheap enabled case */ J9IndexableObjectLayout_DataAddr_Arraylet 0x3 /* Balanced GC Offheap disabled case */ 3, in Macro J9JAVAARRAY_EA/J9JAVAARRAY_EA_VM, check StandardGC case and Balanced GC Offheap enabled case first in order to reduce runtime condition check for standard GC(Balanced GC Offheap enabled case too), then avoid performance regression(reduce flag numbers in J9VmThread also could help reduce the regression for some platforms). 4, flag isVirtualLargeObjectHeapEnabled and isIndexableDataAddrPresent has been removed from J9VmThread flag isVirtualLargeObjectHeapEnabled has been removed from JavaVM (we still keep flag isIndexableDataAddrPresent in JavaVM for minimizing the changes). Signed-off-by: lhu <[email protected]>
36c306a
to
cd7ba08
Compare
jenkins test sanity aix jdk21 |
DDR needs to be updated to adapt to the removal of the field |
isIndexableDataAddrPresent was removed only from J9VMThread (and that one was not referenced by DDR), but not from J9JavaVM. |
Sorry, you're right, |
Optimize array access macros to use is-contiguous check only in presence
of arraylets
Along with new offheap feature support, Macro Array Element Access
J9JAVAARRAY_EA/J9JAVAARRAY_EA_VM need 1 or 2 more runtime flags check to
handle new cases/new structures. extra runtime condition checks in the
Macro, which is called in hotspot, could cause certain performance
regression in some platforms. especially for standard GC cases, off-heap
would not contribute any benefit at all.
Optimize Macro J9JAVAARRAY_EA/J9JAVAARRAY_EA_VM to avoid runtime check
IsContiguousArray for stamdard GC and balanced GC with off-heap eanable
cases, because there is no discontigouos array for these cases(except o
size array).
1, replace isVirtualLargeObjectHeapEnabled and
isIndexableDataAddrPresent flag with indexableObjectLayout in JavaVM and
J9VmThread.
2, indexableObjectLayout have only 4 states
J9IndexableObjectLayout_NoDataAddr_NoArraylet 0x0 /* StandardGC case /
J9IndexableObjectLayout_NoDataAddr_Arraylet 0x1 / Metronome GC case /
J9IndexableObjectLayout_DataAddr_NoArraylet 0x2 / Balanced GC Offheap
enabled case /
J9IndexableObjectLayout_DataAddr_Arraylet 0x3 / Balanced GC Offheap
disabled case */
3, in Macro J9JAVAARRAY_EA/J9JAVAARRAY_EA_VM, check StandardGC case and
Balanced GC Offheap enabled case first in order to reduce runtime
condition check for standard GC(Balanced GC Offheap enabled case too),
then avoid performance regression(reduce flag numbers in J9VmThread
also could help reduce the regression for some platforms).
4, flag isVirtualLargeObjectHeapEnabled and isIndexableDataAddrPresent
has been removed from J9VmThread
flag isVirtualLargeObjectHeapEnabled has been removed from JavaVM (we
still keep flag isIndexableDataAddrPresent in JavaVM for minimizing the
changes).
Signed-off-by: lhu [email protected]