News for hackers. Stuff that matters.
Re:Comparing the Cost of Different Multiple-return Technique... by j_baker on Monday December 23, 2013 @12:24PM (#6955346)
I'm curious: why are lower numbered benchmarks on the openbsd machine so much slower than higher-numbered benchmarks? Clearly, the machine is older and less powerful than the others, but I wouldn't expect that to alter the timing in this way. Is this a result of the machine, the OS, or the version of the OS?
Re:Comparing the Cost of Different Multiple-return Technique... by silentbicycle on Monday December 23, 2013 @12:39PM (#6955419)
I'm not sure, and digging into it would likely be a separate post. It's probably due to OpenBSD having very different cache strategies from OSX or Linux. It seemed to consistently do badly on the first run or two, then catch up on on the rest. It's often recommended to throw away the first run in a set of benchmarks, due to the added overhead of disk IO, but I wanted to retain that because something interesting is going on there.

The graphs also show more overhead for returning a struct with additional padding. OpenBSD's memory allocator favors security rather than speed, and the extra size may have costs for buffer overruns felt elsewhere. I like testing C code on OpenBSD -- it's almost as good as valgrind for detecting memory bugs, but with significantly less overhead, since the memory checking is integrated into the OS.

Re:Comparing the Cost of Different Multiple-return Technique... by evmar on Monday December 23, 2013 @12:46PM (#6955470)
Here's a post where I walk through the assembly generated by some different approaches. http://neugierig.org/software/blog/2011/12/return-by-value.h...

One possibility is that OpenBSD uses the alternative ABI for returning structs mentioned in that post.

Re:Comparing the Cost of Different Multiple-return Technique... by silentbicycle on Friday December 27, 2013 @10:12AM (#6970846)
The code for the benchmarks is up, if you want to investigate: https://github.com/atomicobject/multiple_return_in_c_benchma...