Skip to content

Commit

Permalink
Merge pull request #187 from tajila/master
Browse files Browse the repository at this point in the history
(0.41) Cumulative thread allocation stats
  • Loading branch information
pshipton authored Nov 9, 2023
2 parents d2c4b12 + 60868a0 commit 6640e5c
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 6640e5c

Please sign in to comment.