On Mon, Jun 23, 2014 at 11:17 AM, Andi Kleen <a...@firstfloor.org> wrote:
> Marc Glisse <marc.gli...@inria.fr> writes:
>
>> Hello,
>>
>> this is a stage 1 patch, and I'll ping it then, but if you have
>> comments now...
>
> FWIW i believe the transformation will break a large variety of micro 
> benchmarks.
>
> calloc internally knows that memory fresh from the OS is zeroed.
> But the memory may not be faulted in yet.
>
> memset always faults in the memory.
>
> So if you have some test like
>
>    buf = malloc(...)
>    memset(buf, ...)
>    start = get_time();
>    ... do something with buf
>    end = get_time()
>
> Now the times will be completely off because the measured times includes
> the page faults.


Easy way for these benchmarks to get around this.
volatile char *vbuf = (char*)buf;
for(i=0;i<bufsize;i++)
  *vbuf = 0;
before get_time ();

Now there is no way for the compiler to optimize away the inlined
memset and will always be 100% correct in the future.

Also micro-benchmarking is going to have issues like this too with
future optimizations.

Thanks,
Andrew

>
> -Andi
>
> --
> a...@linux.intel.com -- Speaking for myself only

Reply via email to