don't collect found paths into BTreeSet:

keeping order of inserted Paths having high cost on hot path, collect into HashSet instead and sort afterward.

from 1,858,963,938 to 1,448,975,825 I refs.
This commit is contained in:
klensy 2024-01-23 19:36:07 +03:00
parent e78d6859f7
commit 0710ebb999

View File

@ -25,7 +25,7 @@ use build_helper::git::{get_git_modified_files, get_git_untracked_files};
use core::panic;
use getopts::Options;
use lazycell::AtomicLazyCell;
use std::collections::BTreeSet;
use std::collections::HashSet;
use std::ffi::OsString;
use std::fs;
use std::io::{self, ErrorKind};
@ -415,7 +415,7 @@ pub fn run_tests(config: Arc<Config>) {
let mut tests = Vec::new();
for c in configs {
let mut found_paths = BTreeSet::new();
let mut found_paths = HashSet::new();
make_tests(c, &mut tests, &mut found_paths);
check_overlapping_tests(&found_paths);
}
@ -550,7 +550,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
pub fn make_tests(
config: Arc<Config>,
tests: &mut Vec<test::TestDescAndFn>,
found_paths: &mut BTreeSet<PathBuf>,
found_paths: &mut HashSet<PathBuf>,
) {
debug!("making tests from {:?}", config.src_base.display());
let inputs = common_inputs_stamp(&config);
@ -646,7 +646,7 @@ fn collect_tests_from_dir(
relative_dir_path: &Path,
inputs: &Stamp,
tests: &mut Vec<test::TestDescAndFn>,
found_paths: &mut BTreeSet<PathBuf>,
found_paths: &mut HashSet<PathBuf>,
modified_tests: &Vec<PathBuf>,
poisoned: &mut bool,
) -> io::Result<()> {
@ -1128,7 +1128,7 @@ fn not_a_digit(c: char) -> bool {
!c.is_digit(10)
}
fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
fn check_overlapping_tests(found_paths: &HashSet<PathBuf>) {
let mut collisions = Vec::new();
for path in found_paths {
for ancestor in path.ancestors().skip(1) {
@ -1138,6 +1138,7 @@ fn check_overlapping_tests(found_paths: &BTreeSet<PathBuf>) {
}
}
if !collisions.is_empty() {
collisions.sort();
let collisions: String = collisions
.into_iter()
.map(|(path, check_parent)| format!("test {path:?} clashes with {check_parent:?}\n"))