

Change Backtrace::enabled atomic from SeqCst to Relaxed by dtolnay · Pull Reques...
source link: https://github.com/rust-lang/rust/pull/92139
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

This atomic is not synchronizing anything outside of its own value, so we don't need the Acquire
/Release
guarantee that all memory operations prior to the store are visible after the subsequent load, nor the SeqCst
guarantee of all threads seeing all of the sequentially consistent operations in the same order.
Using Relaxed
reduces the overhead of Backtrace::capture()
in the case that backtraces are not enabled.
Benchmark
#![feature(backtrace)] use std::backtrace::Backtrace; use std::sync::atomic::{AtomicUsize, Ordering}; use std::thread; use std::time::Instant; fn main() { let begin = Instant::now(); let mut threads = Vec::new(); for _ in 0..64 { threads.push(thread::spawn(|| { for _ in 0..10_000_000 { let _ = Backtrace::capture(); static LOL: AtomicUsize = AtomicUsize::new(0); LOL.store(1, Ordering::Release); } })); } for thread in threads { let _ = thread.join(); } println!("{:?}", begin.elapsed()); }
Before: 6.73 seconds
After: 5.18 seconds
Recommend
-
64
README.md ReLaXed...
-
11
Ben Simner, Shaked Flur, Christopher Pulte, Alasdair Armstrong, Jean Pichon-Pharabod, Luc Maranget, Peter Sewell Abstract Computing relies on architecture specifications to decouple hardware an...
-
7
Version 2.5 A more liberal style guide for RuboCop. It comes with a config fil...
-
6
Apple agrees to relax App Store rules for ‘reader’ apps like Netflix, SpotifyA small step in the right direction.Photo: AppleApple will relax App Store rules for “reader” apps that let users access previously purc...
-
2
Copy link Contributor lcnr commented
-
9
Copy link Contributor Author lcnr comment...
-
9
New issue gerrit: Google/Gmail account requirement should be relaxed #49383 Closed
-
7
Conducting user research with relaxed usersHow to relax participants and why this is important when researching chilled-out activities
-
8
No Man’s Sky 4.0 trailer shows off streamlined UI and new relaxed modeNo Man’s Sky 4.0 trailer shows off streamlined UI and new relaxed mode / The free update drops today alongside the Nintendo Switch launch
-
8
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK