Académique Documents
Professionnel Documents
Culture Documents
Benchmarking is $as'000
///%a&"ls'stems%com
1 1 1 1
An# F"n000 2M' Java is faster than 'o"r C0003 An# generall' /rong%%% Without exception every microbenchmark 45ve seen has ha# serious fla/s
6 $7ce8t those 45ve ha# a han# in correcting
1 Serious 9
6 2)core3 is "nrelate# to inten#e# meas"rement or 6 error bars e7cee# meas"re# val"es
1 CaffeineMark 2logic3
6 triviall' ma#e #ea# b' J4TG infinite s8ee#"8
1 )ciMark- Monte-Carlo
6 H.I of time in s'nc5# >an#om%ne7t 6 )everal foc"se# tests #ea#G infinite s8ee#"8
1 )8ecJVMJH K--<Kmtrt
6 >"ntime is m"ch less than * sec
1 CaffeineMark 2logic3
6 triviall' ma#e #ea# b' J4TG infinite s8ee#"8
1 )ciMark- Monte-Carlo
6 H.I of time in s'nc5# >an#om%ne7t 6 )everal foc"se# tests #ea#G infinite s8ee#"8
1 )8ecJVMJH K--<Kmtrt
6 >"ntime is m"ch less than * sec
!ea# Loo8s
///%a&"ls'stems%com
1 TimelineL
// how fast is divide-by-10? long start = Sys.CTM() for( int i=0 i!" i## ) int $ = i/10 ret%rn "&1000/(Sys.CTM()-start)
1 Time to r"nL -.ms ? Independent of N! 6 Var' O 99P var' score 99P 2!ial-o-)core03
!ea# Loo8s
///%a&"ls'stems%com
)ciMark- Monte-Carlo
///%a&"ls'stems%com
1 H.I of time in syn'hroni(e5# >an#om%ne7t 1 N-letter-com8an' 2s8amme#3 it b' re8lacing /ith intrinsic
#oing a Com8areAn#)/a8 (CA))
1 1 1 1 1
4 /as or#ere# to follo/ s"it (match 8erformance) !o"g Lea sai# 2/aitL @"st make a CA) from Java3 Hence s"n%misc%AtomicLong /as born >a8i#l' re8lace# b' Rnsafe%com8areAn#)/a8%%% %%%an# event"all' @ava%lang%AtomicS
6 Base# on ver' volatile ran#om #ata 6 4nline #ecisions var' from r"n-to-r"n
8"blic int a() W for(%%%) b()G X 8"blic int b() W for(%%%) c()G X 8"blic int c() W Y/ork%%% X
AL loo8*L Y call B @ne loo8* ret"rn BL loo8-L %%% @ne loo8Y ret"rn
'lass ben'h1 i)*le)ents ben'h + void s,rt(int i) 'lass ben'h. i)*le)ents ben'h + void s,rt(int i) stati' final int "=1000000 // )illion ... stati' int test( ben'h / ) + long start = Syste).'%rrentTi)eMillis() for( int i=0 i!" i## ) /.s,rt(i) // hot loo* v-'all ret%rn "&1000/(Syste).'%rrentTi)eMillis()-start)
: ;-..< A&"l )'stems, 4nc%
'lass ben'h1 i)*le)ents ben'h + void s,rt(int i) 'lass ben'h. i)*le)ents ben'h + void s,rt(int i) stati' final int "=1000000 // )illion ... stati' int test( ben'h / ) + long start = Syste).'%rrentTi)eMillis() for( int i=0 i!" i## ) /.s,rt(i) // hot loo* v-'all ret%rn "&1000/(Syste).'%rrentTi)eMillis()-start)
: ;-..< A&"l )'stems, 4nc%
long start = Sys.CTM() for( int i=0 i!" i## ) /.s,rt(i) ret%rn "&1000/(Sys.CTM()-start)
long start = Sys.CTM() for( int i=0 i!" i## ) /.s,rt(i) ret%rn "&1000/(Sys.CTM()-start) long start = Sys.CTM() g"ar#e# for( int i=0 i!" i## ) inline Math.s,rt(i) // inline ben'h1.s,rt ret%rn "&1000/(Sys.CTM()-start)
long start = Sys.CTM() long start = Sys.CTM() // 01T2d loo* re)oved for( int i=0 i!" i## ) ret%rn "&1000/(Sys.CTM()-start) /.s,rt(i) ret%rn "&1000/(Sys.CTM()-start) long start = Sys.CTM() g"ar#e# for( int i=0 i!" i## ) #ea# co#e inline Math.s,rt(i) // inline ben'h1.s,rt ret%rn "&1000/(Sys.CTM()-start)
long start = Syste).CTM() for( int i=0 i!" i## ) /.s,rt(i) ret%rn "&1000/(Syste).CTM()-start)
: ;-..< A&"l )'stems, 4nc%
ben'h.)
ben'h.)
'lass ben'h1 i)*le)ents ben'h + void s,rt(int i) 'lass ben'h. i)*le)ents ben'h + void s,rt(int i) ... // war)%* loo* for( int i=0 i!10 i## ) + test( new ben'h1 ) test( new ben'h. ) // now try ti)ing *rintf(test(new ben'h1))
: ;-..< A&"l )'stems, 4nc%
ben'h.)
'lass ben'h1 i)*le)ents ben'h + void s,rt(int i) 'lass ben'h. i)*le)ents ben'h + void s,rt(int i) ... // war)%* loo* for( int i=0 i!10 i## ) + test( new ben'h1 ) test( new ben'h. ) // now try ti)ing *rintf(test(new ben'h1))
: ;-..< A&"l )'stems, 4nc%
Micro-bench A#viceL =C
///%a&"ls'stems%com
1 )tatisticsL not @"st average, b"t also st#-#ev 1 Look for tren#s
6 Co"l# be cree8ing =C behavior
1 Acco"nt for m"lti-threa#e# locking 1 4 do see 8eo8le testing, e%g% locking costs on singlethrea#e# 8rograms
1 Very slightly conten#e# lock is 8robabl' +7 more 1 Real contentionL Am#ahl5s La/
6 Bl"s lots and lots of F) overhea#
Micro-bench A#vice
///%a&"ls'stems%com
1 >ealistic r"ntimes
6 Rnless 'o" nee# s"b-milli-sec reboots
1 1 1 1 1
Aarm-"8 loo8s - give the J4T a chance )tatisticsL 8lan for variation in res"lts !ea# loo8s ? look for 2!ial-o-)core03, #eal /ith it *st r"n fast, -n# r"n slo/ ? look for it, #eal /ith it =CL avoi# or embrace
Macro-bench /arnings
///%a&"ls'stems%com
1 JBB-..., -..M
6 Oot m"ch har#er target 6 V$>E 8o8"lar, eas' eno"gh to 2s8am3 6 )core rarel' relate# to an'thing real
Macro-bench /arnings
///%a&"ls'stems%com
1 Bo8"lar ones are targete# b' com8anies 1 =eneral i#eaL JVM engineers are honest
6 B"t /ant the best for com8an' 6 )o #o targete# o8timi&ations 6 e%g% intrinsic CA) for >an#om%ne7t 6 Brobabl' "sef"l to somebo#' 6 Oever incorrect 6 !efinitel' hel8s this benchmark
1 1 1 1
Benchmark C becomes 8o8"lar Management tells $ngineerL 24m8rove C5s score03 $ngineer #oes an in-#e8th st"#' of C !eci#es o8timi&ation 2E3 /ill hel8
6 An# E is not broken for an'bo#' 6 Bossibl' hel8s some other 8rogram
1 4m8lements shi8s a JVM /ith 2E3 1 Management anno"nces score of 2C3 is no/ -SC 1 Rsers 'a/n in #isbeliefL 2E3 #oes not hel8 them
)8ecJBB-...
///%a&"ls'stems%com
1 Te' to 8erformanceL
)8ecJBB-...L )8amming
///%a&"ls'stems%com
flags
6 Across man' ven#ors 6 Man' rolle# into 2-CCLZAggressiveF8timi&ations3 6 =oalL no ol#-gen =C in + min"tes
)8ecJBB-...L )8amming
///%a&"ls'stems%com
flags
6 Across man' ven#ors 6 Man' rolle# into 2-CCLZAggressiveF8timi&ations3 6 =oalL no ol#-gen =C in + min"tes
behavior 6 Most /eb-servers s"ffer from FL!-gen =C iss"es 6 4m8roving 'o"ng-gen #i#n5t hel8 /eb-servers m"ch
)8ecJBB-..M
///%a&"ls'stems%com
(CTOs are #ela'e# too long) 6 )ame as JBB-..., b"t more CML 6 Oee#s some JavaD-isms o8timi&e#
1 )till embarrassing 8arallel ? 'o"ng-gen =C test 1 A&"l ran "8 to *<.. /areho"se(threa#s
on a NM.=ig hea8, allocating -.=igab'tes(sec for N%M #a's an# )T4LL no ol#-gen =C
)8ecJBB-..M
///%a&"ls'stems%com
(CTOs are #ela'e# too long) 6 )ame as JBB-..., b"t more CML 6 Oee#s some JavaD-isms o8timi&e#
1 )till embarrassing 8arallel ? 'o"ng-gen =C test 1 A&"l ran "8 to *<.. /areho"se(threa#s
on a NM.=ig hea8, allocating -.=igab'tes(sec for N%M #a's an# )T4LL no ol#-gen =C
str"ct"re, not JVM 6 ---Km8ega"#io ? s"b@ect to o## FB o8timi&ations 6 --HK@ack ? thro/s heav' e7ce8tions ? b"t so #o man' a88serversG also 8arsers are 8o8"lar% 4m8rovements here might carr' over 6 -*NK@avac ? genericall' "sef"l metric for mo#est CBR bo"n# a88lications
cache
str"ct"re, not JVM 6 ---Km8ega"#io ? s"b@ect to o## FB o8timi&ations 6 --HK@ack ? thro/s heav' e7ce8tions ? b"t so #o man' a88serversG also 8arsers are 8o8"lar% 4m8rovements here might carr' over 6 -*NK@avac ? genericall' "sef"l metric for mo#est CBR bo"n# a88lications
cache
)8ecJA88)erver
///%a&"ls'stems%com
1 1 1 1
Oee# a #ecent (not great) JVM (e%g% =C is V MI) B"t 8eak score #e8en#s on an "ber-!B an# fast #isk or net/ork 1 Oot so heavil' o8timi&e# b' JVM $ngineers 1 Lots of 2fle73 in set"8 r"les (!B net/ork config)
)8ecJA88)erver
///%a&"ls'stems%com
1 1 1 1
Oee# a #ecent (not great) JVM (e%g% =C is V MI) B"t 8eak score #e8en#s on an "ber-!B an# fast #isk or net/ork 1 Oot so heavil' o8timi&e# b' JVM $ngineers 1 Lots of 2fle73 in set"8 r"les (!B net/ork config)
!aCa8o
///%a&"ls'stems%com
1 1 1 1 1 1 1
Less 8o8"lar so less o8timi&e# >ealistic of mi#-si&e# BFJF a88s OFT t'8ical of a88-servers, J-$$ st"ff $78ect *...5s of classes loa#e# metho#s J4T5# )ome 4(F, more t'8ical =C behavior M"ch better score re8orting r"les !aCa8o "8gra#es coming soon0
6 Oe/ version has /eb-servers
8arallel co#es
!aCa8o
///%a&"ls'stems%com
1 1 1 1 1 1 1
Less 8o8"lar so less o8timi&e# >ealistic of mi#-si&e# BFJF a88s OFT t'8ical of a88-servers, J-$$ st"ff $78ect *...5s of classes loa#e# metho#s J4T5# )ome 4(F, more t'8ical =C behavior M"ch better score re8orting r"les !aCa8o "8gra#es coming soon0
6 Oe/ version has /eb-servers
8arallel co#es
1 CMLMark
6 Berf varies b' *.7 base# on CML 8arser J!T version 6 Too-/ell-behave# 'o"ng-gen allocation 6 Like !aCa8o ? more realistic of mi#-si&e# BFJF a88s
6 Ver' 8arallel (not a contention benchmark)
1 )8ecJVM-..H
6 Also like !aCa8o ? realisticall' si&e# BFJF a88s 6 B"t also has /eb-servers 8arallel a88s 6 Oe/er, not so heavil' targete# b' Ven#ors
1 CMLMark
6 Berf varies b' *.7 base# on CML 8arser J!T version 6 Too-/ell-behave# 'o"ng-gen allocation 6 Like !aCa8o ? more realistic of mi#-si&e# BFJF a88s
6 Ver' 8arallel (not a contention benchmark)
1 )8ecJVM-..H
6 Also like !aCa8o ? realisticall' si&e# BFJF a88s 6 B"t also has /eb-servers 8arallel a88s 6 Oe/er, not so heavil' targete# b' Ven#ors
1 Rnrealistic treatment of =C
6 e%g% Oone in time# /in#o/ 6 Fr 8erfect 'o"ng-gen collections 6 >eal a88s t'8ical trigger f"ll =C ever' ho"r or so
1 4(F
6 B"t make a h"ge #ifference in >eal Life 6 Eo"r a88 might share 4(F !B /ith others
)"mmar'
///%a&"ls'stems%com
1 Macrobenchmarks
6 Targete# b' JVM $ngineers 6 Buyer Beware! 6 The closer the benchmark is to 'o"r 8roblem 6 The more likel' im8rovements /ill im8act 'o" 6 =C is likel' to not be typical of real a88lications 6 Your a88lications ever go N%M #a's /itho"t a f"ll =C[ 6 4(F !B loa# also 8robabl' not t'8ical
)"mmar'
///%a&"ls'stems%com
1 Microbenchmarks
$as' to Arite, Har# to get >ight Easy to be Fooled Aon5t tell 'o" m"ch abo"t macro-co#e an'/a's ar!u" ? *5s of secon#s to *.5s of secon#s Statistics ? average lots of r"ns 6 $ven o"t variations in the 2com8ile 8lan3 6 Call out to man' metho#s in the hot loo8 6 Be /ar' of dead#code s"8er-score res"lts
6 6 6 6 6
///%a&"ls'stems%com
///%a&"ls'stems%com