Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove object-pooling from CachedValuesHistogram #1351

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,9 @@

import org.HdrHistogram.Histogram;

import java.util.concurrent.ConcurrentLinkedQueue;

public class CachedValuesHistogram {

static int POOL_SIZE = 1000;
static ConcurrentLinkedQueue<Histogram> HISTOGRAM_POOL = new ConcurrentLinkedQueue<Histogram>();

static {
for (int i = 0; i < POOL_SIZE; i++) {
HISTOGRAM_POOL.add(new Histogram(3));
}
}
private final static int NUMBER_SIGNIFICANT_DIGITS = 3;

private final int mean;
private final int p0;
Expand Down Expand Up @@ -100,8 +91,6 @@ private CachedValuesHistogram(Histogram underlying) {
p100 = (int) underlying.getValueAtPercentile(100);

totalCount = underlying.getTotalCount();

release(underlying);
}

/**
Expand Down Expand Up @@ -155,16 +144,7 @@ public long getTotalCount() {
return totalCount;
}

private static void release(Histogram histogram) {
histogram.reset();
HISTOGRAM_POOL.offer(histogram);
}

public static Histogram getNewHistogram() {
Histogram histogram = HISTOGRAM_POOL.poll();
if (histogram == null) {
histogram = new Histogram(3);
}
return histogram;
return new Histogram(NUMBER_SIGNIFICANT_DIGITS);
}
}