1 /*
2 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
148 protected:
149 const char* _description; // Identifying string.
150
151 size_t _allocated; // Total allocated
152 size_t _wasted; // of which wasted (internal fragmentation)
153 size_t _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size)
154 size_t _unused; // Unused in last buffer
155 size_t _desired_net_plab_sz;// Output of filter (below), suitably trimmed and quantized
156 AdaptiveWeightedAverage
157 _filter; // Integrator with decay
158
159 virtual void reset() {
160 _allocated = 0;
161 _wasted = 0;
162 _undo_wasted = 0;
163 _unused = 0;
164 }
165
166 virtual void log_plab_allocation();
167 virtual void log_sizing(size_t calculated, size_t net_desired);
168 public:
169 PLABStats(const char* description, size_t desired_net_plab_sz_, unsigned wt) :
170 _description(description),
171 _allocated(0),
172 _wasted(0),
173 _undo_wasted(0),
174 _unused(0),
175 _desired_net_plab_sz(desired_net_plab_sz_),
176 _filter(wt)
177 { }
178
179 virtual ~PLABStats() { }
180
181 size_t allocated() const { return _allocated; }
182 size_t wasted() const { return _wasted; }
183 size_t unused() const { return _unused; }
184 size_t used() const { return allocated() - (wasted() + unused()); }
185 size_t undo_wasted() const { return _undo_wasted; }
186
187 static const size_t min_size() {
188 return PLAB::min_size();
189 }
190
191 static const size_t max_size() {
192 return PLAB::max_size();
193 }
194
195 // Calculates plab size for current number of gc worker threads.
196 size_t desired_plab_sz(uint no_of_gc_workers);
197
198 // Updates the current desired PLAB size. Computes the new desired PLAB size with one gc worker thread,
199 // updates _desired_plab_sz and clears sensor accumulators.
200 virtual void adjust_desired_plab_sz();
201
202 inline void add_allocated(size_t v);
203
204 inline void add_unused(size_t v);
205
206 inline void add_wasted(size_t v);
207
208 inline void add_undo_wasted(size_t v);
209 };
210
211 #endif // SHARE_VM_GC_SHARED_PLAB_HPP
|
1 /*
2 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
148 protected:
149 const char* _description; // Identifying string.
150
151 size_t _allocated; // Total allocated
152 size_t _wasted; // of which wasted (internal fragmentation)
153 size_t _undo_wasted; // of which wasted on undo (is not used for calculation of PLAB size)
154 size_t _unused; // Unused in last buffer
155 size_t _desired_net_plab_sz;// Output of filter (below), suitably trimmed and quantized
156 AdaptiveWeightedAverage
157 _filter; // Integrator with decay
158
159 virtual void reset() {
160 _allocated = 0;
161 _wasted = 0;
162 _undo_wasted = 0;
163 _unused = 0;
164 }
165
166 virtual void log_plab_allocation();
167 virtual void log_sizing(size_t calculated, size_t net_desired);
168
169 // helper for adjust_desired_plab_sz().
170 virtual size_t compute_desired_plab_sz();
171
172 public:
173 PLABStats(const char* description, size_t desired_net_plab_sz_, unsigned wt) :
174 _description(description),
175 _allocated(0),
176 _wasted(0),
177 _undo_wasted(0),
178 _unused(0),
179 _desired_net_plab_sz(desired_net_plab_sz_),
180 _filter(wt)
181 { }
182
183 virtual ~PLABStats() { }
184
185 size_t allocated() const { return _allocated; }
186 size_t wasted() const { return _wasted; }
187 size_t unused() const { return _unused; }
188 size_t used() const { return allocated() - (wasted() + unused()); }
189 size_t undo_wasted() const { return _undo_wasted; }
190
191 static const size_t min_size() {
192 return PLAB::min_size();
193 }
194
195 static const size_t max_size() {
196 return PLAB::max_size();
197 }
198
199 // Calculates plab size for current number of gc worker threads.
200 size_t desired_plab_sz(uint no_of_gc_workers);
201
202 // Updates the current desired PLAB size. Computes the new desired PLAB size with one gc worker thread,
203 // updates _desired_plab_sz and clears sensor accumulators.
204 void adjust_desired_plab_sz();
205
206 inline void add_allocated(size_t v);
207
208 inline void add_unused(size_t v);
209
210 inline void add_wasted(size_t v);
211
212 inline void add_undo_wasted(size_t v);
213 };
214
215 #endif // SHARE_VM_GC_SHARED_PLAB_HPP
|