--- a/hotspot/src/share/vm/gc/shared/plab.cpp Fri Feb 24 12:41:26 2017 -0500
+++ b/hotspot/src/share/vm/gc/shared/plab.cpp Thu Feb 23 12:50:49 2017 -0500
@@ -1,5 +1,5 @@
/*
- * 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
@@ -154,30 +154,33 @@
assert(is_object_aligned(max_size()) && min_size() <= max_size(),
"PLAB clipping computation may be incorrect");
- if (_allocated == 0) {
- assert(_unused == 0,
- "Inconsistency in PLAB stats: "
- "_allocated: " SIZE_FORMAT ", "
- "_wasted: " SIZE_FORMAT ", "
- "_unused: " SIZE_FORMAT ", "
- "_undo_wasted: " SIZE_FORMAT,
- _allocated, _wasted, _unused, _undo_wasted);
+ 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);
- _allocated = 1;
- }
- double wasted_frac = (double)_unused / (double)_allocated;
+ 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() {
+ size_t allocated = MAX2(_allocated, size_t(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;
+ 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;
}