<p dir="ltr"><br>
On 16 May 2014 18:40, "Chandler Carruth" <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:<br>
><br>
> Why not use the cycle count which perf exposes from hardware? That would seem even better to me, but data would be better. =]</p>
<p dir="ltr">That's an interesting idea. However I'm concerned if that will miss some aspects of compiler optimization. For example frequent cache misses would have much smaller impact on the result if the processor goes to lower frequency during the stall period. Nonetheless it's definitely worth to try out.</p>

<p dir="ltr">><br>
><br>
> On Fri, May 16, 2014 at 11:17 AM, Yi Kong <<a href="mailto:kongy.dev@gmail.com">kongy.dev@gmail.com</a>> wrote:<br>
>><br>
>> On 16 May 2014 18:08, Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br>
>> > ----- Original Message -----<br>
>> >> From: "Yi Kong" <<a href="mailto:kongy.dev@gmail.com">kongy.dev@gmail.com</a>><br>
>> >> To: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>, "Renato Golin" <<a href="mailto:renato.golin@linaro.org">renato.golin@linaro.org</a>>, "Tobias Grosser" <<a href="mailto:tobias@grosser.es">tobias@grosser.es</a>><br>

>> >> Cc: "LLVM Dev" <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>><br>
>> >> Sent: Friday, May 16, 2014 11:37:28 AM<br>
>> >> Subject: Use perf tool for more accurate time measuring on Linux<br>
>> >><br>
>> >> Hi all,<br>
>> >><br>
>> >> The LLVM benchmarking system produces very noisy results even on<br>
>> >> quiet<br>
>> >> machines. One of the sources of inaccuracy is the timing tool we are<br>
>> >> using. Because it is a user-space tool, the OS can context switch it<br>
>> >> and we will get an outlier result. Perf stat uses SW_TASK_CLOCK<br>
>> >> counter in kernel to measure time, therefore more accurate. It also<br>
>> >> does not get context switched.<br>
>> >><br>
>> >> I've implemented a wrapper script over perf stat which mimics the<br>
>> >> behaviour of timeit tool in test suite, so that nothing else needs to<br>
>> >> be modified. The script is not yet feature complete as timeit, but<br>
>> >> enough to run nightly tests.<br>
>> >><br>
>> >> I carried out experiments on several machines and saw different level<br>
>> >> of improvements. I am no longer seeing outlier results, and MAD is<br>
>> >> considerably lower. The run-by-run changes results over the same<br>
>> >> revision shrank from around 10 to only 2-3. The MAD reduced from<br>
>> >> around 0.01 to 0.003 on a quiet machine.<br>
>> ><br>
>> > That sounds great, thanks for working on this!<br>
>> ><br>
>> > First, we'd definitely need more documentation on what perf is and how to get it. The testing guide (and lnt dependencies), at least, need to be updated. FWIW, I don't have any machines on which this is already installed (and so it certainly is not installed by default). On Ubuntu, it is claimed that both linux-base and linux-tools-common provide a 'pref' utility, and on rpm systems it looks like there is a perf package.<br>

>> ><br>
>> > +# FIXME: How to measure sys time?<br>
>> > +echo sys 0.0000 >> $REPORT<br>
>> ><br>
>> > Is this just the difference between the real time and the task time (or would that be a reasonable approximation)?<br>
>><br>
>> Not on some occasions. But for most programs, that should a reasonable<br>
>> approximation. Since test suite does not care about the sys time, we<br>
>> can leave it for now.<br>
>> $ time -p sleep 5<br>
>> real 5.00<br>
>> user 0.00<br>
>> sys 0.00<br>
>><br>
>> ><br>
>> > Thanks again,<br>
>> > Hal<br>
>> ><br>
>> >><br>
>> >> I've attached the patch and please experiment with it.<br>
>> >><br>
>> >> Cheers,<br>
>> >> Yi Kong<br>
>> >><br>
>> ><br>
>> > --<br>
>> > Hal Finkel<br>
>> > Assistant Computational Scientist<br>
>> > Leadership Computing Facility<br>
>> > Argonne National Laboratory<br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
><br>
><br>
</p>