5 ms·
There's another reason too; there are strong reasons why the timing of successive code executions should not be linear. Typically the first call to a function w
by colmmacc 7y ago
There's another reason too; there are strong reasons why the timing of successive code executions should not be linear. Typically the first call to a function will incur the cost of fetching data into a cache. At minimum the basic blocks for the function will be loaded through the l1/l2/l3 pipelines.
2, 3, 4 function calls in a row will benefit from that caching, but also help train the speculative execution engine. At some point that speculation may radically alter performance. Later, with a sufficient number of runs, the timing will also suffer from preemption, context-switches, or other interruptions that can invalidate both the cache and the speculative execution engine.
The idea that there is a fixed performance time for a function is naive on modern hardware.
- cscheid 7y agoYou make a good point I hadn't considered. In that case, not even robust least squares will save you, because the samples are not independent of one another. You'd have to start looking into explicit time-dependent methods and yikes, I have no idea of what the literature says about time dependence and outliers. I wouldn't be surprised if it's "here be dragons" territory.
- colmmacc 7y agoSpeculative execution optimizations, e.g. branch prediction, are even data dependent. It's a very complex measurement space!
- gdxhyrd 7y agoYou are speaking as a stats person. :) While there are dozens of things that can go south in benchmarking, how to solve them is not about applying advanced stats, but about understanding and eliminating the sources of noise. Most benchmarks in CS can be done quite easily as long as one understands all the technology stack.
- cscheid 7y agoI'm not a stats person! But I have been burned in real projects by doing the wrong thing. I just have learned --- the hard way --- to honestly appreciate it.
- jwkane 7y ago"The idea that there is a fixed performance time for a function is naive on modern hardware." This is exactly it, though it can be further compounded by runtime optimization in software.