RFR: 8315702: jcmd Thread.dump_to_file slow with millions of virtual threads
Mandy Chung
mchung at openjdk.org
Thu Sep 7 17:47:38 UTC 2023
On Wed, 6 Sep 2023 07:02:53 GMT, Alan Bateman <alanb at openjdk.org> wrote:
> `HotSpotDiagnosticMXBean.dumpThreads` and `jcmd Thread.dump_to_file` are slow when there is a large number of threads.
>
> The thread dump can be sped up significantly with some small changes:
> - Using println rather than format when print thread info and thread stacks
> - Wrap the underlying file output stream in a BufferedOutputStream
>
> With 200k virtual threads on macOS, the plain format thread dump goes from 22s to 1.8s, and the json format thread dump goes from 31s to 2.8s on one system that I tried. On a Linux system, also with 200k threads, the plain thread dump goes from 8.7s to 2.9s, and the json format thread dump from 12.4s to 4.5s.
Looks good to me.
-------------
Marked as reviewed by mchung (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15581#pullrequestreview-1615959218
More information about the serviceability-dev
mailing list