Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve assertion output for large object stats #3589

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gc/base/MemoryPoolSplitAddressOrderedListBase.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -186,7 +186,7 @@ MM_MemoryPoolSplitAddressOrderedListBase::initialize(MM_EnvironmentBase* env)
return false;
} else {
for (uintptr_t i = 0; i < _heapFreeListCountExtended; ++i) {
new (&_largeObjectAllocateStatsForFreeList[i]) MM_LargeObjectAllocateStats();
new (&_largeObjectAllocateStatsForFreeList[i]) MM_LargeObjectAllocateStats(env);

/* set multiple factor = 2 for doubling _maxVeryLargeEntrySizes to avoid run out of _veryLargeEntryPool (minus count during decrement) */
if (!_largeObjectAllocateStatsForFreeList[i].initialize(env, (uint16_t)extensions->largeObjectAllocationProfilingTopK, extensions->largeObjectAllocationProfilingThreshold, extensions->largeObjectAllocationProfilingVeryLargeObjectThreshold, (float)extensions->largeObjectAllocationProfilingSizeClassRatio / (float)100.0,
Expand Down
27 changes: 13 additions & 14 deletions gc/stats/LargeObjectAllocateStats.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2016 IBM Corp. and others
* Copyright (c) 2012, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -489,7 +489,7 @@ MM_LargeObjectAllocateStats::newInstance(MM_EnvironmentBase *env, uint16_t maxAl
largeObjectAllocateStats = (MM_LargeObjectAllocateStats *)env->getForge()->allocate(sizeof(MM_LargeObjectAllocateStats), OMR::GC::AllocationCategory::FIXED, OMR_GET_CALLSITE());

if(NULL != largeObjectAllocateStats) {
new(largeObjectAllocateStats) MM_LargeObjectAllocateStats();
new(largeObjectAllocateStats) MM_LargeObjectAllocateStats(env);

if(!largeObjectAllocateStats->initialize(env, maxAllocateSizes, largeObjectThreshold, veryLargeObjectThreshold, sizeClassRatio, maxHeapSize, tlhMaximumSize, tlhMinimumSize, factorVeryLargeEntryPool)) {
largeObjectAllocateStats->kill(env);
Expand All @@ -503,7 +503,7 @@ MM_LargeObjectAllocateStats::newInstance(MM_EnvironmentBase *env, uint16_t maxAl
bool
MM_LargeObjectAllocateStats::initialize(MM_EnvironmentBase *env, uint16_t maxAllocateSizes, uintptr_t largeObjectThreshold, uintptr_t veryLargeObjectThreshold, float sizeClassRatio, uintptr_t maxHeapSize, uintptr_t tlhMaximumSize, uintptr_t tlhMinimumSize, uintptr_t factorVeryLargeEntryPool)
{
_portLibrary = env->getPortLibrary();
OMRPortLibrary *portLibrary = env->getPortLibrary();
#if defined(OMR_GC_THREAD_LOCAL_HEAP)
_tlhMaximumSize = tlhMaximumSize;
_tlhMinimumSize = tlhMinimumSize;
Expand All @@ -516,23 +516,23 @@ MM_LargeObjectAllocateStats::initialize(MM_EnvironmentBase *env, uint16_t maxAll

/* To accurately maintain for stats for top _maxAllocateSizes different sizes,
* we'll actually maintain stats for 2x more, and discard info for lower 1/2 */
if (NULL == (_spaceSavingSizes = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) {
if (NULL == (_spaceSavingSizes = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) {
return false;
}

if (NULL == (_spaceSavingSizeClasses = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) {
if (NULL == (_spaceSavingSizeClasses = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) {
return false;
}

if (NULL == (_spaceSavingSizesAveragePercent = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) {
if (NULL == (_spaceSavingSizesAveragePercent = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) {
return false;
}

if (NULL == (_spaceSavingSizeClassesAveragePercent = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) {
if (NULL == (_spaceSavingSizeClassesAveragePercent = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) {
return false;
}

if (NULL == (_spaceSavingTemp = spaceSavingNew(_portLibrary, _maxAllocateSizes * 2))) {
if (NULL == (_spaceSavingTemp = spaceSavingNew(portLibrary, _maxAllocateSizes * 2))) {
return false;
}

Expand Down Expand Up @@ -1553,16 +1553,15 @@ MM_LargeObjectAllocateStats::getSizeClassIndex(uintptr_t size)
* a Linux kernel on problematic machine
*/

/* the logarithm for integer can not be negative! */
Assert_MM_true(logValue >= 0.0);

/* CMVC 194170 (remove when resolved) */
Assert_MM_true(0.0 != _sizeClassRatioLog);
/* the logarithm can not be negative! */
Assert_GC_true_with_message2(_env, (logValue >= 0.0), "Error calculation log(), passed %zu, returned %f\n", size, logValue);
Assert_GC_true_with_message(_env, (_sizeClassRatioLog > 0.0), "_sizeClassRatioLog is %f but must be larger then zero\n", _sizeClassRatioLog);

uintptr_t result = (uintptr_t)(logValue / _sizeClassRatioLog);

/* the logarithm value is larger then we can accept - probably larger then log(UDATA_MAX) */
Assert_MM_true((_freeEntrySizeClassStats._maxSizeClasses == 0) || (result < _freeEntrySizeClassStats._maxSizeClasses));
Assert_GC_true_with_message2(_env, ((_freeEntrySizeClassStats._maxSizeClasses == 0) || (result < _freeEntrySizeClassStats._maxSizeClasses)),
"Calculated value of getSizeClassIndex() %zu can not be larger then maximum %zu\n", result, _freeEntrySizeClassStats._maxSizeClasses);

return result;
}
Expand Down
8 changes: 4 additions & 4 deletions gc/stats/LargeObjectAllocateStats.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2016 IBM Corp. and others
* Copyright (c) 2012, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -148,7 +148,7 @@ class MM_FreeEntrySizeClassStats {
class MM_LargeObjectAllocateStats : public MM_Base {
public:
private:
OMRPortLibrary *_portLibrary;
MM_EnvironmentBase *_env; /**< cached thread environment */
#if defined(OMR_GC_THREAD_LOCAL_HEAP)
uintptr_t _tlhMaximumSize; /**< cached value of _tlhMaximumSize */
uintptr_t _tlhMinimumSize; /**< cached value of _tlhMinimumSize */
Expand Down Expand Up @@ -325,8 +325,8 @@ class MM_LargeObjectAllocateStats : public MM_Base {
uintptr_t getFreeMemoryBeforeEstimate() { return _freeMemoryBeforeEstimate; }
uintptr_t getMaxHeapSize() {return _maxHeapSize; }

MM_LargeObjectAllocateStats() :
_portLibrary(NULL),
MM_LargeObjectAllocateStats(MM_EnvironmentBase* env) :
_env(env),
#if defined(OMR_GC_THREAD_LOCAL_HEAP)
_tlhMaximumSize(0),
_tlhMinimumSize(0),
Expand Down