Scope.Thread and @Setup bug?
Lev Serebryakov
lev at serebryakov.spb.ru
Wed Sep 28 13:17:02 UTC 2016
On 28.09.2016 10:20, Aleksey Shipilev wrote:
> Anyhow, would be nice to see the MCVE example of the failure, because my
> quick test does not fail:
My minimal code with BlockingQueue<> works too, but I've added
diagnostic message to ISE and got this (please, note, now exception
shows which thread was already registered and which is new one and
violate invariant "only one initialization per thread"):
=========
java.lang.IllegalStateException: Reader thread has been set to
Thread[benchmarks.buffers.Buffers.buf-jmh-worker-1,5,main] but
registerReader() is called again with
Thread[benchmarks.buffers.Buffers.buf-jmh-worker-2,5,main]
at
benchmarks.buffers.impl.fullpadded.siaifus.RingBufferFillAUStatLockSupportFullyPaddedSIntAInt.registerReader(RingBufferFillAUStatLockSupportFullyPaddedSIntAInt.java:96)
at benchmarks.buffers.Buffers$ReaderState.setup(Buffers.java:88)
at
benchmarks.buffers.generated.Buffers_buf_jmhTest._jmh_tryInit_f_readerstate1_0(Buffers_buf_jmhTest.java:735)
at
benchmarks.buffers.generated.Buffers_buf_jmhTest.buf_Throughput(Buffers_buf_jmhTest.java:71)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:444)
at
org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:426)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown
Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
Source)
at java.lang.Thread.run(Unknown Source)
=========
And JMH says about this benchmark:
=========
# Threads: 2 threads (1 group; 1x "reader", 1x "writer" in each group),
will synchronize iterations
=========
BTW, even with timeout = 5 and time = 5, JMH hangs forever in these
tests... Looks like, LockSupport.park() could not be always interrupted.
--
// Black Lion AKA Lev Serebryakov
More information about the jmh-dev
mailing list