28 #include "gc/g1/heapRegion.hpp"
29 #include "memory/allocation.hpp"
30
31 class G1AdaptiveIHOPControl;
32
33 // Track allocation details in the old generation.
34 class G1OldGenAllocationTracker : public CHeapObj<mtGC> {
35 // New bytes allocated in old gen between the end of the last GC and
36 // the end of the GC before that. This includes humongous object allocation.
37 size_t _last_period_old_bytes;
38 // New bytes allocated in humongous regions between the end of the last GC and
39 // the end of the GC before that.
40 size_t _last_period_humongous_bytes;
41
42 size_t _humongous_bytes_after_last_gc;
43 size_t _humongous_bytes_after_penultimate_gc;
44
45 size_t _allocated_bytes_since_last_gc;
46 size_t _allocated_humongous_bytes_since_last_gc;
47
48 friend class G1AdaptiveIHOPControl;
49
50 public:
51 G1OldGenAllocationTracker();
52 // Add the given number of bytes to the total number of allocated bytes in the old gen.
53 void add_allocated_bytes_since_last_gc(size_t bytes) { _allocated_bytes_since_last_gc += bytes; }
54
55 void add_allocated_humongous_bytes_since_last_gc(size_t bytes) {
56 _allocated_humongous_bytes_since_last_gc += bytes;
57 _allocated_bytes_since_last_gc += bytes;
58 }
59
60 // Record a humongous allocation during a collection pause.
61 // In g1CollectedHeap, when a humongous allocation fails, the heap will attempt
62 // to trigger a GC and try to allocate the required bytes during it. These bytes
63 // are then not counted in any mutator period but as survived bytes after GC.
64 // Otherwise, they would distort our estimation for how many humongous bytes are
65 // freed in a mutator period.
66 void record_collection_pause_humongous_allocation(size_t bytes) {
67 _humongous_bytes_after_last_gc += bytes;
68 }
69
70 size_t last_period_old_bytes() const { return _last_period_old_bytes; }
71
72 // Reset stats after a collection.
73 void reset_after_gc(size_t humongous_bytes_after_gc);
74 };
75
76 #endif // SHARE_VM_GC_G1_G1OLDGENALLOCATIONTRACKER_HPP
|
28 #include "gc/g1/heapRegion.hpp"
29 #include "memory/allocation.hpp"
30
31 class G1AdaptiveIHOPControl;
32
33 // Track allocation details in the old generation.
34 class G1OldGenAllocationTracker : public CHeapObj<mtGC> {
35 // New bytes allocated in old gen between the end of the last GC and
36 // the end of the GC before that. This includes humongous object allocation.
37 size_t _last_period_old_bytes;
38 // New bytes allocated in humongous regions between the end of the last GC and
39 // the end of the GC before that.
40 size_t _last_period_humongous_bytes;
41
42 size_t _humongous_bytes_after_last_gc;
43 size_t _humongous_bytes_after_penultimate_gc;
44
45 size_t _allocated_bytes_since_last_gc;
46 size_t _allocated_humongous_bytes_since_last_gc;
47
48 public:
49 G1OldGenAllocationTracker();
50 // Add the given number of bytes to the total number of allocated bytes in the old gen.
51 void add_allocated_bytes_since_last_gc(size_t bytes) { _allocated_bytes_since_last_gc += bytes; }
52
53 void add_allocated_humongous_bytes_since_last_gc(size_t bytes) {
54 _allocated_humongous_bytes_since_last_gc += bytes;
55 _allocated_bytes_since_last_gc += bytes;
56 }
57
58 // Record a humongous allocation during a collection pause.
59 // In g1CollectedHeap, when a humongous allocation fails, the heap will attempt
60 // to trigger a GC and try to allocate the required bytes during it. These bytes
61 // are then not counted in any mutator period but as survived bytes after GC.
62 // Otherwise, they would distort our estimation for how many humongous bytes are
63 // freed in a mutator period.
64 void record_collection_pause_humongous_allocation(size_t bytes) {
65 _humongous_bytes_after_last_gc += bytes;
66 }
67
68 size_t last_period_old_bytes() const { return _last_period_old_bytes; }
69
70 // Reset stats after a collection.
71 void reset_after_gc(size_t humongous_bytes_after_gc);
72
73 // This is used by Adaptive IHOP to sample the old gen allocation rate.
74 // Different from the regular old gen allocation rate, this method considers the
75 // humongous objects that can be reclaimed early by young GCs. Since we cannot
76 // track the life cycle of individual humongous objects, we assume that such
77 // objects were all newly allocated and not survivors, unless more were
78 // reclaimed than allocated.
79 size_t last_period_net_survived_old_bytes() const;
80 };
81
82 #endif // SHARE_VM_GC_G1_G1OLDGENALLOCATIONTRACKER_HPP
|