Skip to content

Commit

Permalink
Merge pull request eclipse-omr#7116 from amicic/cumulative_thread_all…
Browse files Browse the repository at this point in the history
…ocation

Cumulative thread allocation stats
  • Loading branch information
babsingh authored Sep 14, 2023
2 parents f8fecbe + d63a4e4 commit edcb5c6
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 edcb5c6

Please sign in to comment.