1 /* |
1 /* |
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
31 |
31 |
32 G1HeapTransition::Data::Data(G1CollectedHeap* g1_heap) { |
32 G1HeapTransition::Data::Data(G1CollectedHeap* g1_heap) { |
33 _eden_length = g1_heap->eden_regions_count(); |
33 _eden_length = g1_heap->eden_regions_count(); |
34 _survivor_length = g1_heap->survivor_regions_count(); |
34 _survivor_length = g1_heap->survivor_regions_count(); |
35 _old_length = g1_heap->old_regions_count(); |
35 _old_length = g1_heap->old_regions_count(); |
|
36 _archive_length = g1_heap->archive_regions_count(); |
36 _humongous_length = g1_heap->humongous_regions_count(); |
37 _humongous_length = g1_heap->humongous_regions_count(); |
37 _metaspace_used_bytes = MetaspaceUtils::used_bytes(); |
38 _metaspace_used_bytes = MetaspaceUtils::used_bytes(); |
38 } |
39 } |
39 |
40 |
40 G1HeapTransition::G1HeapTransition(G1CollectedHeap* g1_heap) : _g1_heap(g1_heap), _before(g1_heap) { } |
41 G1HeapTransition::G1HeapTransition(G1CollectedHeap* g1_heap) : _g1_heap(g1_heap), _before(g1_heap) { } |
41 |
42 |
42 struct DetailedUsage : public StackObj { |
43 struct DetailedUsage : public StackObj { |
43 size_t _eden_used; |
44 size_t _eden_used; |
44 size_t _survivor_used; |
45 size_t _survivor_used; |
45 size_t _old_used; |
46 size_t _old_used; |
|
47 size_t _archive_used; |
46 size_t _humongous_used; |
48 size_t _humongous_used; |
47 |
49 |
48 size_t _eden_region_count; |
50 size_t _eden_region_count; |
49 size_t _survivor_region_count; |
51 size_t _survivor_region_count; |
50 size_t _old_region_count; |
52 size_t _old_region_count; |
|
53 size_t _archive_region_count; |
51 size_t _humongous_region_count; |
54 size_t _humongous_region_count; |
52 |
55 |
53 DetailedUsage() : |
56 DetailedUsage() : |
54 _eden_used(0), _survivor_used(0), _old_used(0), _humongous_used(0), |
57 _eden_used(0), _survivor_used(0), _old_used(0), _archive_used(0), _humongous_used(0), |
55 _eden_region_count(0), _survivor_region_count(0), _old_region_count(0), _humongous_region_count(0) {} |
58 _eden_region_count(0), _survivor_region_count(0), _old_region_count(0), |
|
59 _archive_region_count(0), _humongous_region_count(0) {} |
56 }; |
60 }; |
57 |
61 |
58 class DetailedUsageClosure: public HeapRegionClosure { |
62 class DetailedUsageClosure: public HeapRegionClosure { |
59 public: |
63 public: |
60 DetailedUsage _usage; |
64 DetailedUsage _usage; |
61 bool do_heap_region(HeapRegion* r) { |
65 bool do_heap_region(HeapRegion* r) { |
62 if (r->is_old()) { |
66 if (r->is_old()) { |
63 _usage._old_used += r->used(); |
67 _usage._old_used += r->used(); |
64 _usage._old_region_count++; |
68 _usage._old_region_count++; |
|
69 } else if (r->is_archive()) { |
|
70 _usage._archive_used += r->used(); |
|
71 _usage._archive_region_count++; |
65 } else if (r->is_survivor()) { |
72 } else if (r->is_survivor()) { |
66 _usage._survivor_used += r->used(); |
73 _usage._survivor_used += r->used(); |
67 _usage._survivor_region_count++; |
74 _usage._survivor_region_count++; |
68 } else if (r->is_eden()) { |
75 } else if (r->is_eden()) { |
69 _usage._eden_used += r->used(); |
76 _usage._eden_used += r->used(); |
92 assert(usage._eden_region_count == 0, "Expected no eden regions, but got " SIZE_FORMAT, usage._eden_region_count); |
99 assert(usage._eden_region_count == 0, "Expected no eden regions, but got " SIZE_FORMAT, usage._eden_region_count); |
93 assert(usage._survivor_region_count == after._survivor_length, "Expected survivors to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
100 assert(usage._survivor_region_count == after._survivor_length, "Expected survivors to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
94 after._survivor_length, usage._survivor_region_count); |
101 after._survivor_length, usage._survivor_region_count); |
95 assert(usage._old_region_count == after._old_length, "Expected old to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
102 assert(usage._old_region_count == after._old_length, "Expected old to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
96 after._old_length, usage._old_region_count); |
103 after._old_length, usage._old_region_count); |
|
104 assert(usage._archive_region_count == after._archive_length, "Expected archive to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
|
105 after._archive_length, usage._archive_region_count); |
97 assert(usage._humongous_region_count == after._humongous_length, "Expected humongous to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
106 assert(usage._humongous_region_count == after._humongous_length, "Expected humongous to be " SIZE_FORMAT " but was " SIZE_FORMAT, |
98 after._humongous_length, usage._humongous_region_count); |
107 after._humongous_length, usage._humongous_region_count); |
99 } |
108 } |
100 |
109 |
101 log_info(gc, heap)("Eden regions: " SIZE_FORMAT "->" SIZE_FORMAT "(" SIZE_FORMAT ")", |
110 log_info(gc, heap)("Eden regions: " SIZE_FORMAT "->" SIZE_FORMAT "(" SIZE_FORMAT ")", |
110 log_info(gc, heap)("Old regions: " SIZE_FORMAT "->" SIZE_FORMAT, |
119 log_info(gc, heap)("Old regions: " SIZE_FORMAT "->" SIZE_FORMAT, |
111 _before._old_length, after._old_length); |
120 _before._old_length, after._old_length); |
112 log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", |
121 log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", |
113 usage._old_used / K, ((after._old_length * HeapRegion::GrainBytes) - usage._old_used) / K); |
122 usage._old_used / K, ((after._old_length * HeapRegion::GrainBytes) - usage._old_used) / K); |
114 |
123 |
|
124 log_info(gc, heap)("Archive regions: " SIZE_FORMAT "->" SIZE_FORMAT, |
|
125 _before._archive_length, after._archive_length); |
|
126 log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", |
|
127 usage._archive_used / K, ((after._archive_length * HeapRegion::GrainBytes) - usage._archive_used) / K); |
|
128 |
115 log_info(gc, heap)("Humongous regions: " SIZE_FORMAT "->" SIZE_FORMAT, |
129 log_info(gc, heap)("Humongous regions: " SIZE_FORMAT "->" SIZE_FORMAT, |
116 _before._humongous_length, after._humongous_length); |
130 _before._humongous_length, after._humongous_length); |
117 log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", |
131 log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K", |
118 usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K); |
132 usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K); |
119 |
133 |