-
-
Save hozumi/3048d90328d3118583a4 to your computer and use it in GitHub Desktop.
on SL6.0(x86_64) at C2D/2.4GHz(VM) x 2C, mem 1GB
(def thread-count 300)
(def repeat-num 100000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core atom-bench
"Elapsed time: 21790.753297 msecs"
real 0m22.915s user 0m39.346s sys 0m2.594s
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core hash-bench
"Elapsed time: 22829.410391 msecs"
real 0m23.960s user 0m40.413s sys 0m3.032s
(def thread-count 1)
(def repeat-num 30000000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 50793.495805 msecs"
real 0m51.917s user 0m51.809s sys 0m1.240s
(def thread-count 2)
(def repeat-num 15000000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 79318.288035 msecs"
real 1m20.478s user 2m9.840s sys 0m16.127s
(def thread-count 5)
(def repeat-num 6000000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 60840.602644 msecs"
real 1m2.025s user 1m2.295s sys 0m4.023s
JDK1.6.0_24 on OSX10.6 at C2D/2.4GHz x 2C, mem 4GB
(def thread-count 300)
(def repeat-num 100000)
$ time java -d32 -server -ms256M -mx256M -cp lib/clojure-1.3.0-beta1.jar:classes bench.core atom-bench
"Elapsed time: 15938.494 msecs"
real 0m17.271s user 0m32.024s sys 0m0.571s
$ time java -d64 -server -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core atom-bench
"Elapsed time: 19769.618 msecs"
real 0m20.981s user 0m39.054s sys 0m0.719s
$ time java -d32 -server -ms256M -mx256M -cp lib/clojure-1.3.0-beta1.jar:classes bench.core hash-bench
"Elapsed time: 18469.355 msecs"
real 0m19.809s user 0m36.015s sys 0m0.457s
$ time java -d64 -server -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core hash-bench
"Elapsed time: 64242.953 msecs"
real 1m5.472s user 1m1.936s sys 0m34.415s
(def thread-count 1)
(def repeat-num 30000000)
$ time java -d32 -server -ms256M -mx256M -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 66448.203 msecs"
real 1m7.750s user 1m8.639s sys 0m0.497s
$ time java -d64 -server -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 65525.307 msecs"
real 1m6.693s user 1m7.295s sys 0m0.540s
(def thread-count 5)
(def repeat-num 6000000)
$ time java -d32 -server -ms256M -mx256M -cp lib/clojure-1.3.0-beta1.jar:classes bench.core
"Elapsed time: 97204.37 msecs" ref-bench
real 1m38.541s user 2m55.565s sys 0m12.372s
$ time java -d64 -server -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 183678.22 msecs"
real 3m4.897s user 3m47.993s sys 1m40.321s
共有資源に高頻度で書き込む並列性のないスレッド間処理をするなら、同時実行できるのがシングルスレッドもしくは、共有しなくて済むような枠組みを考えた方が良さそうです。
適切に動作しないマルチスレッド アプリケーションの一般的なパターン
http://msdn.microsoft.com/ja-jp/library/ee329530.aspx
STMは共有資源に複数のスレッドが書き込みを試みて、共有資源が他のスレッドに既に更新されてれば失敗してやり直すという処理なので、逆に言えば、実行中のスレッドの中の必ず一つは書き込みに成功するということだと思います。
実行中のどの時間を見ても必ず書き込みに成功するスレッドが一ついるということはつまり、
原理的にはシングルスレッドと同じ時間で処理できることを意味していると思います。
シングルスレッドやロック(hash-bench)の時は使われていなかったコアが無駄な計算をするだけで、
処理にかかる時間が劇的に伸びるのはどうもよく理解出来ないです。
on SL6.0(x86_64) at C2D/2.4GHz(VM) x 1C, mem 1GB
(def thread-count 300)
(def repeat-num 100000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core atom-bench
"Elapsed time: 12895.192333 msecs"
real 0m14.113s user 0m13.398s sys 0m0.361s
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core hash-bench
"Elapsed time: 22023.822917 msecs"
real 0m23.336s user 0m22.571s sys 0m0.282s
(def thread-count 1)
(def repeat-num 30000000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 38797.987308 msecs"
real 0m40.009s user 0m39.369s sys 0m0.386s
(def thread-count 2)
(def repeat-num 15000000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 42579.257926 msecs"
real 0m43.823s user 0m42.618s sys 0m0.967s
(def thread-count 5)
(def repeat-num 6000000)
$ time /usr/java/jdk1.7.0/bin/java -d64 -ms256M -mx256M -XX:+UseCompressedOops -cp lib/clojure-1.3.0-beta1.jar:classes bench.core ref-bench
"Elapsed time: 51573.837598 msecs"
real 0m52.858s user 0m51.050s sys 0m1.529s