From: jens.korinth@tuta.io
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: FUJITA Tomonori <fujita.tomonori@gmail.com>,
Rust For Linux <rust-for-linux@vger.kernel.org>,
Ojeda <ojeda@kernel.org>, Alex Gaynor <alex.gaynor@gmail.com>,
Boqun Feng <boqun.feng@gmail.com>, Gary <gary@garyguo.net>,
Bjorn3 Gh <bjorn3_gh@protonmail.com>,
Benno Lossin <benno.lossin@proton.me>,
A Hindborg <a.hindborg@kernel.org>,
Aliceryhl <aliceryhl@google.com>, Tmgross <tmgross@umich.edu>
Subject: Re: [PATCH v1] rust: Add pr_*_once macros
Date: Sun, 3 Nov 2024 23:29:29 +0100 (CET) [thread overview]
Message-ID: <OAo8RFp--B-9@tuta.io> (raw)
In-Reply-To: <CANiq72n3bdNoYsSo47BGK2AJX_yhREoOxfKwkMBwz4v3bR-UHQ@mail.gmail.com>
> Hmm... Isn't this derived from what Jens was working on in Zulip? (Cc'd)
>
Looks very similar. But more importantly it's missing the hotpath improvement suggested by Boqun Feng, which improves the perfomance significantly:
@_**Boqun Feng|411647** [said](https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/warn_once.2Fdo_once_lite_if/near/478155223):
````quote
FWIW, you can do this:
```diff
diff --git a/benches/once_cmp.rs b/benches/once_cmp.rs
index 322e420..1bfc9cd 100644
--- a/benches/once_cmp.rs
+++ b/benches/once_cmp.rs
@@ -124,7 +124,7 @@ macro_rules! do_once_lite_if_abool_swap {
($cond:expr, $e:expr) => {
#[link_section = ".data.once"]
static ALREADY_DONE: AtomicBool = AtomicBool::new(false);
- if $cond && !ALREADY_DONE.swap(true, Ordering::Relaxed) {
+ if $cond && !ALREADY_DONE.load(Ordering::Relaxed) && !ALREADY_DONE.swap(true, Ordering::Relaxed) {
$e;
}
}
```
to improve the hotpath, because you don't need to xchg() each time after you set the flag.
````
Jens
next prev parent reply other threads:[~2024-11-03 22:36 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-03 3:05 [PATCH v1] rust: Add pr_*_once macros FUJITA Tomonori
2024-11-03 16:38 ` Dirk Behme
2024-11-04 1:48 ` FUJITA Tomonori
2024-11-03 16:41 ` Miguel Ojeda
2024-11-03 22:29 ` jens.korinth [this message]
2024-11-04 2:15 ` FUJITA Tomonori
2024-11-04 6:08 ` Boqun Feng
2024-11-04 2:08 ` FUJITA Tomonori
2024-11-04 15:44 ` Miguel Ojeda
2024-11-04 22:08 ` jens.korinth
2024-11-04 22:20 ` Boqun Feng
2024-11-04 23:33 ` FUJITA Tomonori
2024-11-05 20:20 ` Miguel Ojeda
2024-11-05 23:33 ` FUJITA Tomonori
2024-11-05 20:35 ` Miguel Ojeda
2024-11-05 23:31 ` FUJITA Tomonori
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=OAo8RFp--B-9@tuta.io \
--to=jens.korinth@tuta.io \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.