Sending interrupts to the worker threads upon teardown
Aleksey Shipilev
aleksey.shipilev at oracle.com
Mon Apr 14 17:01:19 UTC 2014
Hi Chris,
On 04/14/2014 08:45 PM, Chris Vest wrote:
> However, because of the blocking nature of the queue, there’s a
> pretty high chance that the benchmark will get stuck, because the
> shutdown of the producer does not exactly line up with the shutdown
> of the consumer. The simplest way to fix this, that I can think of,
> is to send them interrupts, since it is a common expectation of well
> behaved blocking methods to respond to interrupts.
Yeah, JMH today is not handing the interrupts well, though I agree
interruptible benchmarks are the legitimate use case. We tried that
before, but in the presence of complex @States with helper methods it
was very prone to errors. We have an item on JMH TODO list to try that
again in the near time.
> Is there a good way to do this already, or is it something that could
> be added in a future version? (Or is my idea bad and I should feel
> bad?)
There is no good way today: @TearDown-s will run only after measurement
threads have left the @GMB methods, so interrupt from there would not
work. The only option I could think of today is to have timed take()-s,
but that will distort the measurement.
-Aleksey.
More information about the jmh-dev
mailing list