0

Is there a tool available to profile java applications regarding branch (mis)prediction statistics for if statements?

I know VisualVM and JDK Mission Control but did not find such functionality.

Mahatma_Fatal_Error
  • 720
  • 1
  • 10
  • 26

1 Answers1

0

No such tool exists.

It is generally impossible to extract that information from CPU, you can either measure performance of code block, or emulate execution of code and collect such statistic.

talex
  • 17,973
  • 3
  • 29
  • 66
  • CPUs do have hardware performance counters for branches and branch hits. Using `perf stat --all-user java foo.jar` will count overall (user-space only) branch miss stats for the whole Java process. `perf record --all-user -e branch-misses ./a.out` will record samples on branch misses, including for JITed machine code. Finding the JITed machine code for a specific `if()` in your Java source in the `perf report` output is probably a huge pain, unless you ran a microbenchmark and counted `cycles,branch-misses` so you could look for the code where your program spent most of its time. – Peter Cordes Jun 05 '22 at 03:34