Mercurial > hg > graal-compiler
comparison src/share/vm/memory/metaspaceCounters.cpp @ 10183:868d87ed63c8
8008966: NPG: Inefficient Metaspace counter functions cause large young GC regressions
Reviewed-by: mgerdin, coleenp
author | jmasa |
---|---|
date | Tue, 12 Feb 2013 14:15:45 -0800 |
parents | 0624b9d81255 |
children | 1a8fb39bdbc4 |
comparison
equal
deleted
inserted
replaced
10182:5c93c1f61226 | 10183:868d87ed63c8 |
---|---|
27 #include "memory/resourceArea.hpp" | 27 #include "memory/resourceArea.hpp" |
28 #include "utilities/exceptions.hpp" | 28 #include "utilities/exceptions.hpp" |
29 | 29 |
30 MetaspaceCounters* MetaspaceCounters::_metaspace_counters = NULL; | 30 MetaspaceCounters* MetaspaceCounters::_metaspace_counters = NULL; |
31 | 31 |
32 size_t MetaspaceCounters::calc_total_capacity() { | |
33 // The total capacity is the sum of | |
34 // 1) capacity of Metachunks in use by all Metaspaces | |
35 // 2) unused space at the end of each Metachunk | |
36 // 3) space in the freelist | |
37 size_t total_capacity = MetaspaceAux::allocated_capacity_bytes() | |
38 + MetaspaceAux::free_bytes() + MetaspaceAux::free_chunks_total_in_bytes(); | |
39 return total_capacity; | |
40 } | |
41 | |
32 MetaspaceCounters::MetaspaceCounters() : | 42 MetaspaceCounters::MetaspaceCounters() : |
33 _capacity(NULL), | 43 _capacity(NULL), |
34 _used(NULL), | 44 _used(NULL), |
35 _max_capacity(NULL) { | 45 _max_capacity(NULL) { |
36 if (UsePerfData) { | 46 if (UsePerfData) { |
37 size_t min_capacity = MetaspaceAux::min_chunk_size(); | 47 size_t min_capacity = MetaspaceAux::min_chunk_size(); |
38 size_t max_capacity = MetaspaceAux::reserved_in_bytes(); | 48 size_t max_capacity = MetaspaceAux::reserved_in_bytes(); |
39 size_t curr_capacity = MetaspaceAux::capacity_in_bytes(); | 49 size_t curr_capacity = calc_total_capacity(); |
40 size_t used = MetaspaceAux::used_in_bytes(); | 50 size_t used = MetaspaceAux::allocated_used_bytes(); |
41 | 51 |
42 initialize(min_capacity, max_capacity, curr_capacity, used); | 52 initialize(min_capacity, max_capacity, curr_capacity, used); |
43 } | 53 } |
44 } | 54 } |
45 | 55 |
80 } | 90 } |
81 } | 91 } |
82 | 92 |
83 void MetaspaceCounters::update_capacity() { | 93 void MetaspaceCounters::update_capacity() { |
84 assert(UsePerfData, "Should not be called unless being used"); | 94 assert(UsePerfData, "Should not be called unless being used"); |
85 assert(_capacity != NULL, "Should be initialized"); | 95 size_t total_capacity = calc_total_capacity(); |
86 size_t capacity_in_bytes = MetaspaceAux::capacity_in_bytes(); | 96 _capacity->set_value(total_capacity); |
87 _capacity->set_value(capacity_in_bytes); | |
88 } | 97 } |
89 | 98 |
90 void MetaspaceCounters::update_used() { | 99 void MetaspaceCounters::update_used() { |
91 assert(UsePerfData, "Should not be called unless being used"); | 100 assert(UsePerfData, "Should not be called unless being used"); |
92 assert(_used != NULL, "Should be initialized"); | 101 size_t used_in_bytes = MetaspaceAux::allocated_used_bytes(); |
93 size_t used_in_bytes = MetaspaceAux::used_in_bytes(); | |
94 _used->set_value(used_in_bytes); | 102 _used->set_value(used_in_bytes); |
95 } | 103 } |
96 | 104 |
97 void MetaspaceCounters::update_max_capacity() { | 105 void MetaspaceCounters::update_max_capacity() { |
98 assert(UsePerfData, "Should not be called unless being used"); | 106 assert(UsePerfData, "Should not be called unless being used"); |