Skip to content

Instantly share code, notes, and snippets.

View shipilev's full-sized avatar

Aleksey Shipilëv shipilev

View GitHub Profile
@shipilev
shipilev / gist:3177965
Created July 25, 2012 19:14
optimized ASR version
/***** BEGIN LICENSE BLOCK *****
* Version: CPL 1.0/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Common Public
* License Version 1.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.eclipse.org/legal/cpl-v10.html
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
@shipilev
shipilev / gist:8038826
Last active August 13, 2018 19:35
How to stop tweeting and investigate HotSpot
*** Figuring out what "no vm operation" means here in -XX:+PrintSafepointStatistics:
vmop [threads: total initially_running wait_to_block] [time: spin block sync cleanup vmop] page_trap_count
0.320: Deoptimize [ 7 0 0 ] [ 0 0 0 0 0 ] 0
1.320: no vm operation [ 8 1 1 ] [ 0 0 0 0 0 ] 1
4.061: EnableBiasedLocking [ 8 1 1 ] [ 0 0 0 0 0 ] 1
5.222: RevokeBias [ 8 0 1 ] [ 0 0 0 0 0 ] 0
5.831: RevokeBias [ 8 0 0 ] [ 0 0 0 0 0 ] 0
6.440: RevokeBias [ 8 0 0 ] [ 0 0 0 0 0 ] 0
7.049: RevokeBias
This is a class:
class C {
final int v;
C(int v) {
this.v = v;
}
int sqr() {
return v*v;
Entering generation 0
---------------------------------------
Baseline score: 663.60 ops/ms
678.53 ops/ms ( +2.25%) -XX:FreqInlineSize=325 -XX:InlineSmallCode=1000 -XX:MaxInlineLevel=9 -XX:MaxInlineSize=35 -XX:MaxRecursiveInlineLevel=1 -XX:MinInliningThreshold=250
676.79 ops/ms ( +1.99%) -XX:FreqInlineSize=325 -XX:InlineSmallCode=1000 -XX:MaxInlineLevel=9 -XX:MaxInlineSize=35 -XX:MaxRecursiveInlineLevel=1 -XX:MinInliningThreshold=250
673.78 ops/ms ( +1.53%) -XX:FreqInlineSize=325 -XX:InlineSmallCode=1000 -XX:MaxInlineLevel=9 -XX:MaxInlineSize=35 -XX:MaxRecursiveInlineLevel=1 -XX:MinInliningThreshold=250
673.55 ops/ms ( +1.50%) -XX:FreqInlineSize=325 -XX:InlineSmallCode=1000 -XX:MaxInlineLevel=9 -XX:MaxInlineSize=35 -XX:MaxRecursiveInlineLevel=1 -XX:MinInliningThreshold=250
670.98 ops/ms ( +1.11%) -XX:FreqInlineSize=325 -XX:InlineSmallCode=1000 -XX:MaxInlineLevel=9 -XX:MaxInlineSize=35 -XX:MaxRecursiveInlineLevel=1 -XX:MinInliningThreshold=250
670.82 ops/ms (
@shipilev
shipilev / IterationBenchmark.java
Last active August 29, 2015 13:57
Pop quiz: what's wrong with measureWrong()?
package org.sample;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
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;
@shipilev
shipilev / IterationBenchmark.java
Created March 5, 2014 06:07
Dead code is so dead
package org.sample;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.GenerateMicroBenchmark;
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;
@shipilev
shipilev / gist:9595796
Created March 17, 2014 08:33
Quad-core Cortex-A9, jcstress/UnfencedAcquireReleaseTest
$ jdk8b132/bin/java -server -XX:-RestrictContended -jar jcstress.jar -t ".*UnfencedAcquireReleaseTest.*" -v -f 0 -iters 1000
(ETA: n/a) (R: 5.82E+12) (T: 1/0) (F: 0/0) (I: 0/1000) [OK] o.o.j.t.fences.UnfencedAcquireReleaseTest
Observed state Occurrences Expectation Interpretation
[0, 0] ( 190,046,972) ACCEPTABLE Before observing releasing write to, any value is OK for ...
[0, 1] ( 234) ACCEPTABLE Before observing releasing write to, any value is OK for ...
[0, 2] ( 322) ACCEPTABLE Before observing releasing write to, any value is OK for ...
[0, 3] ( 178,121) ACCEPTABLE Before observing releasing write to, any value is OK for ...
[1, 0] ( 572) ACCEPTABLE_INTERESTING Without fence or volatile can read the default or old val...
# Run progress: 0.00% complete, ETA 00:00:05
# VM invoker: /home/shade/Install/jdk8u0/jre/bin/java
# VM options: <none>
# Fork: 1 of 1
# Warmup: <none>
# Measurement: 5 iterations, 1 s each
# Threads: 1 thread, will synchronize iterations
# Benchmark mode: Throughput, ops/time
# Benchmark: org.openjdk.jmh.samples.JMHSample_01_HelloWorld.wellHelloThere
Iteration 1: 1838576.986 ops/ms
@shipilev
shipilev / gist:10602166
Created April 13, 2014 21:01
o.o.j.t.fences.UnfencedAcquireReleaseTest
It looks like test is affected by where the guard variable is residing, this changeset isolates it:
http://hg.openjdk.java.net/code-tools/jcstress/rev/39a1c4786c47
On x86_64, it can not fail without compiler being involved, since x86 is TSO:
$ jdk8/bin/java -XX:-RestrictContended -jar tests-custom/target/jcstress.jar -t ".*UnfencedAcquireReleaseTest.*" -v -iters 20 -f 5
Observed state Occurrences Expectation Interpretation
[0, 0] ( 27,588,422) ACCEPTABLE Before observing releasing write to, any value is OK for ...
[0, 1] ( 167) ACCEPTABLE Before observing releasing write to, any value is OK for ...
/*
* Copyright 2014 The Netty Project
*
* The Netty Project 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
*
* Unless required by applicable law or agreed to in writing, software