src/share/vm/gc/shared/plab.cpp
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -152,32 +152,37 @@
}
assert(is_object_aligned(max_size()) && min_size() <= max_size(),
"PLAB clipping computation may be incorrect");
- if (_allocated == 0) {
- assert(_unused == 0,
+ assert(_allocated != 0 || _unused == 0,
"Inconsistency in PLAB stats: "
"_allocated: " SIZE_FORMAT ", "
"_wasted: " SIZE_FORMAT ", "
"_unused: " SIZE_FORMAT ", "
"_undo_wasted: " SIZE_FORMAT,
_allocated, _wasted, _unused, _undo_wasted);
+ size_t plab_sz = compute_desired_plab_sz();
+ // Take historical weighted average
+ _filter.sample(plab_sz);
+ _desired_net_plab_sz = MAX2(min_size(), (size_t)_filter.average());
+
+ log_sizing(plab_sz, _desired_net_plab_sz);
+ // Clear accumulators for next round
+ reset();
+}
+
+size_t PLABStats::compute_desired_plab_sz() {
+ if (_allocated == 0) {
_allocated = 1;
}
double wasted_frac = (double)_unused / (double)_allocated;
size_t target_refills = (size_t)((wasted_frac * TargetSurvivorRatio) / TargetPLABWastePct);
if (target_refills == 0) {
target_refills = 1;
}
size_t used = _allocated - _wasted - _unused;
// Assumed to have 1 gc worker thread
size_t recent_plab_sz = used / target_refills;
- // Take historical weighted average
- _filter.sample(recent_plab_sz);
- _desired_net_plab_sz = MAX2(min_size(), (size_t)_filter.average());
-
- log_sizing(recent_plab_sz, _desired_net_plab_sz);
-
- reset();
+ return recent_plab_sz;
}