Skip to content

Commit

Permalink
Add j9gc_get_cumulative_class_unloading_stats()
Browse files Browse the repository at this point in the history
Add external GC function to report cumulative class unloading stats.
Use general API to update counters in class unloading stats.

Signed-off-by: Dmitri Pivkine <[email protected]>
  • Loading branch information
dmitripivkine authored and Aleksandar Micic committed Nov 25, 2024
1 parent be066e8 commit 305f0ee
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions runtime/gc/gctable.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ J9MemoryManagerFunctions MemoryManagerFunctions = {
#endif /* J9VM_GC_OBJECT_ACCESS_BARRIER */
j9gc_get_bytes_allocated_by_thread,
j9gc_get_cumulative_bytes_allocated_by_thread,
j9gc_get_cumulative_class_unloading_stats,
j9mm_iterate_all_ownable_synchronizer_objects,
j9mm_iterate_all_continuation_objects,
ownableSynchronizerObjectCreated,
Expand Down
4 changes: 1 addition & 3 deletions runtime/gc_base/ClassLoaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,7 @@ MM_ClassLoaderManager::cleanUpClassLoadersStart(MM_EnvironmentBase *env, J9Class
TRIGGER_J9HOOK_VM_CLASS_LOADERS_UNLOAD(_javaVM->hookInterface, vmThread, classLoaderUnloadList);
}

classUnloadStats->_classesUnloadedCount = classUnloadCount;
classUnloadStats->_classLoaderUnloadedCount = classLoaderUnloadCount;
classUnloadStats->_anonymousClassesUnloadedCount = anonymousClassUnloadCount;
classUnloadStats->updateUnloadedCounters(anonymousClassUnloadCount, classUnloadCount, classLoaderUnloadCount);

/* Ensure that the vm has an accurate number of currently loaded anonymous classes */
_javaVM->anonClassCount -= anonymousClassUnloadCount;
Expand Down
1 change: 1 addition & 0 deletions runtime/gc_base/gc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ extern BOOLEAN j9gc_stringHashEqualFn (void *leftKey, void *rightKey, void *user
/* modronapi.cpp */
extern J9_CFUNC UDATA j9gc_get_bytes_allocated_by_thread(J9VMThread* vmThread);
extern J9_CFUNC BOOLEAN j9gc_get_cumulative_bytes_allocated_by_thread(J9VMThread *vmThread, UDATA *cumulativeValue);
extern J9_CFUNC BOOLEAN j9gc_get_cumulative_class_unloading_stats(J9VMThread *vmThread, UDATA *anonymous, UDATA *classes, UDATA *classloaders);

#ifdef __cplusplus
}
Expand Down
14 changes: 14 additions & 0 deletions runtime/gc_base/modronapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,20 @@ j9gc_get_cumulative_bytes_allocated_by_thread(J9VMThread *vmThread, UDATA *cumul
return MM_EnvironmentBase::getEnvironment(vmThread->omrVMThread)->_objectAllocationInterface->getAllocationStats()->bytesAllocatedCumulative(cumulativeValue);
}

/**
* @param[in] vmThread the vmThread we are querying about
* @param[out] anonymous cumulative value pointer for unloaded anonymous classes
* @param[out] classes cumulative value pointer for unloaded classes (including anonymous)
* @param[out] classloaders cumulative value pointer for unloaded classesloaders
*/
BOOLEAN
j9gc_get_cumulative_class_unloading_stats(J9VMThread *vmThread, UDATA *anonymous, UDATA *classes, UDATA *classloaders)
{
MM_GCExtensions *ext = MM_GCExtensions::getExtensions(vmThread->javaVM);
ext->globalGCStats.classUnloadStats.getUnloadedCountersCumulative(anonymous, classes, classloaders);
return true;
}

/**
* Return information about the total CPU time consumed by GC threads, as well
* as the number of GC threads. The time for the main and worker threads is
Expand Down
5 changes: 2 additions & 3 deletions runtime/gc_glue_java/MetronomeDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,9 +615,8 @@ MM_MetronomeDelegate::updateClassUnloadStats(MM_EnvironmentBase *env, UDATA clas
MM_ClassUnloadStats *classUnloadStats = &_extensions->globalGCStats.classUnloadStats;

/* TODO CRGTMP move global stats into super class implementation once it is created */
classUnloadStats->_classesUnloadedCount = classUnloadCount;
classUnloadStats->_anonymousClassesUnloadedCount = anonymousClassUnloadCount;
classUnloadStats->_classLoaderUnloadedCount = classLoaderUnloadCount;
classUnloadStats->updateUnloadedCounters(anonymousClassUnloadCount, classUnloadCount, classLoaderUnloadCount);


/* Record increment stats */
_extensions->globalGCStats.metronomeStats.classesUnloadedCount = classUnloadCount;
Expand Down
1 change: 1 addition & 0 deletions runtime/oti/j9nonbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -4801,6 +4801,7 @@ typedef struct J9MemoryManagerFunctions {
#endif /* defined(J9VM_GC_OBJECT_ACCESS_BARRIER) */
UDATA ( *j9gc_get_bytes_allocated_by_thread)(struct J9VMThread *vmThread) ;
BOOLEAN ( *j9gc_get_cumulative_bytes_allocated_by_thread)(struct J9VMThread *vmThread, UDATA *cumulativeValue) ;
BOOLEAN ( *j9gc_get_cumulative_class_unloading_stats)(struct J9VMThread *vmThread, UDATA *anonumous, UDATA *classes, UDATA *classloaders) ;

jvmtiIterationControl ( *j9mm_iterate_all_ownable_synchronizer_objects)(struct J9VMThread *vmThread, J9PortLibrary *portLibrary, UDATA flags, jvmtiIterationControl (*func)(struct J9VMThread *vmThread, struct J9MM_IterateObjectDescriptor *object, void *userData), void *userData) ;
jvmtiIterationControl ( *j9mm_iterate_all_continuation_objects)(struct J9VMThread *vmThread, J9PortLibrary *portLibrary, UDATA flags, jvmtiIterationControl (*func)(struct J9VMThread *vmThread, struct J9MM_IterateObjectDescriptor *object, void *userData), void *userData) ;
Expand Down

0 comments on commit 305f0ee

Please sign in to comment.