Skip to content

Instantly share code, notes, and snippets.

View franz1981's full-sized avatar
🏠
Working from home

Francesco Nigro franz1981

🏠
Working from home
View GitHub Profile
import org.openjdk.jmh.annotations.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)

Same OS/HW configuration of https://github.com/franz1981/JCTools-wiki/blob/xadd_docs/MpscUnboundedXaddArrayQueue.md#lies-damned-lies-and-benchmarks but with different taskset params:

$ taskset -pc 1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47 $$

Running:

$ java -jar microbenchmarks.jar org.jctools.jmh.throughput.ExecutorThroughput -f 4 -p eType=FJ,XADD -p initialCapacity=131072 -tg 12,1 -p consumers=4 -gc true -prof gc

ie 12 producers, 1 executor stat collector thread and 4 consumers.

/usr/lib/jvm/java-1.8.0-openjdk/bin/java -Dfile.encoding=UTF-8 -classpath /home/forked_franz/IdeaProjects/netty/microbench/target/classes:/home/forked_franz/IdeaProjects/netty/handler/target/classes:/home/forked_franz/IdeaProjects/netty/common/target/classes:/home/forked_franz/.m2/repository/org/jctools/jctools-core/2.1.1/jctools-core-2.1.1.jar:/home/forked_franz/IdeaProjects/netty/buffer/target/classes:/home/forked_franz/IdeaProjects/netty/transport/target/classes:/home/forked_franz/IdeaProjects/netty/resolver/target/classes:/home/forked_franz/IdeaProjects/netty/codec/target/classes:/home/forked_franz/IdeaProjects/netty/codec-http/target/classes:/home/forked_franz/IdeaProjects/netty/codec-http2/target/classes:/home/forked_franz/IdeaProjects/netty/codec-redis/target/classes:/home/forked_franz/IdeaProjects/netty/transport-native-epoll/target/classes:/home/forked_franz/IdeaProjects/netty/transport-native-unix-common/target/classes:/home/forked_franz/IdeaProjects/netty/transport-native-kqueue/target/classes:/hom
/usr/lib/jvm/java-1.8.0-openjdk/bin/java -Dfile.encoding=UTF-8 -classpath /home/forked_franz/IdeaProjects/netty/microbench/target/classes:/home/forked_franz/IdeaProjects/netty/handler/target/classes:/home/forked_franz/IdeaProjects/netty/common/target/classes:/home/forked_franz/.m2/repository/org/jctools/jctools-core/2.1.1/jctools-core-2.1.1.jar:/home/forked_franz/IdeaProjects/netty/buffer/target/classes:/home/forked_franz/IdeaProjects/netty/transport/target/classes:/home/forked_franz/IdeaProjects/netty/resolver/target/classes:/home/forked_franz/IdeaProjects/netty/codec/target/classes:/home/forked_franz/IdeaProjects/netty/codec-http/target/classes:/home/forked_franz/IdeaProjects/netty/codec-http2/target/classes:/home/forked_franz/IdeaProjects/netty/codec-redis/target/classes:/home/forked_franz/IdeaProjects/netty/transport-native-epoll/target/classes:/home/forked_franz/IdeaProjects/netty/transport-native-unix-common/target/classes:/home/forked_franz/IdeaProjects/netty/transport-native-kqueue/target/classes:/hom
@Override
public E poll()
{
final int chunkMask = this.chunkMask;
final int chunkShift = this.chunkShift;
long cIndex;
MpmcUnboundedXaddChunk<E> cChunk;
int ciChunkOffset;
boolean isFirstElementOfNextChunk;
boolean pooled = false;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
@Warmup(iterations = 5, time = 1)
@Measurement(iterations = 5, time = 1)
@Fork(1)
public class ArrayLengthBenchmark {
private byte[] array;
private long idx;
/*
* Wake up waiters matching bitset queued on this futex (uaddr).
*/
static int futex_wake(u32 __user *uaddr, unsigned int flags, int nr_wake, u32 bitset)
{
struct futex_hash_bucket *hb;
struct futex_q *this, *next;
union futex_key key = FUTEX_KEY_INIT;
int ret;
DEFINE_WAKE_Q(wake_q);
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*