| Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applications by J. Seward, N. Nethercote, J. Weidendorfer and the Valgrind Development Team Paperback (6"x9"), 164 pages ISBN 0954612051 RRP £12.95 ($19.95) |
6.3.3 Accuracy
Valgrind's cache profiling has a number of shortcomings:
- It doesn't account for kernel activity--the effect of system calls on the cache contents is ignored.
- It doesn't account for other process activity. This is probably desirable when considering a single program.
- It doesn't account for virtual-to-physical address mappings. Hence the simulation is not a true representation of what's happening in the cache. Most caches are physically indexed, but Cachegrind simulates caches using virtual addresses.
- It doesn't account for cache misses not visible at the instruction level, e.g. those arising from TLB misses, or speculative execution.
- Valgrind will schedule threads differently from how they would be when running natively. This could warp the results for threaded programs.
-
The x86/amd64 instructions ‘bts’,
‘btr’ and
‘btc’ will incorrectly be
counted as doing a data read if both the arguments are
registers, e.g.:
btsl %eax, %edx
This should only happen rarely. - x86/amd64 FPU instructions with data sizes of 28 and 108 bytes (e.g. ‘fsave’) are treated as though they only access 16 bytes. These instructions seem to be rare so hopefully this won't affect accuracy much.
Another thing worth noting is that results are very sensitive. Changing the size of the the executable being profiled, or the sizes of any of the shared libraries it uses, or even the length of their file names, can perturb the results. Variations will be small, but don't expect perfectly repeatable results if your program changes at all.
More recent GNU/Linux distributions do address space randomisation, in which identical runs of the same program have their shared libraries loaded at different locations, as a security measure. This also perturbs the results.
While these factors mean you shouldn't trust the results to be super-accurate, hopefully they should be close enough to be useful.
| ISBN 0954612051 | Valgrind 3.3 - Advanced Debugging and Profiling for GNU/Linux applications | See the print edition |