5 ms·
Is it bad to try to avoid relying on the pre-fetcher? It's obviously there for a good reason and presumably could cut down on a bunch of micro-optimisation, I'm
by Twirrim 10y ago
Is it bad to try to avoid relying on the pre-fetcher? It's obviously there for a good reason and presumably could cut down on a bunch of micro-optimisation, I'm just curious how much of a significant performance measuring black hole it's leaving by not considering it.
- keldaris 10y agoDepending on your workload deliberately avoiding the prefetcher (which isn't particularly easy, mind you) ranges between a mild loss to 2-3 orders of magnitude in performance. As a trivial example, consider the element-wise addition of two large matrices. Without a prefetcher you would incur a large number (how large mostly depends on the ratio of the number of elements in your matrices and the available cache memory) of cache misses even during the most cache-friendly iteration pattern since the matrices are simply too large. On modern CPUs the prefetcher avoids these cache misses so well that the performance difference is approximately two orders of magnitude. Of course for this to work your traversal pattern has to be sufficiently predictable. Generally, I think considering the prefetcher is roughly as important (and, indeed, inextricably linked) as considering the cache subsystem itself. Any performance sensitive code will benefit from careful consideration of memory access and traversal patterns.