Re: [PATCH v2 1/8] lib/find_bit.c: Add find_last_zero_bit

From: Yun Levi
Date: Sun Dec 06 2020 - 04:16:45 EST


> btrfs' free space cache v1 is going to be removed some time in the
> future so introducing kernel-wide change just for its own sake is a bit
> premature.

Sorry, I don't know about this fact Thanks..

> Also do you have measurements showing it indeed improves
> performances?

I'm not test btrfs' free space cache directly, But I used find_bit_benchmark.c.

here is the result of find_bit_benchmark.

Start testing find_bit() with random-filled bitmap
[ +0.001874] find_next_bit: 816326 ns, 163323 iterations
[ +0.000822] find_next_zero_bit: 808977 ns, 164357 iterations
[ +0.000571] find_last_bit: 561444 ns, 163323 iterations
[ +0.000619] find_last_zero_bit: 609533 ns, 164357 iterations
[ +0.002043] find_first_bit: 2011390 ns, 16204
iterations
[ +0.000003] find_next_and_bit: 59 ns, 0 iterations
[ +0.000001]
Start testing find_bit() with sparse bitmap
[ +0.000068] find_next_bit: 34573 ns, 653 iterations
[ +0.001691] find_next_zero_bit: 1663556 ns, 327027 iterations
[ +0.000010] find_last_bit: 7864 ns, 653 iterations
[ +0.001235] find_last_zero_bit: 1216449 ns, 327027 iterations
[ +0.000664] find_first_bit: 653148 ns, 653 iterations
[ +0.000002] find_next_and_bit: 44 ns, 0 iterations

as this result, the find_last_zero_bit is a little fast, and logically,
because find_each_clear_bit is iterate till the specified index (i) times,
But find_last_zero_bit in that case call one time
(find_each_clear_bit call i times but find_last_zero_bit call only one time)

So, i think it has a slight improvement.

Thanks.
Levi.

On Sun, Dec 6, 2020 at 6:01 PM Nikolay Borisov <nborisov@xxxxxxxx> wrote:
>
>
>
> On 6.12.20 г. 10:56 ч., Yun Levi wrote:
> >> This, and the change above this, are not related to this patch so you
> >> might not want to include them.
> >
> >> Also, why is this patch series even needed? I don't see a justification
> >> for it anywhere, only "what" this patch is, not "why".
> >
> > I think the find_last_zero_bit will help to improve in
> > 7th patch's change and It can be used in the future.
> > But if my thinking is bad.. Please let me know..
> >
> > Thanks.
> > Levi.
> >
>
> btrfs' free space cache v1 is going to be removed some time in the
> future so introducing kernel-wide change just for its own sake is a bit
> premature. Also do you have measurements showing it indeed improves
> performances?