Add benchmark for closing pooled buffers

Motivation:
Pooled buffers are a very important use case, and they change the cost dynamics around shared memory segments, so it's worth looking into in detail.

Modification:
Add another explicit close of pooled direct buffers to MemorySegmentClosedByCleanerBenchmark

Result:
Explicitly closing of pooled buffers is even out-performing cleaner close on the "heavy" workload, so this is currently the fastest way to run that workload:

Benchmark                                                  (workload)  Mode  Cnt   Score   Error  Units
MemorySegmentClosedByCleanerBenchmark.cleanerClose              heavy  avgt  150  14,194 ± 0,558  us/op
MemorySegmentClosedByCleanerBenchmark.explicitClose             heavy  avgt  150  40,496 ± 0,414  us/op
MemorySegmentClosedByCleanerBenchmark.explicitPooledClose       heavy  avgt  150  12,723 ± 0,134  us/op
This commit is contained in:
Chris Vest 2020-12-01 11:15:44 +01:00
parent 89860b779a
commit 4a409d2458

View File

@ -43,6 +43,7 @@ import static java.util.concurrent.CompletableFuture.completedFuture;
public class MemorySegmentClosedByCleanerBenchmark {
private static final Allocator direct = Allocator.direct();
private static final Allocator withCleaner = Allocator.directWithCleaner();
private static final Allocator directPooled = Allocator.pooledDirect();
@Param({"heavy", "light"})
public String workload;
@ -66,6 +67,13 @@ public class MemorySegmentClosedByCleanerBenchmark {
}
}
@Benchmark
public Buf explicitPooledClose() throws Exception {
try (Buf buf = process(directPooled.allocate(256))) {
return buf;
}
}
@Benchmark
public Buf cleanerClose() throws Exception {
return process(withCleaner.allocate(256));