fix recycler free stat report (#23159)
* fix recycler free stat report * update comments for ewma window size * one atomic update with aggregated local counter * fix clippy integer arithmetic error * move free calcs outside of loop * fix integer arithmetic error
This commit is contained in:
parent
afda8c4020
commit
aad73f1f2e
|
@ -14,14 +14,19 @@ use {
|
||||||
// cushion against *normal* variations in the workload while bounding the
|
// cushion against *normal* variations in the workload while bounding the
|
||||||
// number of redundant garbage collected objects after temporary bursts.
|
// number of redundant garbage collected objects after temporary bursts.
|
||||||
const RECYCLER_SHRINK_SIZE: usize = 1024;
|
const RECYCLER_SHRINK_SIZE: usize = 1024;
|
||||||
// Lookback window for averaging number of garbage collected objects in terms
|
|
||||||
// of number of allocations.
|
// Lookback window for exponential moving averaging number of garbage collected
|
||||||
|
// objects in terms of number of allocations. The half-life of the decaying
|
||||||
|
// factor based on the window size defined below is 11356. This means a sample
|
||||||
|
// of gc.size() that is 11356 allocations ago has half of the weight as the most
|
||||||
|
// recent sample of gc.size() at current allocation.
|
||||||
const RECYCLER_SHRINK_WINDOW: usize = 16384;
|
const RECYCLER_SHRINK_WINDOW: usize = 16384;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct RecyclerStats {
|
struct RecyclerStats {
|
||||||
total: AtomicUsize,
|
total: AtomicUsize,
|
||||||
reuse: AtomicUsize,
|
reuse: AtomicUsize,
|
||||||
|
freed: AtomicUsize,
|
||||||
max_gc: AtomicUsize,
|
max_gc: AtomicUsize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +153,10 @@ impl<T: Default + Reset> RecyclerX<T> {
|
||||||
if gc.len() > RECYCLER_SHRINK_SIZE
|
if gc.len() > RECYCLER_SHRINK_SIZE
|
||||||
&& self.size_factor.load(Ordering::Acquire) >= SIZE_FACTOR_AFTER_SHRINK
|
&& self.size_factor.load(Ordering::Acquire) >= SIZE_FACTOR_AFTER_SHRINK
|
||||||
{
|
{
|
||||||
|
self.stats.freed.fetch_add(
|
||||||
|
gc.len().saturating_sub(RECYCLER_SHRINK_SIZE),
|
||||||
|
Ordering::Relaxed,
|
||||||
|
);
|
||||||
for mut x in gc.drain(RECYCLER_SHRINK_SIZE..) {
|
for mut x in gc.drain(RECYCLER_SHRINK_SIZE..) {
|
||||||
x.set_recycler(Weak::default());
|
x.set_recycler(Weak::default());
|
||||||
}
|
}
|
||||||
|
@ -169,7 +178,7 @@ impl<T: Default + Reset> RecyclerX<T> {
|
||||||
}
|
}
|
||||||
let total = self.stats.total.load(Ordering::Relaxed);
|
let total = self.stats.total.load(Ordering::Relaxed);
|
||||||
let reuse = self.stats.reuse.load(Ordering::Relaxed);
|
let reuse = self.stats.reuse.load(Ordering::Relaxed);
|
||||||
let freed = self.stats.total.fetch_add(1, Ordering::Relaxed);
|
let freed = self.stats.freed.load(Ordering::Relaxed);
|
||||||
datapoint_debug!(
|
datapoint_debug!(
|
||||||
"recycler",
|
"recycler",
|
||||||
("gc_len", len as i64, i64),
|
("gc_len", len as i64, i64),
|
||||||
|
|
Loading…
Reference in New Issue