Skip to content

Instantly share code, notes, and snippets.

@CodingFabian
Last active November 9, 2015 22:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodingFabian/9058922 to your computer and use it in GitHub Desktop.
Save CodingFabian/9058922 to your computer and use it in GitHub Desktop.
Benchmark for my concurrency improvements for joda time.
Improving JodaTime Concurrency for XYZChronology.getInstance()
Model Name: MacBook Pro
Model Identifier: MacBookPro11,3
Processor Name: Intel Core i7
Processor Speed: 2,3 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 6 MB
Memory: 16 GB
Using JMH and Java 7u45, Tested Single Threaded and with 3 Threads
# Before the changes (https://github.com/JodaOrg/joda-time/commit/f17223a4974f3e55097456441d7386735c97ffd6)
Fabians-MacBook-Pro:test fabian$ java -jar target/microbenchmarks.jar -f 2 -wi 5 -i 10 -t 1 ".*JodaBenchmark.*"
Benchmark Mode Samples Mean Mean error Units
o.j.t.JodaBenchmark.BuddhistChronology thrpt 20 25841.694 998.251 ops/ms
o.j.t.JodaBenchmark.CopticChronology thrpt 20 43078.128 184.048 ops/ms
o.j.t.JodaBenchmark.GJChronology thrpt 20 13396.979 71.886 ops/ms
o.j.t.JodaBenchmark.GregorianChronology thrpt 20 42798.998 226.985 ops/ms
o.j.t.JodaBenchmark.ISOChronology thrpt 20 322809.803 1758.325 ops/ms
o.j.t.JodaBenchmark.IslamicChronology thrpt 20 39569.958 2256.253 ops/ms
o.j.t.JodaBenchmark.JulianChronology thrpt 20 42688.621 389.241 ops/ms
Fabians-MacBook-Pro:test fabian$ java -jar target/microbenchmarks.jar -f 2 -wi 5 -i 10 -t 3 ".*JodaBenchmark.*"
Benchmark Mode Samples Mean Mean error Units
o.j.t.JodaBenchmark.BuddhistChronology thrpt 20 12870.201 29.631 ops/ms
o.j.t.JodaBenchmark.CopticChronology thrpt 20 20658.471 259.044 ops/ms
o.j.t.JodaBenchmark.GJChronology thrpt 20 7158.990 244.942 ops/ms
o.j.t.JodaBenchmark.GregorianChronology thrpt 20 19346.941 1118.202 ops/ms
o.j.t.JodaBenchmark.ISOChronology thrpt 20 944874.377 6195.881 ops/ms
o.j.t.JodaBenchmark.IslamicChronology thrpt 20 19922.005 857.766 ops/ms
o.j.t.JodaBenchmark.JulianChronology thrpt 20 21101.986 42.799 ops/ms
Conclusion: The synchronization hurts multithreading performance, reducing efficiency to 50%. Only ISOChronology with its "fast" cache scales.
# After the changes (https://github.com/CodingFabian/joda-time/tree/avoid_lock_contention_chonology_cache)
Fabians-MacBook-Pro:test fabian$ java -jar target/microbenchmarks.jar -f 2 -wi 5 -i 10 -t 1 ".*JodaBenchmark.*"
Benchmark Mode Samples Mean Mean error Units
o.j.t.JodaBenchmark.BuddhistChronology thrpt 20 91189.119 1028.652 ops/ms
o.j.t.JodaBenchmark.CopticChronology thrpt 20 83795.233 533.833 ops/ms
o.j.t.JodaBenchmark.GJChronology thrpt 20 13026.649 101.089 ops/ms
o.j.t.JodaBenchmark.GregorianChronology thrpt 20 83723.907 546.798 ops/ms
o.j.t.JodaBenchmark.ISOChronology thrpt 20 324468.325 2122.884 ops/ms
o.j.t.JodaBenchmark.IslamicChronology thrpt 20 83633.283 422.543 ops/ms
o.j.t.JodaBenchmark.JulianChronology thrpt 20 83837.379 564.661 ops/ms
Fabians-MacBook-Pro:test fabian$ java -jar target/microbenchmarks.jar -f 2 -wi 5 -i 10 -t 3 ".*JodaBenchmark.*"
Benchmark Mode Samples Mean Mean error Units
o.j.t.JodaBenchmark.BuddhistChronology thrpt 20 267918.607 4046.096 ops/ms
o.j.t.JodaBenchmark.CopticChronology thrpt 20 243143.939 4214.440 ops/ms
o.j.t.JodaBenchmark.GJChronology thrpt 20 44552.761 3072.997 ops/ms
o.j.t.JodaBenchmark.GregorianChronology thrpt 20 244300.326 4928.798 ops/ms
o.j.t.JodaBenchmark.ISOChronology thrpt 20 946187.053 8575.379 ops/ms
o.j.t.JodaBenchmark.IslamicChronology thrpt 20 241865.596 2067.272 ops/ms
o.j.t.JodaBenchmark.JulianChronology thrpt 20 244272.077 1278.080 ops/ms
Conclusion: Now linar scaling for all Chronologies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment