Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Vest chrisvest

View GitHub Profile
@chrisvest
chrisvest / pagelock.c
Created May 12, 2015
This program uses memory in page units. As much as you like. Have fun.
View pagelock.c
#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]);
View perf-stats.txt
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 ~
View BinaryLatch.java
/*
* 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;
/**
View java8-using-cms-gc.txt
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
@chrisvest
chrisvest / motd
Last active Aug 29, 2015
/etc/motd
View motd
 ▄▄▄▄▄▄▄▄▄ 
▄▄ ▄▄ ▄▄▄ 
 ▄▄▄▄▄▄ ▄▄    
▄▄ ▄ ▄▄▄ ▄▄ ▄ ▄▄▄▄▄ 
  ▄ ▄  ▄ ▄▄▄
View MemoryHolder.java
public static void main(String[] args) {
MemoryHolder holder = new MemoryHolder();
System.out.println("holder.getInt() = " + holder.getInt());
reachabilityFence(holder);
}
View MemoryHolder.java
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);
}
View MemoryHolder.java
public class MemoryHolder {
private long pointer;
public MemoryHolder() {
pointer = unsafe.allocateMemory(MEMORY);
}
@Override
protected void finalize() {
unsafe.freeMemory(pointer);
@chrisvest
chrisvest / Reachability.java
Last active Aug 29, 2015
Reachability fence benchmark
View Reachability.java
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;
View pom.xml snippet
<dependency>
<groupId>com.github.chrisvest</groupId>
<artifactId>stormpot</artifactId>
<version>2.3</version>
</dependency>
You can’t perform that action at this time.