diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonArguments.cpp --- a/src/hotspot/share/gc/epsilon/epsilonArguments.cpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonArguments.cpp Thu May 31 16:09:17 2018 +0200 @@ -30,6 +30,7 @@ #include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" #include "runtime/vm_version.hpp" +#include "utilities/macros.hpp" size_t EpsilonArguments::conservative_max_heap_alignment() { return UseLargePages ? os::large_page_size() : os::vm_page_size(); @@ -45,7 +46,6 @@ FLAG_SET_DEFAULT(ExitOnOutOfMemoryError, true); } -#if INCLUDE_EPSILONGC if (EpsilonMaxTLABSize < MinTLABSize) { warning("EpsilonMaxTLABSize < MinTLABSize, adjusting it to " SIZE_FORMAT, MinTLABSize); EpsilonMaxTLABSize = MinTLABSize; @@ -55,7 +55,6 @@ warning("Disabling EpsilonElasticTLABDecay because EpsilonElasticTLAB is disabled"); FLAG_SET_DEFAULT(EpsilonElasticTLABDecay, false); } -#endif #ifdef COMPILER2 // Enable loop strip mining: there are still non-GC safepoints, no need to make it worse diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonBarrierSet.cpp --- a/src/hotspot/share/gc/epsilon/epsilonBarrierSet.cpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonBarrierSet.cpp Thu May 31 16:09:17 2018 +0200 @@ -28,6 +28,7 @@ #include "gc/shared/collectorPolicy.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/barrierSetAssembler.hpp" +#include "utilities/macros.hpp" #ifdef COMPILER1 #include "gc/shared/c1/barrierSetC1.hpp" #endif diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonBarrierSet.hpp --- a/src/hotspot/share/gc/epsilon/epsilonBarrierSet.hpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonBarrierSet.hpp Thu May 31 16:09:17 2018 +0200 @@ -24,7 +24,6 @@ #ifndef SHARE_VM_GC_EPSILON_BARRIERSET_HPP #define SHARE_VM_GC_EPSILON_BARRIERSET_HPP -#include "gc/shared/collectorPolicy.hpp" #include "gc/shared/barrierSetAssembler.hpp" #include "gc/shared/barrierSet.hpp" diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonHeap.cpp --- a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp Thu May 31 16:09:17 2018 +0200 @@ -48,7 +48,7 @@ // Precompute hot fields _max_tlab_size = MIN2(CollectedHeap::max_tlab_size(), EpsilonMaxTLABSize / HeapWordSize); _step_counter_update = MIN2(max_byte_size / 16, EpsilonUpdateCountersStep); - _step_heap_print = (EpsilonPrintHeapStep == 0) ? SIZE_MAX : (max_byte_size / EpsilonPrintHeapStep); + _step_heap_print = (EpsilonPrintHeapSteps == 0) ? SIZE_MAX : (max_byte_size / EpsilonPrintHeapSteps); _decay_time_ns = (int64_t) EpsilonTLABDecayTime * NANOSECS_PER_MILLISEC; // Enable monitoring @@ -144,18 +144,27 @@ res = _space->par_allocate(size); } + size_t used = _space->used(); + // Allocation successful, update counters - size_t used = _space->used(); - if (used - _last_counter_update >= _step_counter_update) { - _last_counter_update = used; - _monitoring_support->update_counters(); + { + size_t last = _last_counter_update; + if ((used - last >= _step_counter_update) && Atomic::cmpxchg(used, &_last_counter_update, last) == last) { + _monitoring_support->update_counters(); + } } // ...and print the occupancy line, if needed - if (used - _last_heap_print >= _step_heap_print) { - log_info(gc)("Heap: " SIZE_FORMAT "M reserved, " SIZE_FORMAT "M committed, " SIZE_FORMAT "M used", - max_capacity() / M, capacity() / M, used / M); - _last_heap_print = used; + { + size_t last = _last_heap_print; + if ((used - last >= _step_heap_print) && Atomic::cmpxchg(used, &_last_heap_print, last) == last) { + log_info(gc)("Heap: " SIZE_FORMAT "M reserved, " SIZE_FORMAT "M (%.2f%%) committed, " SIZE_FORMAT "M (%.2f%%) used", + max_capacity() / M, + capacity() / M, + capacity() * 100.0 / max_capacity(), + used / M, + used * 100.0 / max_capacity()); + } } return res; diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonHeap.hpp --- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp Thu May 31 16:09:17 2018 +0200 @@ -44,11 +44,11 @@ ContiguousSpace* _space; VirtualSpace _virtual_space; size_t _max_tlab_size; - size_t _last_counter_update; - size_t _last_heap_print; size_t _step_counter_update; size_t _step_heap_print; int64_t _decay_time_ns; + volatile size_t _last_counter_update; + volatile size_t _last_heap_print; public: static EpsilonHeap* heap(); @@ -106,7 +106,7 @@ size_t* actual_size); // TLAB allocation - virtual bool supports_tlab_allocation() const { return UseTLAB; } + virtual bool supports_tlab_allocation() const { return true; } virtual size_t tlab_capacity(Thread* thr) const { return capacity(); } virtual size_t tlab_used(Thread* thr) const { return used(); } virtual size_t max_tlab_size() const { return _max_tlab_size; } diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonMemoryPool.cpp --- a/src/hotspot/share/gc/epsilon/epsilonMemoryPool.cpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonMemoryPool.cpp Thu May 31 16:09:17 2018 +0200 @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "gc/epsilon/epsilonHeap.hpp" -#include "epsilonMemoryPool.hpp" +#include "gc/epsilon/epsilonMemoryPool.hpp" EpsilonMemoryPool::EpsilonMemoryPool(EpsilonHeap* heap) : _heap(heap), diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonMemoryPool.hpp --- a/src/hotspot/share/gc/epsilon/epsilonMemoryPool.hpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonMemoryPool.hpp Thu May 31 16:09:17 2018 +0200 @@ -24,12 +24,10 @@ #ifndef SHARE_VM_GC_EPSILON_EPSILONMEMORYPOOL_HPP #define SHARE_VM_GC_EPSILON_EPSILONMEMORYPOOL_HPP -#include "utilities/macros.hpp" -#if INCLUDE_EPSILONGC #include "gc/epsilon/epsilonHeap.hpp" #include "services/memoryPool.hpp" #include "services/memoryUsage.hpp" -#endif // INCLUDE_EPSILONGC +#include "utilities/macros.hpp" class EpsilonMemoryPool : public CollectedMemoryPool { private: diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilonThreadLocalData.hpp --- a/src/hotspot/share/gc/epsilon/epsilonThreadLocalData.hpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilonThreadLocalData.hpp Thu May 31 16:09:17 2018 +0200 @@ -24,6 +24,9 @@ #ifndef SHARE_VM_GC_EPSILON_EPSILONTHREADLOCALDATA_HPP #define SHARE_VM_GC_EPSILON_EPSILONTHREADLOCALDATA_HPP +#include "runtime/thread.hpp" +#include "utilities/debug.hpp" + class EpsilonThreadLocalData { private: size_t _ergo_tlab_size; diff -r 380796df44a9 -r 80185413d7fd src/hotspot/share/gc/epsilon/epsilon_globals.hpp --- a/src/hotspot/share/gc/epsilon/epsilon_globals.hpp Wed May 30 09:49:56 2018 +0200 +++ b/src/hotspot/share/gc/epsilon/epsilon_globals.hpp Thu May 31 16:09:17 2018 +0200 @@ -45,13 +45,13 @@ constraint, \ writeable) \ \ - experimental(size_t, EpsilonPrintHeapStep, 100, \ + experimental(size_t, EpsilonPrintHeapSteps, 20, \ "Print heap occupancy stats with this number of steps. " \ "0 turns the printing off.") \ range(0, max_intx) \ \ experimental(size_t, EpsilonUpdateCountersStep, 1 * M, \ - "Update heap heap occupancy counters after allocating this much " \ + "Update heap occupancy counters after allocating this much " \ "memory. Higher values would make allocations faster at " \ "the expense of lower resolution in heap counters.") \ range(1, max_intx) \