15
Measuring directly from CPU : Hardware performance counters Jean-Philippe BEMPEL Performance Architect @jpbempel http://jpbempel.blogspot.com

Measuring directly from cpu hardware performance counters

Embed Size (px)

DESCRIPTION

CPUs embed a performance monitoring unit (PMU) which we can use to collect data on cache usage (hit/miss) branch predictions, instructions, cycles, etc. those counters can be accessed in Java thanks to the overseer library.

Citation preview

Page 1: Measuring directly from cpu  hardware performance counters

Measuring directly from CPU : Hardware performance

counters

Jean-Philippe BEMPEL Performance Architect

@jpbempel http://jpbempel.blogspot.com

Page 2: Measuring directly from cpu  hardware performance counters

●Measuring time○ System.CurrentTimeMillis()○ System.nanoTime()

●Timestamps in logs

●Profiling

Measuring

Page 3: Measuring directly from cpu  hardware performance counters

● System.currentTimeMillis() 1ms -> 10-15ms depending on the OS

● System.nanoTime()500ns -> 1us

Précision

Page 4: Measuring directly from cpu  hardware performance counters

● CPUs embeds PMU (Processing Monitoring Unit)

● Hardware counters on CPU behavior:○ Cycles○ Instructions○ Caches○ Memory accesses

● predefined or customizable

Compteurs de performance

Page 5: Measuring directly from cpu  hardware performance counters

Hiérarchie mémoire

Page 6: Measuring directly from cpu  hardware performance counters

échelle de latence

Page 7: Measuring directly from cpu  hardware performance counters

●available on most linux distros

●Allow to access perf counters but allow other things (profiling, OS counters, …)

● list perf counters: perf list

●Profiler with default counters perf stat java…

●Customize a perf counterperf stat -e LLC-load-misses java ...

Perf

Page 8: Measuring directly from cpu  hardware performance counters

DEMO

Perf

Page 9: Measuring directly from cpu  hardware performance counters

● java library (JNI - linux only)

●Allow to use all available counters

●Based on libpfm4○Encodes counters based on CPU

●Profile precisely part of the code of applications

Overseer

Page 10: Measuring directly from cpu  hardware performance counters

DEMO

Overseer

Page 11: Measuring directly from cpu  hardware performance counters

DEMO

Memory layout: LinkedList

Page 12: Measuring directly from cpu  hardware performance counters

DEMO

Memory layout: ArrayList

Page 13: Measuring directly from cpu  hardware performance counters

Pipeline

Page 14: Measuring directly from cpu  hardware performance counters

● Overseer library:○ http://www.peternier.com/projects/overseer/overseer.php

● libpfm4:○ http://perfmon2.sourceforge.net/

Liens

Page 15: Measuring directly from cpu  hardware performance counters

Thanks for your attention.

Questions?