N-way mirror read speedup in zfsonlinux
Steven Hartland
killing at multiplay.co.uk
Sun Aug 18 23:06:54 UTC 2013
----- Original Message -----
From: "Will Andrews" <will at firepipe.net>
> On Sunday, August 18, 2013, Matthew Ahrens wrote:
>>
>> As I said, it is more difficult to understand because it is nonstandard.
>> There are many more instances in ZFS of for loops than of do/while loops
>> that could be trivially replaced with for loops, because the for loop is
>> the standard way of doing iteration in this codebase.
>>
>> My understanding is that your argument is that the do/while is faster. If
>> you can show (measure) that it is faster in important use cases, then I
>> will agree that the do/while is better.
>>
>
> Not to mention:
> - the change assumes the compiler isn't already optimizing the code to
> behave like a do..while loop. It may do so given that a vdev_children value
> of 0 would yield a zero length buffer and likely page faults for c = 0.
> - for loops condense the loop conditions & iteration into a single line, so
> for most cases it is clearer what the bounds of the loop are.
> - we are talking about *maybe* saving a handful of instructions while
> performing I/O.
You are indeed correct there Will.
I've been playing with various compilers with a little test app that performs
code similar to this and for the most part it does optimise out to the same
performance.
The case where it does make a significant difference is when the test
is not just a simple comparison, such as a function call. In that case
using a do {...} while() instead of a for(){..} results in a noticeable
performance increase.
So given the simple loop test I'll concede and switch it back to for loop.
Thanks for bearing with me this point guys, hopefully the above will provide
useful in the future.
Regards
steve
================================================
This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it.
In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337
or return the E.mail to postmaster at multiplay.co.uk.
More information about the zfs-devel
mailing list