2

I take a look at JMH tool.

In sample file JMHSample_03_States they says:

  ============================== HOW TO RUN THIS TEST: ====================================

  You are expected to see the drastic difference in shared and unshared cases,
  because you either contend for single memory location, or not. This effect
  is more articulated on large machines.

  You can run this test:

  a) Via the command line:
     $ mvn clean install
     $ java -jar target/benchmarks.jar JMHSample_03 -wi 5 -i 5 -t 4 -f 1
     (we requested 5 measurement/warmup iterations, with 4 threads, single fork)

My result for java 1.8.20.0 and Intel i5-4670K CPU @ 3.40GHz

# Run complete. Total time: 00:00:24

Benchmark                                   Mode  Samples           Score  Score error  Units
o.s.JMHSample_03_States.measureShared      thrpt        5  1547894580.996  3632128.044  ops/s
o.s.JMHSample_03_States.measureUnshared    thrpt        5  1571371998.011  6150584.658  ops/s

What is the "drastic difference"? Difference between measureShared (1547894580) and measureUnshared (1571371998) less then 2%

qwazer
  • 7,174
  • 7
  • 44
  • 69
  • Well, are you sure you requested 4 threads, as example suggests? – Aleksey Shipilev Sep 19 '14 at 14:14
  • @Aleksey Shipilev Yes, of course. Look at https://gist.github.com/qwazer/cbd8d8300394ae913886 here – qwazer Sep 19 '14 at 15:32
  • Also I notice, than someone has different result https://github.com/artyushov/idea-jmh-plugin/blob/develop/research/results.md May be I need register the bug in bug-tracker? – qwazer Sep 19 '14 at 15:36
  • This does sound like an environmental issue, does not look like a bug yet. How many CPUs your system has? Gist your /proc/cpuinfo, please? – Aleksey Shipilev Sep 19 '14 at 15:37
  • 4 core. https://gist.github.com/qwazer/ecf4e07c56b2b5885a80 – qwazer Sep 19 '14 at 15:39
  • Okay, one more thing. Run the benchmarks, and watch for `mpstat -P ALL 1` on the secondary terminal. Do you have all CPUs busy? – Aleksey Shipilev Sep 19 '14 at 15:40
  • yes: https://gist.github.com/qwazer/05af7a99bb262c712472 – qwazer Sep 19 '14 at 15:47
  • That's weird. This does look like environmental issue, because the difference is perfectly repoducible on other machines I've tried. Can you give me a ssh access to your machine? – Aleksey Shipilev Sep 19 '14 at 15:50
  • It's not very easy for me, becouse I'm behind very restrictive firefall. But I'll try to make the tunnell and will mail it to aleksey@shipilev.net in 15-30 minutes – qwazer Sep 19 '14 at 15:55
  • So did you find out what was the problem? It's very interesting! – Tagir Valeev Aug 17 '15 at 09:56
  • @TagirValeev, no. I give acess to my machine to Aleksey, but we didn't find cause of problem. Aleksey added volatile to JMHSample_03_States http://hg.openjdk.java.net/code-tools/jmh/rev/f481bc602a57. – qwazer Aug 18 '15 at 17:38
  • @aleksey-shipilev @tagir-valeev I found that disabling of the JIT compiler with `-Djava.compiler=NONE` option gives some difference with non-volatile fields on my platform. https://gist.github.com/qwazer/e4341f0153f525f088fa227348e69734 – qwazer Apr 14 '17 at 14:28

0 Answers0