How to run a program with a cold cache

I run the test several times to record the average. But I notice that after the first run, subsequent runs are faster. I think this has something to do with the instruction cache, so when I run the program next time, the reference already has instructions in the cache. Is there a way to run a program using cold instructions and data caches?

+6
source share
1 answer

This is normal behavior. One way to avoid this problem is to warm up a bit before the main launch. These warm-ups will overwrite the cache that grew earlier running the program. When calculating the average value, exclude warm-up values ​​for a real run only. There are various notes tools that use this approach. kernbench , lmbench etc. Where the warm value is available.

And, if the benchmark that you use depends on the data you need to read from the disk, then disk caching also has some effect, one way to avoid this is, if possible, caching this data on RAM. This method is used by kernbench to avoid disk cache problems.

+4
source

Source: https://habr.com/ru/post/945759/


All Articles