简体   繁体   English

ForkJoinPool 的健康和调整

[英]Health and tuning of ForkJoinPool

I am investigating some performance issues in an app using ForkJoinPool.我正在使用 ForkJoinPool 调查应用程序中的一些性能问题。 We've been at it with Dynatrace and there are indications of some blocking operations which last way too long.我们一直在使用 Dynatrace,有迹象表明一些阻塞操作会持续太长时间。 I cannot find enough information in FJP docs or elsewhere about how to configure and monitor our ForkJoinPools.我在 FJP 文档或其他地方找不到足够的关于如何配置和监控我们的 ForkJoinPools 的信息。

  1. What does parallelism mean in the context of ForkJoinPools, and what are the guidelines/best practice for which values to chose for different thread pools (blocking/non-blocking)?在 ForkJoinPools 的上下文中,并行性是什么意思,以及为不同线程池(阻塞/非阻塞)选择哪些值的指南/最佳实践是什么?

  2. How can I monitor and tune my ForkJoinPool?如何监控和调整我的 ForkJoinPool? We are using ForkJoinPool.toString() which gives some counters, but I cannot find enough information in the javadoc on how to use this stats for tuning.我们正在使用 ForkJoinPool.toString() ,它提供了一些计数器,但我在 javadoc 中找不到关于如何使用此统计信息进行调整的足够信息。 getStealCount() is described as "....should be high enough to keep threads busy, but low enough to avoid overhead and contention accross threads" , which does not really help. getStealCount()被描述为“......应该足够高以保持线程忙碌,但足够低以避免跨线程的开销和争用” ,这并没有真正的帮助。

Example of a toString() toString() 示例

[Running, parallelism = 48, size = 47, active = 0, running = 0, steals
= 33195, tasks = 0, submissions = 0]

To the best of my knowledge, there is no way to tune this "framework.'据我所知,没有办法调整这个“框架”。 Configuration is limited to Parallelism, Thread Factory, Exception Handling and spare threads (see below in parallelism.)配置仅限于并行性、线程工厂、异常处理和备用线程(参见下面的并行性。)

I wrote a critique about the F/J code back in 2011. I upgraded the critique several times and no longer waste my time doing so.早在 2011 年,我就写了一篇关于 F/J 代码的评论。我多次升级了评论,不再浪费时间这样做。

Steal count is totally worthless.偷数是完全没有价值的。

There are no stats on each thread, therefore, active, running, tasks, etc. give you no knowledge about what is going on inside the framework.每个线程都没有统计信息,因此,活动、运行、任务等不会让您了解框架内部发生的事情。 Most of these "monitors" were added as an afterthought years after the original Java7 debut.这些“监视器”中的大多数是在最初的 Java7 首次亮相几年后才添加的。 For instance, for each thread, knowing total compute() methods processed, total waits, etc. would give you an idea of how each thread is performing.例如,对于每个线程,了解处理的计算()方法总数、等待总数等将使您了解每个线程的执行情况。 However, since the framework adds/deletes threads (see below in parallelism) this can never happen.但是,由于框架添加/删除线程(参见下面的并行性),这永远不会发生。 Having a total overall count of any of these monitors doesn't tell you anything useful.对这些监视器中的任何一个进行总计数并不能告诉您任何有用的信息。

join() of course, still has severe problems with blocking (stalling.) If you can use the CountedCompleter Class, you are better off. join() 当然,在阻塞(停滞)方面仍然存在严重问题。如果你可以使用 CountedCompleter 类,你会更好。

Parallelism means the number of initial threads.并行度是指初始线程的数量。 The framework exceeds this number when threads block up to a maximum (java.util.concurrent.ForkJoinPool.common.maximumSpares (this may not be available in Java8 unless it was backported)).当线程阻塞达到最大值(java.util.concurrent.ForkJoinPool.common.maximumSpares(这在Java8 中可能不可用,除非它被向后移植))时,框架会超过这个数字。 The framework adds/deletes threads according to internal rules (you need to look at the code yourself since it is release dependent.) See also Interface ForkJoinPool.ManagedBlocker and the code to support it.框架根据内部规则添加/删除线程(您需要自己查看代码,因为它依赖于版本。)另请参阅接口 ForkJoinPool.ManagedBlocker 和支持它的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM