javascriptv8cpu-cachejavascriptcorechakracore

How do I measure CPU cache and prefetch misses in JavaScript engines?


I want a command-line way to evaluate low-level contributors to lower performance-per-watt of Node.js applications. Namely, L1, L2, and prefetch cache misses of JIT-generated native code, as well as the JIT/GC/interpteter of the JavaScript runtime itself.

JavaScriptCore, v8, and ChakraCore all supply commandline REPLs for running benchmarks. What profiler(s) can I run on Intel-, AMD-, and ARMv6-based hardware to gather these statistics with reasonable accuracy? I'd prefer to have a way to do this across at least two operating systems: Windows, Mac, and/or Linux.


Solution

  • V8 and the Linux perf tool support each other, see the documentation. If you have a very recent system (IIRC kernel >= 4.4 and perf >= 4.10), you can skip the steps for compiling your own kernel and perf.