Skip to content

Instantly share code, notes, and snippets.

View chrisvest's full-sized avatar
🍉

Chris Vest chrisvest

🍉
View GitHub Profile
import org.junit.Rule;
import org.junit.Test;
import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
import org.neo4j.kernel.GraphDatabaseAPI;
import org.neo4j.kernel.impl.nioneo.store.NeoStore;
import org.neo4j.kernel.impl.nioneo.store.NodeRecord;
import org.neo4j.kernel.impl.nioneo.store.NodeStore;
@chrisvest
chrisvest / benchmark-results.txt
Last active August 29, 2015 13:56
First results of reimplementing the Stormpot object pool benchmarks with JMH. The machine is a Late 2013 MacBook Pro with a 4 core i7 Crystalwell CPU. The pools are capped to max 10 objects, which explain the degraded behaviours observed with 16 threads.
shipilev:stormpot-benchmark[master*]$ uname -a
Darwin shipilev.local 13.0.2 Darwin Kernel Version 13.0.2: Sun Sep 29 19:38:57 PDT 2013; root:xnu-2422.75.4~1/RELEASE_X86_64 x86_64
shipilev:stormpot-benchmark[master*]$ java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
shipilev:stormpot-benchmark[master*]$
[ 1 thread ]
shipilev:stormpot-benchmark[master*]$ java -jar target/object-pool-benchmarks.jar ".*ClaimRelease.*" -t 1 -i 6 -wi 6 -f 1 -tu s -bm thrpt
@chrisvest
chrisvest / LinkedListTest.java
Last active August 29, 2015 13:56
Example of a linked list in Cypher.
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import org.junit.Rule;
import org.junit.Test;
@chrisvest
chrisvest / gist:9130697
Created February 21, 2014 08:31
Experimenting with conditional CAS and lazySet. I like the first 4 runs, but wtf happened to the other 6!?
shipilev:object-pool-benchmarks[stormpot-2.2]$ ### Conditional CAS and lazySet:
shipilev:object-pool-benchmarks[stormpot-2.2]$ java -jar target/object-pool-benchmarks.jar ".*ClaimRelease.StormpotBlaze.*" -t 8 -tu ms -bm thrpt
# Run progress: 0.00% complete, ETA 00:06:40
# VM invoker: /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/bin/java
# VM options: <none>
# Fork: 1 of 10
# Warmup: 20 iterations, 1 s each
# Measurement: 20 iterations, 1 s each
# Threads: 8 threads, will synchronize iterations
# Benchmark mode: Throughput, ops/time
@chrisvest
chrisvest / results.txt
Created February 21, 2014 22:12
An otherwise productive evening of optimisations lead to hissing laptops held mid-air at arms length, at a slight tilt. All in the name of science and performance.
mvn clean package && java -jar target/object-pool-benchmarks.jar ".*ClaimRelease.StormpotBlaze.*" -t 8 -tu ms -bm thrpt -f 3
branch:
Benchmark Mode Samples Mean Mean error Units
master:
o.s.ClaimRelease.StormpotBlazePool.cycle thrpt 60 255582.217 2739.712 ops/ms
perf/extend-atomicint:
@chrisvest
chrisvest / BenchmarkSynchronousQueue.java
Created April 14, 2014 18:35
Benchmarking a SynchronousQueue with JMH. Enjoy.
import java.util.concurrent.SynchronousQueue;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
import org.openjdk.jmh.annotations.Group;
import org.openjdk.jmh.annotations.GroupThreads;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.logic.Control;
var Functor = ['map'];
var Applicative = ['maps', 'wrap'].concat(Functor);
var Monad = ['mapcat'].concat(Applicative);
var compliment = function (f) {
return function (x) {
return !f(x);
}
}
public static void main(String[] args) {
outer:for (int i = Integer.MIN_VALUE; i < Integer.MAX_VALUE; i++) {
// Optimise the program by checking most likely candidates for
// coercion conflicts first.
boolean foundConflict = false;
for (int x = 1; x < 100; x++) {
// scala> for (x <- 1 until 15)
// yield ((x / 2) ^ (-1 * (x % 2)));
// res21: Seq[Int] =
// Vector(-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7)
chris@Minty ~ $ perf stat -d echo 1
1
Performance counter stats for 'echo 1':
0.597512 task-clock # 0.249 CPUs utilized
3 context-switches # 0.005 M/sec
0 cpu-migrations # 0.000 K/sec
176 page-faults # 0.295 M/sec
<not supported> cycles
@chrisvest
chrisvest / Finalizer.java
Created July 30, 2014 11:34
The cost of finalizer methods
import org.openjdk.jmh.annotations.Benchmark;
public class Finalizer
{
private static class ObjectWithFinalizer
{
@Override
protected void finalize() throws Throwable
{
super.finalize();