Skip to content

Commit

Permalink
Merge pull request #1351 from mattrjacobs/remove-histogram-object-pool
Browse files Browse the repository at this point in the history
Remove object-pooling from CachedValuesHistogram
  • Loading branch information
mattrjacobs committed Sep 16, 2016
2 parents d838f4d + cc8f973 commit 8738d1c
Showing 1 changed file with 2 additions and 22 deletions.
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);
}
}

0 comments on commit 8738d1c

Please sign in to comment.