Skip to content

Instantly share code, notes, and snippets.

@bendlas
Created March 9, 2017 14:57
Show Gist options
  • Save bendlas/6e3b24bb639c248fdc47d192f5117c39 to your computer and use it in GitHub Desktop.
Save bendlas/6e3b24bb639c248fdc47d192f5117c39 to your computer and use it in GitHub Desktop.
Concurrency tests with clojure's STM on JDK 9: #(ref-set % @%) vs ensure
################################################
Benchmarking with `#(ref-set % @%)` ||
================================================
Estimating sampling overhead
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 1210614 iterations
compilation occurred before 2421103 iterations
compilation occurred before 4842081 iterations
compilation occurred before 18157460 iterations
compilation occurred before 21788927 iterations
compilation occurred before 53261641 iterations
compilation occurred before 65366531 iterations
compilation occurred before 133153915 iterations
compilation occurred before 154942717 iterations
compilation occurred before 243308414 iterations
compilation occurred before 306253842 iterations
compilation occurred before 308674820 iterations
compilation occurred before 458775456 iterations
compilation occurred before 461196434 iterations
compilation occurred before 462406923 iterations
compilation occurred before 866710249 iterations
compilation occurred before 2459713773 iterations
compilation occurred before 3253794557 iterations
compilation occurred before 3255005046 iterations
compilation occurred before 3256215535 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Warming up for JIT optimisations 10000000000 ...
classes loaded before 5135 iterations
compilation occurred before 5135 iterations
compilation occurred before 10269 iterations
compilation occurred before 15403 iterations
compilation occurred before 20537 iterations
compilation occurred before 30805 iterations
compilation occurred before 41073 iterations
compilation occurred before 51341 iterations
compilation occurred before 56475 iterations
compilation occurred before 118083 iterations
compilation occurred before 123217 iterations
compilation occurred before 164289 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
amd64 Linux 4.9.13 4 cpu(s)
OpenJDK 64-Bit Server VM 25.121-b13
Runtime arguments: -Dfile.encoding=UTF-8 -Dclojure.compile.path=/home/herwig/checkout/workbench/target/classes -Dworkbench.version=0 -Dclojure.debug=false
Evaluation count : 2862480 in 60 samples of 47708 calls.
Execution time sample mean : 32.234587 µs
Execution time mean : 32.254517 µs
Execution time sample std-deviation : 7.835514 µs
Execution time std-deviation : 7.869243 µs
Execution time lower quantile : 19.489568 µs ( 2.5%)
Execution time upper quantile : 48.487960 µs (97.5%)
Overhead used : 1.841015 ns
################################################
Benchmarking with `ensure` ||
================================================
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 16043 iterations
compilation occurred before 64169 iterations
compilation occurred before 96253 iterations
compilation occurred before 112295 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Evaluation count : 636420 in 60 samples of 10607 calls.
Execution time mean : 51.671340 µs
Execution time std-deviation : 53.353572 µs
Execution time lower quantile : 17.179265 µs ( 2.5%)
Execution time upper quantile : 179.092669 µs (97.5%)
Overhead used : 1.841015 ns
Found 9 outliers in 60 samples (15.0000 %)
low-severe 4 (6.6667 %)
low-mild 5 (8.3333 %)
Variance from outliers : 98.3097 % Variance is severely inflated by outliers
################################################
Benchmarking with `#(ref-set % @%)` ||
================================================
Estimating sampling overhead
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 1055549 iterations
compilation occurred before 55934425 iterations
compilation occurred before 135086650 iterations
compilation occurred before 265951662 iterations
compilation occurred before 268062388 iterations
compilation occurred before 269117751 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 6669 iterations
compilation occurred before 33341 iterations
classes loaded before 200041 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
amd64 Linux 4.9.13 4 cpu(s)
OpenJDK 64-Bit Server VM 25.121-b13
Runtime arguments: -Dfile.encoding=UTF-8 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-OmitStackTraceInFastThrow -Dclojure.compile.path=/home/herwig/checkout/workbench/target/classes -Dworkbench.version=0 -Dclojure.debug=false
Evaluation count : 1781520 in 60 samples of 29692 calls.
Execution time sample mean : 26.144153 µs
Execution time mean : 26.154586 µs
Execution time sample std-deviation : 1.982248 µs
Execution time std-deviation : 2.007116 µs
Execution time lower quantile : 24.874062 µs ( 2.5%)
Execution time upper quantile : 31.160440 µs (97.5%)
Overhead used : 9.162284 ns
Found 9 outliers in 60 samples (15.0000 %)
low-severe 5 (8.3333 %)
low-mild 4 (6.6667 %)
Variance from outliers : 56.8286 % Variance is severely inflated by outliers
################################################
Benchmarking with `ensure` ||
================================================
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 7894 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Evaluation count : 591360 in 60 samples of 9856 calls.
Execution time mean : 247.054819 µs
Execution time std-deviation : 450.286947 µs
Execution time lower quantile : 34.829207 µs ( 2.5%)
Execution time upper quantile : 1.007922 ms (97.5%)
Overhead used : 9.162284 ns
Found 6 outliers in 60 samples (10.0000 %)
low-severe 3 (5.0000 %)
low-mild 3 (5.0000 %)
Variance from outliers : 98.3258 % Variance is severely inflated by outliers
################################################
Benchmarking with `#(ref-set % @%)` ||
================================================
Estimating sampling overhead
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 498957 iterations
compilation occurred before 997828 iterations
compilation occurred before 13469603 iterations
compilation occurred before 14966216 iterations
compilation occurred before 66848800 iterations
compilation occurred before 96282189 iterations
compilation occurred before 110749448 iterations
compilation occurred before 125715578 iterations
compilation occurred before 127212191 iterations
compilation occurred before 190568808 iterations
compilation occurred before 253925425 iterations
compilation occurred before 254424296 iterations
compilation occurred before 994748860 iterations
compilation occurred before 1201780325 iterations
compilation occurred before 1284094040 iterations
compilation occurred before 1372893078 iterations
compilation occurred before 1373391949 iterations
compilation occurred before 1378879530 iterations
compilation occurred before 1421782436 iterations
compilation occurred before 2664470097 iterations
compilation occurred before 2680433969 iterations
compilation occurred before 2680932840 iterations
compilation occurred before 2681431711 iterations
compilation occurred before 2711363971 iterations
compilation occurred before 2711862842 iterations
compilation occurred before 2712361713 iterations
compilation occurred before 2744289457 iterations
compilation occurred before 2744788328 iterations
compilation occurred before 2751772522 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 1 iterations
compilation occurred before 242 iterations
compilation occurred before 483 iterations
compilation occurred before 724 iterations
compilation occurred before 965 iterations
compilation occurred before 1206 iterations
compilation occurred before 1447 iterations
compilation occurred before 1688 iterations
compilation occurred before 1929 iterations
compilation occurred before 2170 iterations
classes loaded before 2411 iterations
compilation occurred before 2411 iterations
compilation occurred before 2652 iterations
compilation occurred before 2893 iterations
compilation occurred before 3134 iterations
classes loaded before 3375 iterations
compilation occurred before 3375 iterations
compilation occurred before 3616 iterations
compilation occurred before 3857 iterations
compilation occurred before 4098 iterations
compilation occurred before 6990 iterations
compilation occurred before 7231 iterations
compilation occurred before 7472 iterations
compilation occurred before 7954 iterations
compilation occurred before 8436 iterations
compilation occurred before 8677 iterations
compilation occurred before 8918 iterations
compilation occurred before 9641 iterations
compilation occurred before 10123 iterations
compilation occurred before 10364 iterations
compilation occurred before 10605 iterations
compilation occurred before 10846 iterations
compilation occurred before 11087 iterations
compilation occurred before 11569 iterations
compilation occurred before 12051 iterations
compilation occurred before 12774 iterations
compilation occurred before 17353 iterations
compilation occurred before 19040 iterations
compilation occurred before 20004 iterations
compilation occurred before 21209 iterations
compilation occurred before 21450 iterations
compilation occurred before 21691 iterations
compilation occurred before 21932 iterations
compilation occurred before 22414 iterations
compilation occurred before 22896 iterations
compilation occurred before 23378 iterations
compilation occurred before 23619 iterations
compilation occurred before 23860 iterations
compilation occurred before 24101 iterations
compilation occurred before 24342 iterations
compilation occurred before 30367 iterations
compilation occurred before 30608 iterations
compilation occurred before 30849 iterations
compilation occurred before 31813 iterations
compilation occurred before 50852 iterations
compilation occurred before 51816 iterations
compilation occurred before 53503 iterations
compilation occurred before 53744 iterations
compilation occurred before 54467 iterations
compilation occurred before 55913 iterations
compilation occurred before 204369 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
amd64 Linux 4.9.13 4 cpu(s)
OpenJDK 64-Bit Server VM 25.121-b13
Runtime arguments: -Dfile.encoding=UTF-8 -Dclojure.compile.path=/home/herwig/checkout/workbench/target/classes -Dworkbench.version=0 -Dclojure.debug=false
Evaluation count : 3212460 in 60 samples of 53541 calls.
Execution time sample mean : 20.325117 µs
Execution time mean : 20.394039 µs
Execution time sample std-deviation : 4.736416 µs
Execution time std-deviation : 4.858468 µs
Execution time lower quantile : 17.391064 µs ( 2.5%)
Execution time upper quantile : 28.241414 µs (97.5%)
Overhead used : 1.686357 ns
Found 3 outliers in 60 samples (5.0000 %)
low-severe 2 (3.3333 %)
low-mild 1 (1.6667 %)
Variance from outliers : 92.9336 % Variance is severely inflated by outliers
################################################
Benchmarking with `ensure` ||
================================================
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 1 iterations
compilation occurred before 523 iterations
compilation occurred before 1045 iterations
compilation occurred before 1567 iterations
compilation occurred before 2611 iterations
compilation occurred before 3133 iterations
compilation occurred before 6265 iterations
compilation occurred before 7831 iterations
compilation occurred before 9397 iterations
compilation occurred before 9919 iterations
compilation occurred before 40717 iterations
compilation occurred before 41761 iterations
compilation occurred before 47503 iterations
compilation occurred before 48025 iterations
compilation occurred before 55855 iterations
compilation occurred before 66817 iterations
compilation occurred before 68905 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Evaluation count : 3541500 in 60 samples of 59025 calls.
Execution time mean : 51.024348 µs
Execution time std-deviation : 79.437042 µs
Execution time lower quantile : 16.763331 µs ( 2.5%)
Execution time upper quantile : 321.103467 µs (97.5%)
Overhead used : 1.686357 ns
Found 10 outliers in 60 samples (16.6667 %)
low-severe 4 (6.6667 %)
low-mild 6 (10.0000 %)
Variance from outliers : 98.3229 % Variance is severely inflated by outliers
################################################
Benchmarking with `#(ref-set % @%)` ||
================================================
Estimating sampling overhead
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 113003 iterations
compilation occurred before 2935028 iterations
compilation occurred before 14561771 iterations
compilation occurred before 24946823 iterations
compilation occurred before 28671896 iterations
compilation occurred before 28784777 iterations
compilation occurred before 57682313 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Warming up for JIT optimisations 10000000000 ...
classes loaded before 148 iterations
compilation occurred before 148 iterations
compilation occurred before 295 iterations
compilation occurred before 442 iterations
compilation occurred before 589 iterations
compilation occurred before 17641 iterations
compilation occurred before 30283 iterations
compilation occurred before 30724 iterations
compilation occurred before 165523 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
amd64 Linux 4.9.13 4 cpu(s)
OpenJDK 64-Bit Server VM 25.121-b13
Runtime arguments: -Dfile.encoding=UTF-8 -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:-OmitStackTraceInFastThrow -Dclojure.compile.path=/home/herwig/checkout/workbench/target/classes -Dworkbench.version=0 -Dclojure.debug=false
Evaluation count : 1688940 in 60 samples of 28149 calls.
Execution time sample mean : 46.785326 µs
Execution time mean : 46.824538 µs
Execution time sample std-deviation : 10.839865 µs
Execution time std-deviation : 10.959179 µs
Execution time lower quantile : 28.454837 µs ( 2.5%)
Execution time upper quantile : 67.065161 µs (97.5%)
Overhead used : 10.710613 ns
################################################
Benchmarking with `ensure` ||
================================================
Warming up for JIT optimisations 10000000000 ...
compilation occurred before 1 iterations
compilation occurred before 547 iterations
Estimating execution count ...
Sampling ...
Final GC...
Checking GC...
Finding outliers ...
Bootstrapping ...
Checking outlier significance
Evaluation count : 127200 in 60 samples of 2120 calls.
Execution time mean : 481.183373 µs
Execution time std-deviation : 1.402499 ms
Execution time lower quantile : 28.071601 µs ( 2.5%)
Execution time upper quantile : 2.342209 ms (97.5%)
Overhead used : 10.710613 ns
Found 10 outliers in 60 samples (16.6667 %)
low-severe 1 (1.6667 %)
low-mild 9 (15.0000 %)
Variance from outliers : 98.3304 % Variance is severely inflated by outliers
(ns workbench
(:require [criterium.core :as bench]))
(defn write-skew [de-ref]
(let [cats (ref 1)
dogs (ref 1)
john (future
(dosync
(when (< (+ @cats (de-ref dogs)) 3)
(alter cats inc))))
mary (future
(dosync
(when (< (+ (de-ref cats) @dogs) 3)
(alter dogs inc))))]
(do @john @mary)
(dosync
(> (+ @cats @dogs) 3))))
(defn -main []
(println "
################################################
Benchmarking with `#(ref-set % @%)` ||
================================================")
(bench/with-progress-reporting
(bench/bench (write-skew (fn [x] (ref-set x @x))) :verbose))
(println "
################################################
Benchmarking with `ensure` ||
================================================")
(bench/with-progress-reporting
(bench/bench (write-skew ensure))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment