Skip to content

Commit

Permalink
Cumulative thread allocation stats
Browse files Browse the repository at this point in the history
Provide API to return allocation bytes since the start of VM. Return
false if the sum rolls over.

Signed-off-by: Aleksandar Micic <[email protected]>
  • Loading branch information
Aleksandar Micic authored and Aleksandar Micic committed Sep 13, 2023
1 parent f8fecbe commit d63a4e4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gc/stats/AllocationStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
void
MM_AllocationStats::clear()
{
/* calculate cumulative stats before any clear */
_allocationBytesCumulative += bytesAllocated();


#if defined(OMR_GC_THREAD_LOCAL_HEAP)
_tlhRefreshCountFresh = 0;
_tlhRefreshCountReused = 0;
Expand Down
13 changes: 13 additions & 0 deletions gc/stats/AllocationStats.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class MM_AllocationStats : public MM_Base

uintptr_t _allocationCount;
uintptr_t _allocationBytes;
uintptr_t _allocationBytesCumulative; /**< cumulative allocation up to last clear, excluding since last clear */
uintptr_t _ownableSynchronizerObjectCount; /**< Number of Ownable Synchronizer Object allocations */
uintptr_t _continuationObjectCount; /**< Number of Continuation Object allocations */
uintptr_t _discardedBytes;
Expand Down Expand Up @@ -86,6 +87,18 @@ class MM_AllocationStats : public MM_Base
return totalBytesAllocated;
}

bool bytesAllocatedCumulative(uintptr_t *cumulativeValue) {
if (NULL != cumulativeValue) {
/* sum the values up to last clear and since last clear */
*cumulativeValue = _allocationBytesCumulative + bytesAllocated();

/* return false if overflowing */
return (_allocationBytesCumulative <= *cumulativeValue);
}

return false;
}

MM_AllocationStats() :
#if defined(OMR_GC_THREAD_LOCAL_HEAP)
_tlhRefreshCountFresh(0),
Expand Down

0 comments on commit d63a4e4

Please sign in to comment.