From: Alice Ryhl <aliceryhl@google.com>
To: Burak Emir <bqe@google.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
"Yury Norov" <yury.norov@gmail.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
"Rong Xu" <xur@google.com>
Subject: Re: [PATCH v7 4/5] rust: add find_bit_benchmark_rust module.
Date: Mon, 28 Apr 2025 09:36:12 +0000 [thread overview]
Message-ID: <aA9MDH8RjOH9hQ2E@google.com> (raw)
In-Reply-To: <CACQBu=VkFT5yDuDz098L+S+tGvtGHMvm4FaZ6p3sr9VCp88jww@mail.gmail.com>
On Fri, Apr 25, 2025 at 06:17:59PM +0200, Burak Emir wrote:
> On Fri, Apr 25, 2025 at 3:45 PM Boqun Feng <boqun.feng@gmail.com> wrote:
> >
> > On Fri, Apr 25, 2025 at 02:20:13PM +0200, Burak Emir wrote:
> > > On Fri, Apr 25, 2025 at 12:31 AM Boqun Feng <boqun.feng@gmail.com> wrote:
> > > >
> > > > On Thu, Apr 24, 2025 at 09:48:17AM -0700, Boqun Feng wrote:
> > > > > On Thu, Apr 24, 2025 at 06:45:33PM +0200, Burak Emir wrote:
> > > > > > On Wed, Apr 23, 2025 at 6:56 PM Yury Norov <yury.norov@gmail.com> wrote:
> > > > > > > So? Can you show your numbers?
> > > > > >
> > > > > > For now, I only have numbers that may not be very interesting:
> > > > > >
> > > > > > - for find_next_bit, find_next_zero_bit and find_next_zero_bit (sparse):
> > > > > > 22 ns/iteration in C, 32 ns/iteration in Rust.
> > > > > >
> > > > > > - for sparse find_next_bit (sparse):
> > > > > > 60 ns/iteration in C, 70 ns/iteration in Rust.
> > > > > >
> > > > > > This is a VM running nested in a VM. More importantly: the C helper
> > > > > > method is not inlined.
> > > > > > So we are likely measuring the overhead (plus the extra bounds checking).
>
> Alice and I discussed that it may be better to do away with the extra
> bounds check.
> Micro benchmark, for the upcoming v8 that has the bounds check removed
> (and the test changed to >=, as requested):
>
> [] Start testing find_bit() with random-filled bitmap
> [] find_next_bit: 3598165 ns, 164282 iterations
> [] find_next_zero_bit: 3626186 ns, 163399 iterations
> [] Start testing find_bit() with sparse bitmap
> [] find_next_bit: 40865 ns, 656 iterations
> [] find_next_zero_bit: 7100039 ns, 327025 iterations
> [] find_bit_benchmark_rust_module: Start testing find_bit() Rust with
> random-filled bitmap
> [] find_bit_benchmark_rust_module: next_bit:
> 4572086 ns, 164112 iterations
> [] find_bit_benchmark_rust_module: next_zero_bit:
> 4582930 ns, 163569 iterations
> [] find_bit_benchmark_rust_module: Start testing find_bit() Rust with
> sparse bitmap
> [] find_bit_benchmark_rust_module: next_bit:
> 42622 ns, 655 iterations
> [] find_bit_benchmark_rust_module: next_zero_bit:
> 8835122 ns, 327026 iterations
By the way, if you add assert_eq!(bitmap.len(), BITMAP_LEN) before the
loop you may get the bounds checks optimized out.
Alice
next prev parent reply other threads:[~2025-04-28 9:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 13:43 [PATCH v7 0/5] rust: adds Bitmap API, ID pool and bindings Burak Emir
2025-04-23 13:43 ` [PATCH v7 1/5] rust: add bindings for bitmap.h Burak Emir
2025-04-23 15:46 ` Yury Norov
2025-04-23 13:43 ` [PATCH v7 2/5] rust: add bindings for bitops.h Burak Emir
2025-04-23 15:50 ` Yury Norov
2025-04-23 13:43 ` [PATCH v7 3/5] rust: add bitmap API Burak Emir
2025-04-23 16:46 ` Yury Norov
2025-04-28 10:21 ` Burak Emir
2025-04-23 13:43 ` [PATCH v7 4/5] rust: add find_bit_benchmark_rust module Burak Emir
2025-04-23 16:56 ` Yury Norov
2025-04-24 16:45 ` Burak Emir
2025-04-24 16:48 ` Boqun Feng
2025-04-24 22:31 ` Boqun Feng
2025-04-25 12:20 ` Burak Emir
2025-04-25 13:45 ` Boqun Feng
2025-04-25 16:17 ` Burak Emir
2025-04-26 13:03 ` Yury Norov
2025-04-26 15:45 ` Burak Emir
2025-04-28 9:36 ` Alice Ryhl [this message]
2025-04-28 13:21 ` Yury Norov
2025-04-29 8:09 ` Alice Ryhl
2025-04-24 12:42 ` Alice Ryhl
2025-05-07 15:26 ` kernel test robot
2025-04-23 13:43 ` [PATCH v7 5/5] rust: add dynamic ID pool abstraction for bitmap Burak Emir
2025-04-23 15:43 ` [PATCH v7 0/5] rust: adds Bitmap API, ID pool and bindings Yury Norov
2025-04-23 16:19 ` Alice Ryhl
2025-04-23 16:30 ` Boqun Feng
2025-04-23 17:11 ` Yury Norov
2025-04-23 17:30 ` Boqun Feng
2025-04-23 17:34 ` Yury Norov
2025-04-23 17:52 ` Boqun Feng
2025-04-23 18:00 ` Yury Norov
2025-04-23 19:45 ` Boqun Feng
2025-04-23 17:08 ` Yury Norov
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=aA9MDH8RjOH9hQ2E@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=bqe@google.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
--cc=viresh.kumar@linaro.org \
--cc=xur@google.com \
--cc=yury.norov@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;
as well as URLs for NNTP newsgroup(s).