Skip to content

Commit a44a2cc

Browse files
committed
Add JFR GCTLABConfiguration Event
This change add support for the JFR GC TLAB Configuration Event. Signed-off-by: Adrian Popescu <adpopescu@ibm.com>
1 parent 7d59d0f commit a44a2cc

12 files changed

Lines changed: 146 additions & 0 deletions

File tree

runtime/gc/gctable.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ J9MemoryManagerFunctions MemoryManagerFunctions = {
118118
j9gc_get_softmx,
119119
j9gc_get_initial_heap_size,
120120
j9gc_get_maximum_heap_size,
121+
j9gc_get_tlh_minimum_size,
122+
j9gc_get_tlh_initial_size,
123+
j9gc_is_tlab_enabled,
121124
j9gc_get_minimum_young_generation_size,
122125
j9gc_get_maximum_young_generation_size,
123126
j9gc_objaccess_checkClassLive,

runtime/gc_base/gc_internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ extern J9_CFUNC jint JNICALL queryGCStatus(JavaVM *vm, jint *nHeaps, GCStatus *
139139
extern J9_CFUNC int j9gc_finalizer_startup(J9JavaVM * vm);
140140
extern J9_CFUNC UDATA j9gc_wait_for_reference_processing(J9JavaVM *vm);
141141
extern J9_CFUNC UDATA j9gc_get_maximum_heap_size(J9JavaVM *javaVM);
142+
extern J9_CFUNC UDATA j9gc_get_tlh_minimum_size(J9JavaVM *javaVM);
143+
extern J9_CFUNC UDATA j9gc_get_tlh_initial_size(J9JavaVM *javaVM);
144+
extern J9_CFUNC BOOLEAN j9gc_is_tlab_enabled(J9JavaVM *javaVM);
142145
extern J9_CFUNC void* j9gc_get_heap_base(J9JavaVM *javaVM);
143146
extern J9_CFUNC void* j9gc_get_heap_top(J9JavaVM *javaVM);
144147
extern J9_CFUNC UDATA j9gc_get_minimum_young_generation_size(J9JavaVM *javaVM);

runtime/gc_base/modronapi.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,35 @@ j9gc_get_maximum_heap_size(J9JavaVM *javaVM)
856856
return size;
857857
}
858858

859+
/**
860+
* API to return the minimum TLH (Thread Local Heap) size.
861+
*/
862+
UDATA
863+
j9gc_get_tlh_minimum_size(J9JavaVM *javaVM)
864+
{
865+
return MM_GCExtensions::getExtensions(javaVM)->tlhMinimumSize;
866+
}
867+
868+
/**
869+
* API to return the initial TLH (Thread Local Heap) size.
870+
*/
871+
UDATA
872+
j9gc_get_tlh_initial_size(J9JavaVM *javaVM)
873+
{
874+
return MM_GCExtensions::getExtensions(javaVM)->tlhInitialSize;
875+
}
876+
877+
/**
878+
* API to return whether TLH allocation is enabled.
879+
*/
880+
BOOLEAN
881+
j9gc_is_tlab_enabled(J9JavaVM *javaVM)
882+
{
883+
uintptr_t allocType = 0;
884+
UDATA found = javaVM->memoryManagerFunctions->j9gc_modron_getConfigurationValueForKey(javaVM, j9gc_modron_configuration_allocationType, &allocType);
885+
return (found && (j9gc_modron_allocation_type_tlh == allocType)) ? TRUE : FALSE;
886+
}
887+
859888
/**
860889
* API to return the heap base address
861890
*/

runtime/gc_base/modronapi.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ UDATA j9gc_set_softmx(J9JavaVM *javaVM, UDATA newsoftMx);
8585
UDATA j9gc_get_softmx(J9JavaVM *javaVM);
8686
UDATA j9gc_get_initial_heap_size(J9JavaVM *javaVM);
8787
UDATA j9gc_get_maximum_heap_size(J9JavaVM *javaVM);
88+
UDATA j9gc_get_tlh_minimum_size(J9JavaVM *javaVM);
89+
UDATA j9gc_get_tlh_initial_size(J9JavaVM *javaVM);
90+
BOOLEAN j9gc_is_tlab_enabled(J9JavaVM *javaVM);
8891
void *j9gc_get_heap_base(J9JavaVM *javaVM);
8992
void *j9gc_get_heap_top(J9JavaVM *javaVM);
9093
UDATA j9gc_get_minimum_young_generation_size(J9JavaVM *javaVM);

runtime/oti/j9consts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ extern "C" {
10121012
#define J9JFR_EVENT_TYPE_NATIVE_LIBRARY 32
10131013
#define J9JFR_EVENT_TYPE_THREAD_DUMP 33
10141014
#define J9JFR_EVENT_TYPE_THREAD_ALLOCATION_STATISTICS 34
1015+
#define J9JFR_EVENT_TYPE_GC_TLAB_CONFIGURATION 36
10151016

10161017
/* JFR thread states. */
10171018

runtime/oti/j9nonbuilder.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,13 @@ typedef struct J9JFRThreadAllocationStatistics {
590590
U_64 allocated;
591591
} J9JFRThreadAllocationStatistics;
592592

593+
typedef struct J9JFRGCTLABConfiguration {
594+
J9JFR_EVENT_COMMON_FIELDS
595+
BOOLEAN usesTLABs;
596+
U_64 minTLABSize;
597+
U_64 tlabRefillWasteLimit;
598+
} J9JFRGCTLABConfiguration;
599+
593600
#endif /* defined(J9VM_OPT_JFR) */
594601

595602
/* @ddr_namespace: map_to_type=J9CfrError */
@@ -5044,6 +5051,9 @@ typedef struct J9MemoryManagerFunctions {
50445051
UDATA ( *j9gc_get_softmx)(struct J9JavaVM *javaVM) ;
50455052
UDATA ( *j9gc_get_initial_heap_size)(struct J9JavaVM *javaVM) ;
50465053
UDATA ( *j9gc_get_maximum_heap_size)(struct J9JavaVM *javaVM) ;
5054+
UDATA ( *j9gc_get_tlh_minimum_size)(struct J9JavaVM *javaVM) ;
5055+
UDATA ( *j9gc_get_tlh_initial_size)(struct J9JavaVM *javaVM) ;
5056+
BOOLEAN ( *j9gc_is_tlab_enabled)(struct J9JavaVM *javaVM) ;
50475057
UDATA ( *j9gc_get_minimum_young_generation_size)(struct J9JavaVM *javaVM) ;
50485058
UDATA ( *j9gc_get_maximum_young_generation_size)(struct J9JavaVM *javaVM) ;
50495059
UDATA ( *j9gc_objaccess_checkClassLive)(struct J9JavaVM *javaVM, J9Class *classPtr) ;

runtime/vm/JFRChunkWriter.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,33 @@ VM_JFRChunkWriter::writeYoungGenerationConfigurationEvent()
10041004
writeEventSize(dataStart);
10051005
}
10061006

1007+
void
1008+
VM_JFRChunkWriter::writeGCTLABConfigurationEvent()
1009+
{
1010+
GCTLABConfigurationEntry *tlabConfig = &(VM_JFRConstantPoolTypes::getJFRConstantEvents(_vm)->GCTLABConfigEntry);
1011+
1012+
/* reserve size field */
1013+
U_8 *dataStart = reserveEventSize();
1014+
1015+
/* write event type */
1016+
_bufferWriter->writeLEB128(GCTLABConfigurationID);
1017+
1018+
/* write event start time */
1019+
_bufferWriter->writeLEB128(j9time_nano_time());
1020+
1021+
/* write whether TLABs are in use */
1022+
_bufferWriter->writeBoolean(tlabConfig->usesTLABs);
1023+
1024+
/* write minimum TLAB size */
1025+
_bufferWriter->writeLEB128(tlabConfig->minTLABSize);
1026+
1027+
/* write TLAB refill waste limit */
1028+
_bufferWriter->writeLEB128(tlabConfig->tlabRefillWasteLimit);
1029+
1030+
/* write event size */
1031+
writeEventSize(dataStart);
1032+
}
1033+
10071034
void
10081035
VM_JFRChunkWriter::writeInitialSystemPropertyEvents(J9JavaVM *vm)
10091036
{

runtime/vm/JFRChunkWriter.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ enum MetadataTypeID {
122122
NativeLibraryID = 112,
123123
ModuleRequireID = 113,
124124
ModuleExportID = 114,
125+
GCTLABConfigurationID = 132,
125126
GCHeapConfigID = 133,
126127
YoungGenerationConfigID = 134,
127128
VirtualSpaceID = 149,
@@ -509,6 +510,8 @@ class VM_JFRChunkWriter {
509510
writeGCHeapConfigurationEvent();
510511

511512
writeYoungGenerationConfigurationEvent();
513+
514+
writeGCTLABConfigurationEvent();
512515
}
513516

514517
writePhysicalMemoryEvent();
@@ -545,6 +548,10 @@ class VM_JFRChunkWriter {
545548
writeYoungGenerationConfigurationEvent();
546549
}
547550

551+
if (_constantPoolTypes.shouldWriteGCTLABConfigurationEvent()) {
552+
writeGCTLABConfigurationEvent();
553+
}
554+
548555
if (_constantPoolTypes.shouldWritePhysicalMemory()) {
549556
writePhysicalMemoryEvent();
550557
}
@@ -953,6 +960,8 @@ class VM_JFRChunkWriter {
953960

954961
void writeYoungGenerationConfigurationEvent();
955962

963+
void writeGCTLABConfigurationEvent();
964+
956965
void writeInitialSystemPropertyEvents(J9JavaVM *vm);
957966

958967
void writeInitialEnvironmentVariableEvents();

runtime/vm/JFRConstantPoolTypes.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,12 @@ struct YoungGenerationConfigurationEntry {
439439
U_64 newRatio;
440440
};
441441

442+
struct GCTLABConfigurationEntry {
443+
BOOLEAN usesTLABs;
444+
U_64 minTLABSize;
445+
U_64 tlabRefillWasteLimit;
446+
};
447+
442448
struct VirtualizationInformationEntry {
443449
const char *name;
444450
};
@@ -474,6 +480,7 @@ struct JFRConstantEvents {
474480
OSInformationEntry OSInfoEntry;
475481
GCHeapConfigurationEntry GCHeapConfigEntry;
476482
YoungGenerationConfigurationEntry YoungGenConfigEntry;
483+
GCTLABConfigurationEntry GCTLABConfigEntry;
477484
};
478485

479486
class VM_JFRConstantPoolTypes {
@@ -579,6 +586,7 @@ class VM_JFRConstantPoolTypes {
579586
bool _shouldWriteModuleRequire;
580587
bool _shouldWriteModuleExport;
581588
bool _shouldWriteClassLoaderStatistics;
589+
bool _shouldWriteGCTLABConfigurationEvent;
582590

583591
/* Processing buffers */
584592
StackFrame *_currentStackFrameBuffer;
@@ -1314,6 +1322,11 @@ class VM_JFRConstantPoolTypes {
13141322
return _shouldWriteYoungGenerationConfigurationEvent;
13151323
}
13161324

1325+
bool shouldWriteGCTLABConfigurationEvent()
1326+
{
1327+
return _shouldWriteGCTLABConfigurationEvent;
1328+
}
1329+
13171330
bool shouldWritePhysicalMemory()
13181331
{
13191332
return _shouldWritePhysicalMemory;
@@ -1474,6 +1487,9 @@ class VM_JFRConstantPoolTypes {
14741487
case J9JFR_EVENT_TYPE_THREAD_ALLOCATION_STATISTICS:
14751488
addThreadAllocationStatistics((J9JFRThreadAllocationStatistics *)event);
14761489
break;
1490+
case J9JFR_EVENT_TYPE_GC_TLAB_CONFIGURATION:
1491+
_shouldWriteGCTLABConfigurationEvent = true;
1492+
break;
14771493
default:
14781494
Assert_VM_unreachable();
14791495
break;
@@ -1569,6 +1585,7 @@ class VM_JFRConstantPoolTypes {
15691585
initializeOSInformation(vm, result);
15701586
initializeGCHeapConfigurationEvent(vm);
15711587
initializeYoungGenerationConfigurationEvent(vm);
1588+
initializeGCTLABConfigurationEvent(vm);
15721589
}
15731590

15741591
/**
@@ -1828,6 +1845,26 @@ class VM_JFRConstantPoolTypes {
18281845
}
18291846
}
18301847

1848+
/**
1849+
* Initialize GCTLABConfigurationEntry
1850+
*
1851+
* @param vm[in] the J9JavaVM
1852+
*/
1853+
static void initializeGCTLABConfigurationEvent(J9JavaVM *vm)
1854+
{
1855+
J9MemoryManagerFunctions *mmFuncs = vm->memoryManagerFunctions;
1856+
GCTLABConfigurationEntry *tlabConfiguration = &(getJFRConstantEvents(vm)->GCTLABConfigEntry);
1857+
1858+
tlabConfiguration->usesTLABs = mmFuncs->j9gc_is_tlab_enabled(vm);
1859+
tlabConfiguration->minTLABSize = mmFuncs->j9gc_get_tlh_minimum_size(vm);
1860+
/* The closest OMR equivalent to tlabRefillWasteLimit is the
1861+
* initial value of abandonSize in TLHAllocationSupport::refresh(), which
1862+
* evaluates to max(tlhMinimumSize, tlhInitialSize / 2) on a fresh thread.
1863+
* We report tlhInitialSize / 2 as it dominates once refreshSize >= tlhInitialSize.
1864+
*/
1865+
tlabConfiguration->tlabRefillWasteLimit = mmFuncs->j9gc_get_tlh_initial_size(vm) / 2;
1866+
}
1867+
18311868
static uintptr_t recordSystemProcessEvent(uintptr_t pid, const char *commandLine, void *userData)
18321869
{
18331870
VM_JFRConstantPoolTypes *constantPoolTypes = reinterpret_cast<VM_JFRConstantPoolTypes *>(userData);
@@ -2246,6 +2283,7 @@ class VM_JFRConstantPoolTypes {
22462283
, _shouldWriteModuleRequire(false)
22472284
, _shouldWriteModuleExport(false)
22482285
, _shouldWriteClassLoaderStatistics(false)
2286+
, _shouldWriteGCTLABConfigurationEvent(false)
22492287
, _previousStackTraceEntry(NULL)
22502288
, _firstStackTraceEntry(NULL)
22512289
, _previousThreadEntry(NULL)

runtime/vm/JFRPeriodic.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class JfrPeriodicEventSet {
5353
static void requestThreadDump(J9VMThread *currentThread);
5454
static void requestVirtualizationInformation(J9VMThread *currentThread);
5555
static void requestYoungGenerationConfiguration(J9VMThread *currentThread);
56+
static void requestGCTLABConfiguration(J9VMThread *currentThread);
5657
};
5758

5859
#endif /* !defined(JFRPERIODIC_HPP_) */

0 commit comments

Comments
 (0)