N-way mirror read speedup in zfsonlinux

Matthew Ahrens mahrens at delphix.com
Sun Aug 18 16:38:49 UTC 2013


On Sun, Aug 18, 2013 at 8:52 AM, Steven Hartland <killing at multiplay.co.uk>wrote:

> ----- Original Message ----- From: "Matthew Ahrens"
>
>> On Sat, Aug 17, 2013 at 8:08 PM, Steven Hartland wrote:
>>
>>  2) do {} while() loops have their place, but only if they improve
>>>
>>>>   code clarity and/or yield a significant performance benefit.  I
>>>>   don't see either applying here.
>>>>
>>>>
>>> I'd have to disagree, unless using it makes it difficult to understand,
>>> a do while should be used is when you know there's always going to be
>>> one iteration of the loop and hence no need to test before performing
>>> the first iteration.
>>>
>>>
>>
>> I agree with Justin.  This nonstandard iteration makes it more difficult
>> to
>> understand.  I would expect there is no measurable performance benefit,
>> either.
>>
>
> I'd like to understand why its more difficult to understand?
>

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.

--matt


>
> Its not like its a none standard language construct, its already used in
> the code base in lots of place e.g.
>
> uts/common/zmod/deflate.c:
> do {...} while (--len > 0);
> uts/common/dtrace/dtrace.c:
> do {...} } while (--length != 0);
>
> Compared to this case:
> do {...} while (--c >= 0);
>
> Yes its only saving one comparison per call but thats exactly what it
> was added to language to do.
>
> Not trying to be be a pain, I'm just trying to understand why using the
> correct code for the job is confusing?
>
>
>    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