--- a/src/hotspot/share/gc/epsilon/epsilonHeap.cpp Thu May 31 14:50:56 2018 +0200
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.cpp Thu May 31 15:43:02 2018 +0200
@@ -144,18 +144,23 @@
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 committed, " SIZE_FORMAT "M used",
+ max_capacity() / M, capacity() / M, used / M);
+ }
}
return res;
--- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp Thu May 31 14:50:56 2018 +0200
+++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp Thu May 31 15:43:02 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();