Fork me on GitHub
#java
<
2020-02-28
>
rickmoynihan10:02:06

@andy.fingerhut IIRC jstat -gccause <PID> <POLLTIME>

rickmoynihan10:02:47

you can use it on any JVM your user is running, without passing any fancy JVM args. Might be useful, also see man jstat for tweaking what is displayed

andy.fingerhut10:02:52

Thanks for that. I will check it out. I'm currently being a bit stubborn in continuing to look for a way to get such stats from within the JVM that is doing the performance tests, too. Hopefully it isn't a big ordeal to find a way to do that.

rickmoynihan12:02:01

the above does that. It’s a lightweight command line tool that connects to the JVM you specify and dumps gc stats as an ascii table, 1 row per POLLTIME, e.g. a polltime of 1000 would be every second.

andy.fingerhut19:02:34

Doing some more digging, it seems that there may be a bug in criterium that for some calls, causes System/gc to be called just before each execution of your expression you want to benchmark. The GarbageCollectorMXBean measurements I was taking were at the beginning and end of my expression, which was not including those System/gc calls executed by criterium at all.

andy.fingerhut19:02:19

I opened a PR on the criterium library proposing a fix for that. The fix enables you to still request that behavior as an option, but it does not appear to be intended as the default.

andy.fingerhut19:02:28

It is so mentally relaxing for me to find the root cause of weird stuff like this. The world makes sense again 🙂

✔️ 4