This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
#include <sys/types.h> | |
#include <sys/mman.h> | |
void err(char** argv) { | |
printf("Usage: %s <page count>\n", argv[0]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Perf stats for release : BinaryLatch # CountDownLatch(1) | |
----------------------------------------------------------------------------------------------------------------- | |
task-clock (msec) : 37386,009560 ~ 0,928 # 98597,132785 ~ 2,449 CPUs utilized | |
context-switches : 380.403 ~ 0,010 # 20.918.164 ~ 0,212 M/sec | |
cpu-migrations : 69 ~ 0,002 # 5.269.662 ~ 0,053 M/sec | |
page-faults : 3.990 ~ 0,107 # 3.977 ~ 0,040 K/sec | |
cycles : 147.525.086.934 ~ 3,946 # 344.168.284.382 ~ 3,491 GHz | |
stalled-cycles-frontend : 0 ~ 0,00% # 0 ~ 0,00% frontend cycles idle | |
stalled-cycles-backend : 0 ~ 0,00% # 0 ~ 0,00% backend cycles idle | |
instructions : 80.495.832.415 ~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Written by Chris Vest and released to the public domain, as explained at | |
* http://creativecommons.org/publicdomain/zero/1.0/ | |
*/ | |
package binarylatch; | |
import java.util.concurrent.atomic.AtomicReference; | |
import java.util.concurrent.locks.LockSupport; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nitsan:object-pool-benchmarks% java -jar target/benchmarks.jar 'Simulation.(newObject|claimReleaseWithout)' -bm sample -i 10 -wi 10 -tu ns -t 1 -f 1 -r 10 -jvmArgsPrepend '-XX:+UseConcMarkSweepGC' | |
# JMH 1.5.1 (released 10 days ago) | |
# VM invoker: /usr/lib/jvm/java-8-jdk/jre/bin/java | |
# VM options: -XX:+UseConcMarkSweepGC | |
# Warmup: 10 iterations, 1 s each | |
# Measurement: 10 iterations, 10 s each | |
# Timeout: 10 min per iteration | |
# Threads: 1 thread, will synchronize iterations | |
# Benchmark mode: Sampling time | |
# Benchmark: objectpoolbenchmark.specific.stormpot.Simulation.claimReleaseWithoutReturn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[49m [38;5;0m▄▄[38;5;239;48;5;0m▄▄[38;5;237m▄▄[38;5;0;49m▄▄▄ [0m | |
[38;5;0m▄[38;5;239;48;5;0m▄[48;5;239m [38;5;237m▄▄[48;5;237m [48;5;0m▄▄[38;5;0;49m▄ [0m | |
[48;5;0m [38;5;237;48;5;239m▄[38;5;239;48;5;243m▄▄[38;5;243;48;5;239m▄[48;5;237m▄▄ [38;5;239m▄▄ [48;5;234m [48;5;0m [49m [0m | |
[38;5;0m▄[38;5;237;48;5;0m▄[48;5;237m [38;5;234m▄ [38;5;237;48;5;239m▄▄▄[48;5;234m [38;5;234;48;5;237m▄▄ [48;5;237m▄[48;5;234m [48;5;237m▄[38;5;237;48;5;0m▄[49m▄▄▄ [0m | |
[48;5;0m [48;5;237m [38;5;0m▄[48;5;234m [38;5;234;48;5;237m▄ [48;5;167m [38;5;167;48;5;234m▄ [38;5;234;48;5;237m▄[38;5;0;48;5;234m▄▄[49m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
MemoryHolder holder = new MemoryHolder(); | |
System.out.println("holder.getInt() = " + holder.getInt()); | |
reachabilityFence(holder); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
MemoryHolder holder = new MemoryHolder(); | |
long p = holder.pointer; // last use of 'holder' | |
int n = unsafe.getInt(null, p); | |
System.out.println("holder.getInt() = " + n); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MemoryHolder { | |
private long pointer; | |
public MemoryHolder() { | |
pointer = unsafe.allocateMemory(MEMORY); | |
} | |
@Override | |
protected void finalize() { | |
unsafe.freeMemory(pointer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Fork; | |
import org.openjdk.jmh.annotations.Measurement; | |
import org.openjdk.jmh.annotations.OutputTimeUnit; | |
import org.openjdk.jmh.annotations.Scope; | |
import org.openjdk.jmh.annotations.Setup; | |
import org.openjdk.jmh.annotations.State; | |
import org.openjdk.jmh.annotations.Threads; | |
import org.openjdk.jmh.annotations.Warmup; | |
import sun.misc.Unsafe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>com.github.chrisvest</groupId> | |
<artifactId>stormpot</artifactId> | |
<version>2.3</version> | |
</dependency> |