forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#135655 - matthiaskrgr:rollup-ocj5y1t, r=matth…
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#134455 (cleanup promoteds move check) - rust-lang#135421 (Make tidy warn on unrecognized directives) - rust-lang#135611 (Remove unnecessary assertion for reference error) - rust-lang#135620 (ci: improve github action name) - rust-lang#135621 (Move some std tests to integration tests) - rust-lang#135639 (new solver: prefer trivial builtin impls) - rust-lang#135654 (add src/librustdoc and src/rustdoc-json-types to RUSTC_IF_UNCHANGED_ALLOWED_PATHS) r? `@ghost` `@rustbot` modify labels: rollup
- Loading branch information
Showing
69 changed files
with
634 additions
and
562 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,5 @@ | |
extern crate test; | ||
|
||
mod hash; | ||
mod path; | ||
mod time; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
use core::hint::black_box; | ||
use std::collections::{BTreeSet, HashSet}; | ||
use std::hash::{DefaultHasher, Hash, Hasher}; | ||
use std::path::*; | ||
|
||
#[bench] | ||
#[cfg_attr(miri, ignore)] // Miri isn't fast... | ||
fn bench_path_cmp_fast_path_buf_sort(b: &mut test::Bencher) { | ||
let prefix = "my/home"; | ||
let mut paths: Vec<_> = | ||
(0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); | ||
|
||
paths.sort(); | ||
|
||
b.iter(|| { | ||
black_box(paths.as_mut_slice()).sort_unstable(); | ||
}); | ||
} | ||
|
||
#[bench] | ||
#[cfg_attr(miri, ignore)] // Miri isn't fast... | ||
fn bench_path_cmp_fast_path_long(b: &mut test::Bencher) { | ||
let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; | ||
let paths: Vec<_> = | ||
(0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); | ||
|
||
let mut set = BTreeSet::new(); | ||
|
||
paths.iter().for_each(|p| { | ||
set.insert(p.as_path()); | ||
}); | ||
|
||
b.iter(|| { | ||
set.remove(paths[500].as_path()); | ||
set.insert(paths[500].as_path()); | ||
}); | ||
} | ||
|
||
#[bench] | ||
#[cfg_attr(miri, ignore)] // Miri isn't fast... | ||
fn bench_path_cmp_fast_path_short(b: &mut test::Bencher) { | ||
let prefix = "my/home"; | ||
let paths: Vec<_> = | ||
(0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); | ||
|
||
let mut set = BTreeSet::new(); | ||
|
||
paths.iter().for_each(|p| { | ||
set.insert(p.as_path()); | ||
}); | ||
|
||
b.iter(|| { | ||
set.remove(paths[500].as_path()); | ||
set.insert(paths[500].as_path()); | ||
}); | ||
} | ||
|
||
#[bench] | ||
#[cfg_attr(miri, ignore)] // Miri isn't fast... | ||
fn bench_path_hashset(b: &mut test::Bencher) { | ||
let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; | ||
let paths: Vec<_> = | ||
(0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); | ||
|
||
let mut set = HashSet::new(); | ||
|
||
paths.iter().for_each(|p| { | ||
set.insert(p.as_path()); | ||
}); | ||
|
||
b.iter(|| { | ||
set.remove(paths[500].as_path()); | ||
set.insert(black_box(paths[500].as_path())) | ||
}); | ||
} | ||
|
||
#[bench] | ||
#[cfg_attr(miri, ignore)] // Miri isn't fast... | ||
fn bench_path_hashset_miss(b: &mut test::Bencher) { | ||
let prefix = "/my/home/is/my/castle/and/my/castle/has/a/rusty/workbench/"; | ||
let paths: Vec<_> = | ||
(0..1000).map(|num| PathBuf::from(prefix).join(format!("file {num}.rs"))).collect(); | ||
|
||
let mut set = HashSet::new(); | ||
|
||
paths.iter().for_each(|p| { | ||
set.insert(p.as_path()); | ||
}); | ||
|
||
let probe = PathBuf::from(prefix).join("other"); | ||
|
||
b.iter(|| set.remove(black_box(probe.as_path()))); | ||
} | ||
|
||
#[bench] | ||
fn bench_hash_path_short(b: &mut test::Bencher) { | ||
let mut hasher = DefaultHasher::new(); | ||
let path = Path::new("explorer.exe"); | ||
|
||
b.iter(|| black_box(path).hash(&mut hasher)); | ||
|
||
black_box(hasher.finish()); | ||
} | ||
|
||
#[bench] | ||
fn bench_hash_path_long(b: &mut test::Bencher) { | ||
let mut hasher = DefaultHasher::new(); | ||
let path = | ||
Path::new("/aaaaa/aaaaaa/./../aaaaaaaa/bbbbbbbbbbbbb/ccccccccccc/ddddddddd/eeeeeee.fff"); | ||
|
||
b.iter(|| black_box(path).hash(&mut hasher)); | ||
|
||
black_box(hasher.finish()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use std::time::Instant; | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
use test::{Bencher, black_box}; | ||
|
||
macro_rules! bench_instant_threaded { | ||
($bench_name:ident, $thread_count:expr) => { | ||
#[bench] | ||
#[cfg(not(target_arch = "wasm32"))] | ||
fn $bench_name(b: &mut Bencher) -> std::thread::Result<()> { | ||
use std::sync::Arc; | ||
use std::sync::atomic::{AtomicBool, Ordering}; | ||
|
||
let running = Arc::new(AtomicBool::new(true)); | ||
|
||
let threads: Vec<_> = (0..$thread_count) | ||
.map(|_| { | ||
let flag = Arc::clone(&running); | ||
std::thread::spawn(move || { | ||
while flag.load(Ordering::Relaxed) { | ||
black_box(Instant::now()); | ||
} | ||
}) | ||
}) | ||
.collect(); | ||
|
||
b.iter(|| { | ||
let a = Instant::now(); | ||
let b = Instant::now(); | ||
assert!(b >= a); | ||
}); | ||
|
||
running.store(false, Ordering::Relaxed); | ||
|
||
for t in threads { | ||
t.join()?; | ||
} | ||
Ok(()) | ||
} | ||
}; | ||
} | ||
|
||
bench_instant_threaded!(instant_contention_01_threads, 0); | ||
bench_instant_threaded!(instant_contention_02_threads, 1); | ||
bench_instant_threaded!(instant_contention_04_threads, 3); | ||
bench_instant_threaded!(instant_contention_08_threads, 7); | ||
bench_instant_threaded!(instant_contention_16_threads, 15); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.