Skip to content

Commit e0b3764

Browse files
Support only touching a single file to ensure rebuilds
This doesn't adjust all the benchmarks yet; for most of them touching all the files is fine since they're a single crate anyway.
1 parent 71b9952 commit e0b3764

File tree

7 files changed

+40
-13
lines changed

7 files changed

+40
-13
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"cargo_toml": "cranelift-codegen/Cargo.toml"
2+
"cargo_toml": "cranelift-codegen/Cargo.toml",
3+
"touch_file": "cranelift-codegen/src/lib.rs"
34
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"cargo_opts": "--no-default-features",
33
"cargo_toml": "components/script/Cargo.toml",
4-
"runs": 1
4+
"runs": 1,
5+
"touch_file": "components/script/lib.rs"
56
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"cargo_toml": "serde/Cargo.toml"
2+
"cargo_toml": "serde/Cargo.toml",
3+
"touch_file": "serde/src/lib.rs"
34
}

collector/benchmarks/style-servo/perf-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"cargo_rustc_opts": "--cap-lints=warn",
44
"cargo_toml": "components/style/Cargo.toml",
55
"runs": 1,
6-
"supports_stable": true
6+
"supports_stable": true,
7+
"touch_file": "components/style/lib.rs"
78
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"cargo_toml": "wrench/Cargo.toml",
3-
"runs": 1
3+
"runs": 1,
4+
"touch_file": "wrench/src/main.rs"
45
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"cargo_toml": "webrender/Cargo.toml",
3-
"runs": 1
3+
"runs": 1,
4+
"touch_file": "webrender/src/lib.rs"
45
}

collector/src/execute.rs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ use std::time::Duration;
1919
use tempfile::TempDir;
2020
use tokio::runtime::Runtime;
2121

22+
fn touch(root: &Path, path: &Path) -> anyhow::Result<()> {
23+
let mut cmd = Command::new("touch");
24+
cmd.current_dir(root).arg(path);
25+
command_output(&mut cmd).with_context(|| format!("touching {:?} in {:?}", path, root))?;
26+
Ok(())
27+
}
28+
2229
fn touch_all(path: &Path) -> anyhow::Result<()> {
2330
let mut cmd = Command::new("bash");
2431
cmd.current_dir(path)
@@ -50,6 +57,13 @@ struct BenchmarkConfig {
5057
runs: usize,
5158
#[serde(default)]
5259
supports_stable: bool,
60+
61+
/// The file that should be touched to ensure cargo re-checks the leaf crate
62+
/// we're interested in. Likely, something similar to `src/lib.rs`. The
63+
/// default if this is not present is to touch all .rs files in the
64+
/// directory that `Cargo.toml` is in.
65+
#[serde(default)]
66+
touch_file: Option<String>,
5367
}
5468

5569
impl Default for BenchmarkConfig {
@@ -61,6 +75,7 @@ impl Default for BenchmarkConfig {
6175
disabled: false,
6276
runs: default_runs(),
6377
supports_stable: false,
78+
touch_file: None,
6479
}
6580
}
6681
}
@@ -191,6 +206,7 @@ struct CargoProcess<'a> {
191206
manifest_path: String,
192207
cargo_args: Vec<String>,
193208
rustc_args: Vec<String>,
209+
touch_file: Option<String>,
194210
}
195211

196212
impl<'a> CargoProcess<'a> {
@@ -301,13 +317,17 @@ impl<'a> CargoProcess<'a> {
301317
// benchmarking, so as to not refresh dependencies, which may be
302318
// in-tree (e.g., in the case of the servo crates there are a lot of
303319
// other components).
304-
touch_all(
305-
&self.cwd.join(
306-
Path::new(&self.manifest_path)
307-
.parent()
308-
.expect("manifest has parent"),
309-
),
310-
)?;
320+
if let Some(file) = &self.touch_file {
321+
touch(&self.cwd, Path::new(&file))?;
322+
} else {
323+
touch_all(
324+
&self.cwd.join(
325+
Path::new(&self.manifest_path)
326+
.parent()
327+
.expect("manifest has parent"),
328+
),
329+
)?;
330+
}
311331

312332
let output = command_output(&mut cmd)?;
313333
if let Some((ref mut processor, run_kind, run_kind_str, patch)) = self.processor_etc {
@@ -908,6 +928,7 @@ impl Benchmark {
908928
.split_whitespace()
909929
.map(String::from)
910930
.collect(),
931+
touch_file: self.config.touch_file.clone(),
911932
}
912933
}
913934

0 commit comments

Comments
 (0)