Files
rust/library/std/src
Matthias Krüger 12e4907728 Rollup merge of #92139 - dtolnay:backtrace, r=m-ou-se
Change Backtrace::enabled atomic from SeqCst to Relaxed

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

```rust
#![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
2021-12-23 00:28:54 +01:00
..
2021-10-25 22:44:41 -05:00
2021-12-13 08:43:19 +01:00
2021-12-18 00:21:53 +11:00
2021-02-06 13:05:56 +01:00
2021-12-14 16:40:43 +01:00
2021-12-12 11:20:03 +00:00
2021-12-22 18:31:36 +00:00
2021-12-14 16:40:43 +01:00
2021-12-20 18:30:29 +01:00
2021-05-19 15:52:09 +02:00
2021-10-04 10:29:46 +01:00
2021-10-25 22:44:41 -05:00
2021-10-25 22:44:41 -05:00
2021-12-11 13:47:20 +03:00
2021-11-21 08:15:21 -06:00
2021-08-01 11:19:24 -04:00
2021-10-19 15:02:21 +01:00
2021-12-14 16:40:43 +01:00
2021-12-11 13:47:20 +03:00
2021-12-04 19:40:33 +01:00
2021-12-18 00:21:53 +11:00
2021-12-14 16:40:43 +01:00