Skip to content

Commit

Permalink
Rollup merge of rust-lang#120023 - klensy:tidy-alloc, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
tidy: reduce allocs

this reduces allocs in tidy from (dhat output)

```
==31349== Total:     1,365,199,543 bytes in 4,774,213 blocks
==31349== At t-gmax: 10,975,708 bytes in 66,093 blocks
==31349== At t-end:  2,880,947 bytes in 12,332 blocks
==31349== Reads:     5,210,008,956 bytes
==31349== Writes:    1,280,920,127 bytes
```
to
```
==66633== Total:     791,565,538 bytes in 3,503,144 blocks
==66633== At t-gmax: 10,914,511 bytes in 65,997 blocks
==66633== At t-end:  395,531 bytes in 941 blocks
==66633== Reads:     4,249,388,949 bytes
==66633== Writes:    814,119,580 bytes
```

by wrapping regex and updating `ignore` (effect probably not only from `ignore`, didn't measured)
  • Loading branch information
matthiaskrgr authored Feb 5, 2024
2 parents 8c0b4f6 + a9ba383 commit 3b20be5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 54 deletions.
80 changes: 36 additions & 44 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,9 @@ dependencies = [

[[package]]
name = "aho-corasick"
version = "0.7.20"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]

[[package]]
name = "aho-corasick"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41"
checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"
dependencies = [
"memchr",
]
Expand Down Expand Up @@ -319,13 +310,12 @@ dependencies = [

[[package]]
name = "bstr"
version = "1.5.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246e68bb43f6cd9db24bea052a53e40405417c5fb372e3d1a8a7f770a564ef5"
checksum = "c48f0051a4b4c5e0b6d365cd04af53aeaa209e3cc15ec2cdb69e73cc87fbd0dc"
dependencies = [
"memchr",
"once_cell",
"regex-automata 0.1.10",
"regex-automata 0.4.3",
"serde",
]

Expand Down Expand Up @@ -596,7 +586,7 @@ dependencies = [
name = "clippy_dev"
version = "0.0.1"
dependencies = [
"aho-corasick 1.0.2",
"aho-corasick",
"clap",
"indoc",
"itertools",
Expand Down Expand Up @@ -1597,15 +1587,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"

[[package]]
name = "globset"
version = "0.4.10"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1"
dependencies = [
"aho-corasick 0.7.20",
"aho-corasick",
"bstr",
"fnv",
"log",
"regex",
"regex-automata 0.4.3",
"regex-syntax 0.8.2",
]

[[package]]
Expand Down Expand Up @@ -1944,17 +1934,16 @@ checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed"

[[package]]
name = "ignore"
version = "0.4.20"
version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492"
checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1"
dependencies = [
"crossbeam-deque",
"globset",
"lazy_static",
"log",
"memchr",
"regex",
"regex-automata 0.4.3",
"same-file",
"thread_local",
"walkdir",
"winapi-util",
]
Expand Down Expand Up @@ -2274,9 +2263,9 @@ dependencies = [

[[package]]
name = "log"
version = "0.4.19"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"

[[package]]
name = "lzma-sys"
Expand Down Expand Up @@ -2378,9 +2367,9 @@ dependencies = [

[[package]]
name = "memchr"
version = "2.5.0"
version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -2490,9 +2479,6 @@ dependencies = [
[[package]]
name = "miropt-test-tools"
version = "0.1.0"
dependencies = [
"regex",
]

[[package]]
name = "native-tls"
Expand Down Expand Up @@ -3153,13 +3139,14 @@ dependencies = [

[[package]]
name = "regex"
version = "1.8.4"
version = "1.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0ab3ca65655bb1e41f2a8c8cd662eb4fb035e67c3f78da1d61dffe89d07300f"
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
dependencies = [
"aho-corasick 1.0.2",
"aho-corasick",
"memchr",
"regex-syntax 0.7.2",
"regex-automata 0.4.3",
"regex-syntax 0.8.2",
]

[[package]]
Expand All @@ -3181,16 +3168,21 @@ dependencies = [
]

[[package]]
name = "regex-syntax"
version = "0.6.29"
name = "regex-automata"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax 0.8.2",
]

[[package]]
name = "regex-syntax"
version = "0.7.2"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "436b050e76ed2903236f032a59761c1eb99e1b0aead2c257922771dab1fc8c78"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"

[[package]]
name = "regex-syntax"
Expand Down Expand Up @@ -5940,9 +5932,9 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "walkdir"
version = "2.3.3"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee"
dependencies = [
"same-file",
"winapi-util",
Expand Down
1 change: 0 additions & 1 deletion src/tools/miropt-test-tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ version = "0.1.0"
edition = "2021"

[dependencies]
regex = "1.0"
19 changes: 12 additions & 7 deletions src/tools/miropt-test-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ pub fn files_for_miropt_test(
} else {
// Allow-list for file extensions that can be produced by MIR dumps.
// Other extensions can be added here, as needed by new dump flags.
let ext_re = regex::Regex::new(r#"(\.(mir|dot))$"#).unwrap();
let cap = ext_re.captures_iter(test_name).next().unwrap_or_else(|| {
panic!("in {testfile:?}:\nEMIT_MIR has an unrecognized extension: {test_name}")
});
let extension = cap.get(1).unwrap().as_str();
static ALLOWED_EXT: &[&str] = &["mir", "dot"];
let Some((test_name_wo_ext, test_name_ext)) = test_name.rsplit_once('.') else {
panic!(
"in {testfile:?}:\nEMIT_MIR has an unrecognized extension: {test_name}, expected one of {ALLOWED_EXT:?}"
)
};
if !ALLOWED_EXT.contains(&test_name_ext) {
panic!(
"in {testfile:?}:\nEMIT_MIR has an unrecognized extension: {test_name}, expected one of {ALLOWED_EXT:?}"
)
}

expected_file =
format!("{}{}{}", test_name.trim_end_matches(extension), suffix, extension,);
expected_file = format!("{}{}.{}", test_name_wo_ext, suffix, test_name_ext);
from_file = test_name.to_string();
assert!(test_names.next().is_none(), "two mir pass names specified for MIR dump");
to_file = None;
Expand Down
6 changes: 4 additions & 2 deletions src/tools/tidy/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ fn should_ignore(line: &str) -> bool {
// Matches test annotations like `//~ ERROR text`.
// This mirrors the regex in src/tools/compiletest/src/runtest.rs, please
// update both if either are changed.
let re = Regex::new("\\s*//(\\[.*\\])?~.*").unwrap();
re.is_match(line) || ANNOTATIONS_TO_IGNORE.iter().any(|a| line.contains(a))
lazy_static::lazy_static! {
static ref ANNOTATION_RE: Regex = Regex::new("\\s*//(\\[.*\\])?~.*").unwrap();
}
ANNOTATION_RE.is_match(line) || ANNOTATIONS_TO_IGNORE.iter().any(|a| line.contains(a))
}

/// Returns `true` if `line` is allowed to be longer than the normal limit.
Expand Down

0 comments on commit 3b20be5

Please sign in to comment.