From: "NeilBrown" <neilb@suse.de>
To: SandeepKsinha <sandeepksinha@gmail.com>
Cc: Linux RAID <linux-raid@vger.kernel.org>
Subject: Re: [PATCH] md: Enhancements and clean to linear RAID
Date: Tue, 19 May 2009 17:25:30 +1000 (EST) [thread overview]
Message-ID: <9a138833b29b54e5d6c1eaa188f27399.squirrel@neil.brown.name> (raw)
In-Reply-To: <37d33d830905182323x22eec1c8l2a7471668c1a02b3@mail.gmail.com>
On Tue, May 19, 2009 4:23 pm, SandeepKsinha wrote:
> Hi Neil,
>
> I have made the desired changes and have tested the changes as well.
> As expected the performance gain with number of devices ( > 20 ) is
> quite visible.
How did you measure the performance gain and what were your
results?
> The code also looks simpler as compared to what it earlier was.
>
> I have created the following patches for the changes:
>
> PATCH [01/03] md: Removal of num_sectors from dev_info in linear raid
>
> This patch removes the num_sectors from dev_info and makes use of the
> rdev->sectors for
> all further usage.
Could I as you to redo this one a little differently?
I want to keep the linear search very tight, and you have just added
a pointer de-reference to it.
If you could replace start_sector by end_sector, we wouldn't need that
de-reference or the addition.
>
> PATCH[02/03] md: Getting rid of sector_div and hash table in linear raid
>
> Removal of all the code pertaining hast table and other related data
> structures.
> This also makes the code really really simple.
> The searching being made linear for the time being to test the patch.
>
> PATCH[03/03] md: Replacing linear with a binary search
>
> This patch replaces the linear search in which_dev with binary search.
Two things wrong with you binary search.
1/ the while() condition is "hi >= lo". That will always be true, so it
would be better to make that explicit. i.e. "while(1)".
However the while loop of a binary search should be
while (hi > lo)
2/ You have 3 comparisons against 'sector' inside the loop. There should
only be one. We are aiming for speed remember :-)
while (hi > lo) {
mid = (hi + lo + 1) / 2;
dev = conf->disks + mid;
if (sector >= dev->start_sector)
lo = mid;
else
hi = mid - 1;
}
return dev;
With that formulation, you don't even need to replace
sector_start by sector_end.. However doing so would make other
code simpler, so please do proceed with replacing sector_start by
sector_end.
Then the binary search (with a fix because dev can be uninitialised),
becomes:
while (hi > lo) {
mid = (hi + lo) / 2;
if (sector < conf->disks[mid].end_sector)
hi = mid;
else
lo = mid + 1;
}
return conf->disks + lo;
NeilBrown
next prev parent reply other threads:[~2009-05-19 7:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-19 6:23 [PATCH] md: Enhancements and clean to linear RAID SandeepKsinha
2009-05-19 7:25 ` NeilBrown [this message]
2009-05-19 7:31 ` SandeepKsinha
2009-05-19 10:46 ` SandeepKsinha
2009-05-19 11:38 ` Neil Brown
2009-05-19 11:56 ` SandeepKsinha
2009-05-19 12:32 ` Sujit Karataparambil
2009-05-21 3:15 ` SandeepKsinha
2009-05-21 3:47 ` NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9a138833b29b54e5d6c1eaa188f27399.squirrel@neil.brown.name \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=sandeepksinha@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox