JMH挂在基准测试之间(无法杀死分叉的JVM?)

时间:2014-02-19 08:04:40

标签: java jvm jmh

我有一大堆宏基准测试来衡量使用不同执行引擎的各种模拟的执行时间(其中一些是非常多线程的)。这些作业中的大多数都使用我在抽象基类中指定的jmh设置:

@ContextConfiguration(value = AbstractJobExecutorBenchmarker.CONTEXT_LOCATION)
@State(Scope.Benchmark)
@Fork(1)
@BenchmarkMode(Mode.SingleShotTime)
@Warmup(iterations = 1, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 5, timeUnit = TimeUnit.MILLISECONDS)
public abstract class AbstractJobExecutorBenchmarker extends AbstractTestNGSpringContextTests

(我还将-gc -si false添加到命令行)

当我触发任何一个基准或一些小子集时,它都能正常工作。然而,如果我尝试一次性运行所有这些(即没有过滤选项),jmh成功地完成了其中的一些,然后在一个特定的基准测试之后突然发生了frezees ...完成它的完成,最终结果被打印,但它看起来像是分叉的JVM被杀死而且新的没有启动,似乎整个过程都被卡住了。打印的最后一个陈述的例子:

Iteration   3: 03:59:52.059 [pool-8-thread-1] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.059 [pool-8-thread-3] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.060 [pool-8-thread-5] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.060 [pool-8-thread-6] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.061 [pool-8-thread-7] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.061 [pool-8-thread-8] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.061 [pool-8-thread-9] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.061 [pool-8-thread-10] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.062 [pool-8-thread-13] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.062 [pool-8-thread-14] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.063 [pool-8-thread-15] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.063 [pool-8-thread-18] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.063 [pool-8-thread-19] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.064 [pool-8-thread-20] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.064 [pool-8-thread-22] INFO  MessageTrafficController: Starting MessageTrafficController
03:59:52.065 [pool-8-thread-25] INFO  MessageTrafficController: Starting MessageTrafficController
04:00:57.600 [pool-8-thread-6] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.601 [pool-8-thread-7] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.604 [pool-8-thread-13] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.604 [pool-8-thread-10] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.603 [pool-8-thread-8] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.604 [pool-8-thread-9] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.606 [pool-8-thread-22] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.608 [pool-8-thread-25] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.606 [pool-8-thread-20] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.605 [pool-8-thread-15] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.606 [pool-8-thread-19] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.606 [pool-8-thread-18] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
04:00:57.604 [pool-8-thread-14] WARN  MessageTrafficController: Stopped due to class java.lang.InterruptedException
65598.920 ms

Result : 76749.529 Âą(99.9%) 804946.698 ms
  Statistics: (min, avg, max) = (39272.712, 76749.529, 125376.954), stdev = 44121.845
  Confidence interval (99.9%): [-728197.169, 881696.226]

如果我手动杀死分叉的JVM,整个过程将解锁。然而,在完成下一个基准后,它再次陷入困境......任何想法为什么会发生?当我分别开启相同的基准时,为什么不会发生呢?

此外,JMH中是否有一些超时选项,如果正常关机需要太长时间,它会强制杀死分叉进程?

1 个答案:

答案 0 :(得分:4)

这已在JMH dev mailing list上得到解答:您需要调试工作负载以禁止杂散线程,挂钩等阻止分叉VM退出。