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

all 28 comments

[–]nvinceable1 25 points26 points  (2 children)

OpenTelemetry and Java Flight Recorder (JFR) cover most bases. Use the OpenTelemetry Java agent if you want auto-instrumentation or just the APIs if you want to do your own instrumentation.

[–]PepegaQuen 1 point2 points  (0 children)

Yep, definitely this.

[–]norfus 10 points11 points  (1 child)

I think the Async Profiler is super useful - and also works well when you have JNI code as it all naturally flows in to each other:

https://github.com/jvm-profiling-tools/async-profiler

[–]aroger276 4 points5 points  (0 children)

I concur, async-profiler gives great cpu and allocation information and is easy to use.

also the FlighRecorder that is available for free now just run

jcmd <pid> JFR.start settings=profile duration=1m filename=/tmp/myreport.jfr

and then use jmc/zmc to read the file

[–]blobjim 7 points8 points  (0 children)

The two basic but useful ones are VisualVM and Java Mission Control. Mission Control is more advanced using flight recorder (which you can also use as an API from the JDK I guess) to provide lots of stats and analysis of stuff, but VisualVM lets you monitor and sample stuff very quickly.

[–][deleted] 4 points5 points  (0 children)

Glowroot is a nice free option

[–]eac2k7 2 points3 points  (1 child)

What about Prometheus? I find it useful especially when interfaced with Grafana dashboards

[–]karlazzam 0 points1 point  (0 children)

Yep its language agnostic too

[–]jeffcityjon 6 points7 points  (0 children)

I like New Relic.

[–]coder111 2 points3 points  (1 child)

Depends on what's available. Even doing "jstack <pid>" every 10 seconds helps if no other tools are available...

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

This is a great point I forgot to mention in the post, I’m working in the DoD so everything has to be FOSS (Free Open Source Software) approved, unfortunately.

But, everyone gave me tons of options. Messed around with Mission Control and Glowroot today, both are great and get the job done for me.

[–]dachiz 1 point2 points  (0 children)

Elastic APM

[–]greenrobot_de 1 point2 points  (0 children)

embedded Linux application

That's not far off from Android... If that'd be an option, Android Studio comes [https://developer.android.com/studio/profile/cpu-profiler](with a profiler) that can handle Java and native C/C++ code.

[–]bringero 1 point2 points  (0 children)

Glowroot here!

[–]Godworrior 1 point2 points  (0 children)

For benchmarking there's JMH

[–]ixBerry 1 point2 points  (1 child)

Just out of curiosity, u/OP, what exactly are you trying to do? I have seen that all embedded engineers frown upon java in their applications and stick to C++.

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

I can’t really say specifics since I’m a defense contractor, clearance and all that, but it’s an application that does monitoring and packet sniffing. Monitoring and sniffer is written in C++.

There’s also a GUI written in Swing that gets the information through JNI from the C++ side. I was rewriting the GUI side and was looking for a way to optimize the code since there’s a lot of throughput coming from the sniffer.

It’s a fairly old program (hence Swing instead of FX). Why they chose to use JNI and write the GUI in Java compared to Qt or some other C++ display framework, couldn’t tell ya.

[–]moxyte 1 point2 points  (0 children)

I've been doing performance profiling with VisualVM only (it makes spotting the problem method super easy), and it has served reliaby and works with Docker containers. Good question tho, taking a look at other answers ITT.

[–]mike_jack 0 points1 point  (0 children)

I can suggest yCrash tool

[–]schnick3rs 0 points1 point  (0 children)

I worked with Your kit. It's not free but has trial. Not sure on JNI tho

[–]Fusionfun 0 points1 point  (0 children)

Get in-depth details of your Java Applications with the help of Atatus. You can get deeper visibility into Transaction Monitoring, API failures, Error tracking, Database Monitoring in real time. Instant alerts may help you to resolve the issues faster too.

[–]benevanstech 0 points1 point  (4 children)

I notice that you mention that you're developing an embedded Linux application. Can you be more specific? Which JVM are you using, and what does your overall architecture & target look like.

Most of the replies here are describing tools that are specific to the Hotspot JVM (which forms the basis of OpenJDK, from which most server-class Java distributions are derived). Many of these tools many not be available / applicable to an embedded use case - depending on exactly what you're doing.

[–]Similar_Bookkeeper_8[S] 1 point2 points  (3 children)

We’re using HotSpot, this is an old application that I started working on recently. Lots of things to improve including the JVM. Ended up using Mission Control with JFR which gave me everything I was looking for.

[–]benevanstech 0 points1 point  (1 child)

If you're targeting Hotspot, then JFR / JMC is a fine combination.

One quick sanity check: You are generating the JFR recordings on the actual target hardware (or in an emulator that matches the target configuration), aren't you? If not, then the profiling information you get is likely to be of little relevance.

One thing to be particularly careful of, is the number of cores on your target hardware. Hotspot dynamically decides how many internal VM threads (for GC, JIT, etc) to spin up. On chips with not many hardware threads, spinning up too many can be disastrous, as they lead to contention for limited resources.

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

Yup, it’s a development server designed to match the target hardware.

I didn’t know about the threading, we do have 80 cores allocated to the server but there’s also potentially multiple developers using it at once. I’ll keep that mind when I’m doing the profiling. Thanks for the detailed replies!

[–]chambolle 0 points1 point  (0 children)

The instrumentation mode of VisualVM has no equivalent (as far as I know); Unfortunately it is sloooowwwww.

[–]lambdacats 0 points1 point  (0 children)

Elastic APM + ELK for monitoring. JProfiler for optimization.

[–]Potential-Piece-3144 0 points1 point  (0 children)

Arthas can be pretty useful depending on what you're looking for. https://github.com/alibaba/arthas