--- old/src/hotspot/share/gc/g1/g1OldGenAllocationTracker.hpp 2020-08-13 04:14:10.211275174 +0000 +++ new/src/hotspot/share/gc/g1/g1OldGenAllocationTracker.hpp 2020-08-13 04:14:10.055272183 +0000 @@ -28,34 +28,55 @@ #include "gc/g1/heapRegion.hpp" #include "memory/allocation.hpp" +class G1AdaptiveIHOPControl; + // Track allocation details in the old generation. class G1OldGenAllocationTracker : public CHeapObj { // New bytes allocated in old gen between the end of the last GC and + // the end of the GC before that. This includes humongous object allocation. + size_t _last_period_old_bytes; + // New bytes allocated in humongous regions between the end of the last GC and // the end of the GC before that. - size_t _last_cycle_old_bytes; - // The number of seconds between the end of the last GC and - // the end of the GC before that. - double _last_cycle_duration; + size_t _last_period_humongous_bytes; - size_t _allocated_bytes_since_last_gc; + size_t _humongous_bytes_after_last_gc; + size_t _humongous_bytes_after_penultimate_gc; - void reset_cycle_after_gc() { - _last_cycle_old_bytes = _allocated_bytes_since_last_gc; - _allocated_bytes_since_last_gc = 0; - } + size_t _allocated_bytes_since_last_gc; + size_t _allocated_humongous_bytes_since_last_gc; public: G1OldGenAllocationTracker(); // Add the given number of bytes to the total number of allocated bytes in the old gen. void add_allocated_bytes_since_last_gc(size_t bytes) { _allocated_bytes_since_last_gc += bytes; } - size_t last_cycle_old_bytes() { return _last_cycle_old_bytes; } + void add_allocated_humongous_bytes_since_last_gc(size_t bytes) { + _allocated_humongous_bytes_since_last_gc += bytes; + _allocated_bytes_since_last_gc += bytes; + } + + // Record a humongous allocation during a collection pause. + // In g1CollectedHeap, when a humongous allocation fails, the heap will attempt + // to trigger a GC and try to allocate the required bytes during it. These bytes + // are then not counted in any mutator period but as survived bytes after GC. + // Otherwise, they would distort our estimation for how many humongous bytes are + // freed in a mutator period. + void record_collection_pause_humongous_allocation(size_t bytes) { + _humongous_bytes_after_last_gc += bytes; + } - double last_cycle_duration() { return _last_cycle_duration; } + size_t last_period_old_bytes() const { return _last_period_old_bytes; } // Reset stats after a collection. - void reset_after_full_gc(); - void reset_after_young_gc(double allocation_duration_s); + void reset_after_gc(size_t humongous_bytes_after_gc); + + // This is used by Adaptive IHOP to sample the old gen allocation rate. + // Different from the regular old gen allocation rate, this method considers the + // humongous objects that can be reclaimed early by young GCs. Since we cannot + // track the life cycle of individual humongous objects, we assume that such + // objects were all newly allocated and not survivors, unless more were + // reclaimed than allocated. + size_t last_period_net_survived_old_bytes() const; }; #endif // SHARE_VM_GC_G1_G1OLDGENALLOCATIONTRACKER_HPP \ No newline at end of file