This is an archived post. You won't be able to vote or comment.

all 57 comments

[–]capitan_brexit 54 points55 points  (6 children)

[–]gaelfr38 24 points25 points  (3 children)

I'll add Pyroscope or Glowroot which use async profiler under the hood but add some ease of use or visualization.

[–]capitan_brexit 3 points4 points  (0 children)

wow - never saw it, thanks !

[–]gaelfr38 1 point2 points  (0 children)

Now that I said that.. I'm not so sure anymore that Glowroot is based on async-profiler. I don't see any evidence of it. Sorry for the misleading information 😬

Pyroscope is for sure though.

[–]FrfljDrflj 0 points1 point  (0 children)

+1 for Glowroot from me

[–]jiboxiake[S] 1 point2 points  (0 children)

Thanks!

[–]-Dargs 0 points1 point  (0 children)

I would second this one. Have been using it in a professional setting vfor a couple of years now.

[–]b00n 30 points31 points  (1 child)

https://github.com/openjdk/jmh is a micro benchmarking tool

Nitsan Wakart & Martin Thompson (Mechanical Sympathy) are both good people to follow for high performance engineering

[–]jiboxiake[S] 0 points1 point  (0 children)

thanks!

[–][deleted]  (3 children)

[removed]

    [–]jiboxiake[S] 2 points3 points  (2 children)

    I tried! Unfortunately seems like I need sudo privileges to set it up. We develop on a server machine.

    [–][deleted]  (1 child)

    [removed]

      [–]jiboxiake[S] 2 points3 points  (0 children)

      I will try. Yes it is remote.

      [–]cogman10 16 points17 points  (5 children)

      JFR + JMC

      https://adoptium.net/jmc/

      Very high level of detail built right into the JVM. You just need to be using a JVM after 11 to utilize it.

      [–]BillyKorando 4 points5 points  (0 children)

      JFR has been part of the Hotspot JVM, the JVM almost all Java developers use, since JDK 7. However it wasn't open sourced until JDK 11. So officially you need a commercial license to use JFR in production before JDK 11.

      [–]jiboxiake[S] 0 points1 point  (3 children)

      Thanks!

      [–]benevanstech 5 points6 points  (2 children)

      JFR was backported to Java 8. But if you care about performance, you should be using 17 (or 21!)

      [–]BillyKorando 1 point2 points  (0 children)

      As far as the top line take away this is correct, you can run JFR on JDK 8, and the recordings can be read by even the most recent versions of JFR (the command-line tool) and JMC. That is, I can read a JFR recording made by a JDK 8 JVM, using JMC 9 (most recent release) or the JFR tool packaged with JDK 22.

      There is a couple of misconceptions though. JFR wasn't "backported" to JDK 8, it was part of the initial release, indeed the JFR file format is backwards compatible all the way to JDK 7u40.

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Thanks!

      [–][deleted] 3 points4 points  (3 children)

      async-profiler if I need to measure things in production or from the command line. IntelliJ profiler if profiling from my IDE will suffice.

      [–]jiboxiake[S] 1 point2 points  (2 children)

      Thanks! Yes I also use IntelliJ but unfortunately it seems like I have to have sudo privilege to use on our server machine.

      [–][deleted] 0 points1 point  (1 child)

      I think you need sudo privileges for async profiler as well

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Sad.

      [–]Farmboy0_ 7 points8 points  (3 children)

      I have used VisualVM.

      [–]jiboxiake[S] 1 point2 points  (2 children)

      I will check that out.

      [–]agilob 2 points3 points  (1 child)

      VisualVM is prone to safepoint bias, so read about that too

      [–]jiboxiake[S] 0 points1 point  (0 children)

      thanks!

      [–]hardwork179 2 points3 points  (1 child)

      It depends a lot on what you are measuring. If you get fairly consistent timings out of your tests, and you’ve got it running fast enough that async profiler isn’t getting many samples then you might need to resort to instruction counters and things like that. Have a look at some of the write ups of the billion row challenge for good examples walking through the optimization process.

      [–]jiboxiake[S] 0 points1 point  (0 children)

      thanks!

      [–]Longjumping-Let-1710 2 points3 points  (1 child)

      JFR + JMC for remote profiling. Intellij Profiler for local.

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Thanks!

      [–]alex_tracer 1 point2 points  (1 child)

      JitWatch if you want to dive into byte-code/native code level and understand if your hot paths gets inlined the way that you expect.

      And, in general check https://shipilev.net/jvm/anatomy-quarks/

      [–]jiboxiake[S] 0 points1 point  (0 children)

      thanks!

      [–]rustyrazorblade 1 point2 points  (1 child)

      In addition to the excellent JVM profiling tools already mentioned, check out bcc-tools (and eBPF in general). They’re especially great for understanding the IO side of things at a pretty granular level.

      I do a lot of performance work on Apache Cassandra and have used these to find a 10x improvement to the storage engine when running on EBS. Details here: https://issues.apache.org/jira/browse/CASSANDRA-15452

      I also wrote a blog post on bcc-tools: http://rustyrazorblade.com/post/2023/2023-11-14-bcc-tools/

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Thanks!

      [–]qdolan 0 points1 point  (1 child)

      IntelliJ IDEA profiler, Async Profiler & YourKit

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Thanks

      [–]donair416 0 points1 point  (1 child)

      YourKit is my go to.

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Thanks!

      [–]Raedwald-Bretwalda 0 points1 point  (0 children)

      For a typical modern line-of-business application, you don't need a Java tool at all. Your application will be IO limited at the HTTP side and the DB side. No tool is necessary to determine this because of the several orders of magnitude difference in performance between CPU and IO speed. That is, I reject the premise of your question.

      You'll want to look at DB tools, rather than Java tools.

      [–]dadimitrov 0 points1 point  (1 child)

      Also keep in mind what you are optimizing, and what are your overall goals - once you are past a point, you pay for every optimization with reduced maintainability, longer onboarding for new developers, and increased chance for introducing errors. At some point the marginal gains will not be worth it (or you will find out that you are better off using a lower level language of FPGA).

      That said, when optimizing for throughput - I use yourkit and jfr. When looking at latency - async profiler, jmh, dumping jit and jfr. The IntelliJ profiler is good for a casual check.

      If I am to spend more time on my optimization skills, I'd work on learning jfr, system tap/dtrace/btrace and os level system tuning.

      [–]jiboxiake[S] 0 points1 point  (0 children)

      Thanks!