Valgrind vs. Linux perf correlation
Asked Answered
G

1

8

Suppose that I choose perf events instructions, LLC-load-misses, LLC-store-misses. Suppose further that I test a program prog varying its input. Is valgrind supposed to give me the "same" functional results for the same input and the same counter? That is, if one value in perf goes up, the one in valgrind should always do the same? Is there any impact in valgrind being a simulation that I should be aware of during profiling my code?

EDIT: BTW, before people grill me for not experimenting myself, I have to say that I (kinda) have, the problem is that I have a Sandybridge processor, and perf has a "bug" that prevents me from measuring LLC-* events. There is a patch, but I don't feel like recompiling my kernel...

Gassing answered 17/12, 2012 at 0:29 Comment(0)
N
6

Well, Cachegrind is a cache simulator. Even though it tries to mimic some of your hardware's characteristics (cache size, associativity, etc), it does not model every single feature and behavior of your system. Therefore you might in some cases see some differences.

For example, Valgrind's doc states that "Cachegrind simulates branch predictors intended to be typical of mainstream desktop/server processors of around 2004". Sandy Bridge processors first appeared in 2011, and you can guess that branch predictors have improved quite a lot since 2004.

That being said, Valgrind is still a wonderful tool to have in your toolbox.

What's the problem with perf's LLC events on Sandy Bridge processors? I use these events everyday at work on my Sandy Bridge laptop and it works as expected (archlinux 64bits, linux 3.6).

Noguchi answered 10/1, 2013 at 18:46 Comment(2)
Seems perf cannot access the LLC counters in my version of SandyBridge. I get this: comments.gmane.org/gmane.linux.kernel.perf.user/899, and although a couple of years old, this is related: lwn.net/Articles/430100Gassing
Oh I didn't know about this bug. But I tried again and it doesn't seem to be an issue anymore on current kernels (But I don't know when the fix got merged)Noguchi

© 2022 - 2024 — McMap. All rights reserved.