From: Yury Norov <ynorov@nvidia.com>
To: Gary Guo <gary@garyguo.net>
Cc: "Eliot Courtney" <ecourtney@nvidia.com>,
"Greg KH" <gregkh@linuxfoundation.org>,
"Burak Emir" <bqe@google.com>,
"John Hubbard" <jhubbard@nvidia.com>,
"Alice Ryhl" <aliceryhl@google.com>,
"Liam R . Howlett" <liam@infradead.org>,
"Andrew Ballance" <andrewjballance@gmail.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Alistair Popple" <apopple@nvidia.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Benno Lossin" <lossin@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Boqun Feng" <boqun@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"David Airlie" <airlied@gmail.com>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Onur Özkan" <work@onurozkan.dev>,
"Simona Vetter" <simona@ffwll.ch>,
"Tamir Duberstein" <tamird@kernel.org>,
"Timur Tabi" <ttabi@nvidia.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Yury Norov" <yury.norov@gmail.com>, "Zhi Wang" <zhiw@nvidia.com>,
maple-tree@lists.infradead.org, linux-kernel@vger.kernel.org,
nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2] lib: test bitmap vs IDA vs Maple Tree performance for region allocations
Date: Wed, 15 Jul 2026 01:00:12 -0400 [thread overview]
Message-ID: <alcT3HupA6TogWSa@yury> (raw)
In-Reply-To: <DJVSHL6XP43R.1INHQRXAG8UA3@garyguo.net>
On Sat, Jul 11, 2026 at 02:51:28PM +0100, Gary Guo wrote:
...
> > +static unsigned long __init benchmark_bitmap(unsigned long capacity)
> > +{
> > + unsigned long count, index;
> > + ktime_t alloc_time, free_time;
> > + size_t memory;
> > +
> > + bitmap_zero(alloc_bitmap, MAP_SIZE);
> > + alloc_time = ktime_get();
>
> To eliminate possible effects of optimization messing up benchmark, please add a
> barrier() after start timing and a barrier() before end timing. Probably you'd
> want one between each loop iteration too.
It was never a problem in find_bit_benchmark test, but OK.
> > + for (count = 0; count < ARRAY_SIZE(region_sizes); count++) {
> > + index = bitmap_find_next_zero_area(alloc_bitmap, capacity, 0,
> > + region_sizes[count], 0);
> > + if (index >= capacity)
> > + break;
> > +
> > + region_indexes[count] = index;
> > + bitmap_set(alloc_bitmap, index, region_sizes[count]);
> > + }
> > + alloc_time = ktime_get() - alloc_time;
> > +
> > + index = count;
> > + free_time = ktime_get();
> > + while (index--)
> > + bitmap_clear(alloc_bitmap, region_indexes[index],
> > + region_sizes[index]);
> > + free_time = ktime_get() - free_time;
> > + memory = BITS_TO_LONGS(capacity) * sizeof(unsigned long);
> > + pr_err("%-6s %12llu %12llu %8lu %10zu\n", "bitmap", alloc_time,
> > + free_time, capacity, memory);
>
> I wonder if the numbers could be more useful if it is somehow normalized (e.g.
> by how many iterations are performed?)? This number can be computed by adding
> up the prefix of region_sizes until it cover all capacity.
>
> Also, the capacity should probably be made part of the report header for all 3
> ID allocators. Given this is randomized benchmark the single line, when taken
> out of context, is not very meaningful anyway.
>
> Something like this might be better (fake numbers below, you might also need
> some fix point printing):
>
> capacity = 1000000, regions = 100000
> type alloc (ns/region) free (ns/region) memory (B/capacity)
> bitmap 1795.730 3.421 0.125
> IDA 465.556 339.314 0.134
> maple 186.296 197.413 1.548
>
> capacity = 100000, regions = 10000
> bitmap 163.091 3.093 0.125
> IDA 614.478 335.459 0.142
> maple 174.502 182.503 1.554
>
> capacity = 10000, regions = 1000
> bitmap 28.448 3.374 0.125
> IDA 418.978 333.641 0.187
> maple 185.398 211.138 1.563
>
> capacity = 1000, regions = 100
> bitmap 22.530 6.100 0.128
> IDA 427.550 364.320 0.144
> maple 197.280 234.740 1.552
I can add the 'regions' column, mostly for completeness. My experience
with find_bit_benchmark is that people mostly ignore it.
Your version may look more 'human friendly', but the reality is that
people understand the original version quite well. This "nice"
formatting is a substantial complication for the log parsers.
Printing anything else, except for the raw test output numbers, is
simply wrong. I don't want to force people to *my* analysis. If you
believe that ns per region is more informative, you can do that
trivial math yourself.
For more serious statistical analysis, one must take into
consideration measurement errors, distribution skewness, random
variables correlations and all that fancy statistical things.
In your example, you divide one random variable, ns, to another,
number of regions. Each of them has its own distribution, and not
necessarily normal. Simple divide operation becomes not so simple,
if you do it right.
I'm not saying that this simple test requires an analysis of such
complexity. I'm saying that raw output numbers are always preferred
at data collection phase.
Thanks,
Yury
prev parent reply other threads:[~2026-07-15 5:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 6:36 [PATCH v2] lib: test bitmap vs IDA vs Maple Tree performance for region allocations Yury Norov
2026-07-11 8:27 ` Onur Özkan
2026-07-15 1:49 ` Yury Norov
2026-07-11 13:51 ` Gary Guo
2026-07-15 5:00 ` Yury Norov [this message]
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=alcT3HupA6TogWSa@yury \
--to=ynorov@nvidia.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=apopple@nvidia.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=bqe@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=ecourtney@nvidia.com \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=jhubbard@nvidia.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=maple-tree@lists.infradead.org \
--cc=nova-gpu@lists.linux.dev \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=ttabi@nvidia.com \
--cc=willy@infradead.org \
--cc=work@onurozkan.dev \
--cc=yury.norov@gmail.com \
--cc=zhiw@nvidia.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