Skip to content

Instantly share code, notes, and snippets.

View mariofusco's full-sized avatar

Mario Fusco mariofusco

View GitHub Profile
package org.drools.ansible.rulebook.integration.api.rulesengine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class MemoryMonitor {
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
Benchmark (acquireDelay) (objectSize) (poolStrategy) Mode Cnt Score Error Units
JacksonWriteVanilla.writePojoMediaItem 0 small THREAD_LOCAL thrpt 20 14683788.411 ± 112340.127 ops/s
JacksonWriteVanilla.writePojoMediaItem:·gc.alloc.rate 0 small THREAD_LOCAL thrpt 20 5759.914 ± 43.988 MB/sec
JacksonWriteVanilla.writePojoMediaItem:·gc.alloc.rate.norm 0 small THREAD_LOCAL thrpt 20 432.004 ± 0.001 B/op
JacksonWriteVanilla.writePojoMediaItem:·gc.churn.G1_Eden_Space 0 small THREAD_LOCAL thrpt 20 5627.889 ± 62.307 MB/sec
JacksonWriteVanilla.writePojoMediaItem:·gc.churn.G1_Eden_Space.norm 0 small THREAD_LOCAL thrpt 20 422.105 ± 3.664 B/op
JacksonWriteVanilla.writePoj
Benchmark (acquireDelay) (objectSize) (poolStrategy) Mode Cnt Score Error Units
JacksonWriteVanilla.writePojoMediaItem 0 small STRIPED_LOCK_FREE thrpt 20 11302267.117 ± 418486.530 ops/s
JacksonWriteVanilla.writePojoMediaItem:·gc.alloc.rate 0 small STRIPED_LOCK_FREE thrpt 20 4682.483 ± 173.392 MB/sec
JacksonWriteVanilla.writePojoMediaItem:·gc.alloc.rate.norm 0 small STRIPED_LOCK_FREE thrpt 20 456.239 ± 0.273 B/op
JacksonWriteVanilla.writePojoMediaItem:·gc.churn.G1_Eden_Space 0 small STRIPED_LOCK_FREE thrpt 20 4577.683 ± 167.561 MB/sec
JacksonWriteVanilla.writePojoMediaItem:·gc.churn.G1_Eden_Space.norm 0 small STRIPED_LOCK_FREE thrpt 20 446.078 ± 5.264 B/op
JacksonWriteVani
private static final BufferRecyclerPool STRIPED_JCTOOLS_INSTANCE = new StripedPool(JCToolsPool::new, 4);
private static final BufferRecyclerPool STRIPED_LOCK_FREE_INSTANCE = new StripedPool(BufferRecyclerPool.LockFreePool::nonShared, 4);
static class StripedPool implements BufferRecyclerPool {
private static final long PROBE = getProbeOffset();
private final int mask;
Benchmark (acquireDelay) (objectSize) (poolStrategy) Mode Cnt Score Error Units
JacksonWriteVanilla.writePojoMediaItem 0 large NO_OP thrpt 20 784596.886 ± 734.270 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large THREAD_LOCAL thrpt 20 2572762.547 ± 15741.397 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large LOCK_FREE thrpt 20 2487224.084 ± 32952.142 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large CONCURRENT_DEQUEUE thrpt 20 2336025.521 ± 35176.403 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large JCTOOLS thrpt 20 2216228.211 ± 38447.527 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large STRIPED_LOCK_FREE thrpt 20 2442370.234 ± 27381.171 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large STRIPE
Benchmark (acquireDelay) (objectSize) (poolStrategy) Mode Cnt Score Error Units
JacksonWriteVanilla.writePojoMediaItem 0 large STRIPED_LOCK_FREE thrpt 20 2442370.234 ± 27381.171 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large STRIPED_JCTOOLS thrpt 20 2400320.771 ± 12634.878 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 small STRIPED_LOCK_FREE thrpt 20 11151206.516 ± 205137.550 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 small STRIPED_JCTOOLS thrpt 20 10884847.997 ± 254872.601 ops/s
JacksonWriteVanilla.writePojoMediaItem 10 large STRIPED_LOCK_FREE thrpt 20 2449302.227 ± 17819.357 ops/s
JacksonWriteVanilla.writePojoMediaItem 10 large STRIPED_JCTOOLS thrpt 20 2419230.845 ± 39950.726 ops/s
JacksonWriteVanilla.writePojoMediaItem 10 small STRIPED_LOCK_FRE
Benchmark (acquireDelay) (objectSize) (poolStrategy) Mode Cnt Score Error Units
JacksonWriteVanilla.writePojoMediaItem 0 large NO_OP thrpt 20 784596.886 ± 734.270 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large THREAD_LOCAL thrpt 20 2572762.547 ± 15741.397 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large LOCK_FREE thrpt 20 2487224.084 ± 32952.142 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large CONCURRENT_DEQUEUE thrpt 20 2336025.521 ± 35176.403 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 large JCTOOLS thrpt 20 2216228.211 ± 38447.527 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 small NO_OP thrpt 20 803785.767 ± 1208.431 ops/s
JacksonWriteVanilla.writePojoMediaItem 0 small THR
package com.fasterxml.jackson.perf.json;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.util.BufferRecycler;
import com.fasterxml.jackson.core.util.BufferRecyclerPool;
import com.fasterxml.jackson.jr.ob.JSON;
import com.fasterxml.jackson.perf.model.MediaItems;
import com.fasterxml.jackson.perf.util.NopOutputStream;
import org.jctools.queues.MpmcUnboundedXaddArrayQueue;
import org.openjdk.jmh.annotations.Benchmark;
class JCToolsPool implements BufferRecyclerPool {
static final BufferRecyclerPool INSTANCE = new JCToolsPool();
private final MpmcUnboundedXaddArrayQueue<BufferRecycler> queue = new MpmcUnboundedXaddArrayQueue<>(8);
@Override
public BufferRecycler acquireBufferRecycler() {
BufferRecycler bufferRecycler = queue.poll();
return bufferRecycler != null ? bufferRecycler : new BufferRecycler();