08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Lyon jug-how-to-fail-at-benchmarking
1. How to fail at benchmarking ?
Pierre Laporte
Performance engineer - Datastax
@pingtimeout
2. @pingtimeout
Agenda
• Intro
• Why this talk?
• How to fail a benchmark ?
– What to measure ?
– How to measure ?
– "Coordinated Omission" ...?
• Available tools ?
• Mindset ?
• JMH ?
2
13. @pingtimeout 13
Example
• User login benchmark (POST /login)
• 100.000 logins
• 1 user
• Measure each login
• Measure from first login
• Perform one (long) run
• On a dev laptop
• Average the results
• CPU utilization => Capacity Planning
26. @pingtimeout 26
How many 9’s in percentiles ?
• Depend on number of users
• If 500 users, 99th percentile means… ?
27. @pingtimeout 27
How many 9’s in percentiles ?
• If 1.000.000 users, 99th percentile
means… ?
• 10.000 unlucky folks
28. @pingtimeout 28
Maximum
• « Meh, probably a timeout, let’s
ignore » — Random dev facing a 60s
response time
• Is that be acceptable…
• For a video game?
• For a real-time application?
• For a mobile application?
29. @pingtimeout
Benchmark genesis
• A specific question
• Precise requirements
• Ex:
• e-commerce website
• « With my 5 application servers, 20.000
articles in DB and 1.000 simultaneous
clients, will my purchase take 50ms on
average, 100ms once every 10
attempts, and 300ms at worst? »
29
30. @pingtimeout
Environment
• « With my 5 application servers, 20.000
articles in DB and 1.000 simultaneous clients,
will my purchase take 50ms on average,
100ms once every 10 attempts, and 300ms at
worst? »
• POC:
• TomEE
• Glassfish
• Weblogic
30
31. @pingtimeout
Load
• « With my 5 application servers, 20.000
articles in DB and 1.000 simultaneous clients,
will my purchase take 50ms on average,
100ms once every 10 attempts, and 300ms at
worst? »
31
32. @pingtimeout
Requirements
• « With my 5 application servers, 20.000
articles in DB and 1.000 simultaneous clients,
will my purchase take 50ms on average,
100ms once every 10 attempts, and 300ms at
worst? »
32
37. @pingtimeout 37
Normal distribution
• Client gives those latency numbers
• Average = 100 ms
• Std dev = 20 ms
• Median = 120 ms
• Max = 1 s
• What is the 99th percentile ?
49. @pingtimeout 49
Aggressive Opts
• Increase fixnum pool from 128 to … ?
• How much left as an exercise
• Hint: set_aggressive_opts_flags() in
arguments.cpp
• That’s pretty much it.
50. @pingtimeout 50
Puzzler 2
• What does
this code do ?
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
third();
}
void third() {
for(int i=0; i<1_000; i++)
new Sabord();
}
static class Sabord {}
}
51. @pingtimeout 51
Puzzler 2
• What does
this code do ?
1. It swears
2. It does not do
what we think
3. It measures
Hotspot
4. It creates ~10k
objects
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
third();
}
void third() {
for(int i=0; i<1_000; i++)
new Sabord();
}
static class Sabord {}
}
52. @pingtimeout 52
Puzzler 2
• All of the above
(below)
1. It swears
2. It does not do
what we think
3. It measures
Hotspot
4. It creates ~10k
objects
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
third();
}
void third() {
for(int i=0; i<1_000; i++)
new Sabord();
}
static class Sabord {}
}
54. @pingtimeout 54
Puzzler 2 - Run
$ time java Haddock
real 0m0.169s
user 0m0.110s
sys 0m0.055s
Test @3.5 GHz
55. @pingtimeout 55
It does not do what we think
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
third();
}
void third() {
for(int i=0; i<1_000; i++)
new Sabord();
}
static class Sabord {}
}
56. @pingtimeout 56
It does not do what we think
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
third();
}
void third() {
for(int i=0; i<1_000; i++)
;
}
static class Sabord {}
}
57. @pingtimeout 57
It does not do what we think
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
third();
}
void third() {
}
static class Sabord {}
}
58. @pingtimeout 58
It does not do what we think
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
second();
}
void second() {
for(int i=0; i<1_000_000; i++)
;
}
static class Sabord {}
}
59. @pingtimeout 59
It does not do what we think
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
for(int i=0; i<1_000; i++)
;
}
static class Sabord {}
}
60. @pingtimeout 60
It does not do what we think
public class Haddock {
public static void main(String [] args) {
new Haddock().first();
}
void first() {
}
static class Sabord {}
}
61. @pingtimeout 61
Puzzler 2
• After ~10k iterations, code is DCE'd
public class Haddock {
public static void main(String [] args) {}
void first() {}
void second() {}
void third() {}
static class Sabord {}
}
76. @pingtimeout 76
What is CO ?
• Interval between samples : x
• Usual measurements << x
• Outliers > x
• Subsequent measurements delayed
• After the bad period
77. @pingtimeout 77
What is measured ?
• Service Time's 99th percentile
• ≠ Response Time's 99th percentile
78. @pingtimeout 78
Is it common ?
I rarely see load testers that
don't suffer from it, including
common testers used in the
industry (JMeter, Grinder, HP
LoadRunner) and benchmarks
(YCSB, SPECeverything, etc.)
— Gil Tene
80. @pingtimeout 80
How to fix it ? 1/2
• Know your theoretical send time
• Use it as the start time
• Delayed requests will show the issue
long requestSendTime = expectedSendTimeOfSample(n);
execute(client, get);
long requestTime = System.currentTimeMillis() - requestSendTime;
81. @pingtimeout 81
How to fix it ? 2/2
• Interval between samples
• Use HdrHistogram
• http://giltene.github.io/HdrHistogram/
• class Histogram
• copyCorrectedForCoordinatedOmission(…)
• recordValueWithExpectedInterval(…)
83. @pingtimeout 83
JMH
• Written by Oracle Perf Eng Team
• @shipilev leading
• Code generator
• Multi options runner (# threads, groups,
iterations, …)
• Pluggable profiles
• Multi language
• …
90. @pingtimeout 90
Locks
public class Locks {
@State(Scope.Benchmark)
public static class BenchmarkParameters {
@Param({"1"})
public int burnCpuFactor;
}
@State(Scope.Group)
public static class BaselineState {
private int value = 0;
}
@State(Scope.Group)
public static class SynchronizedState {
private final Object lock = new Object();
private int value = 0;
}
@State(Scope.Group)
public static class ReentrantRWLState {
private final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
private int value = 0;
}
91. @pingtimeout 91
Locks
@Benchmark
@Group("baseline")
public void updateBaseline(BaselineState s, BenchmarkParameters p) {
Blackhole.consumeCPU(p.burnCpuFactor);
s.value++;
}
@Benchmark
@Group("baseline")
public int readBaseline(BaselineState s, BenchmarkParameters p) {
Blackhole.consumeCPU(p.burnCpuFactor);
return s.value;
}