Skip to content

Commit ea95276

Browse files
Merge pull request #515 from nnethercote/invert-skip-self-profile
Invert --skip-self-profile
2 parents 2ce8476 + 3e23793 commit ea95276

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

ci/check-benchmarks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ git clone https://github.com/rust-lang-nursery/rustc-timing.git;
99
cargo build -p collector;
1010
RUST_BACKTRACE=1 RUST_LOG=collector=trace,rust_sysroot=debug \
1111
cargo run -p collector --bin collector -- \
12-
--skip-self-profile \
1312
--output-repo rustc-timing \
1413
--exclude servo,cargo,crates.io,packed-simd,sentry-cli,tuple-stress test_benchmarks;
1514
code=$?

collector/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ depending on the speed of your machine.
9494

9595
The following options, if present, must appear before `bench_local` in the
9696
command.
97+
- `--self-profile` can be used to do self-profiling, which requires the
98+
`measureme` tool.
9799
- `--filter $STR` can be used to run a subset of the benchmarks. `$STR` is a
98100
substring of the name of the benchmark(s) you wish to run.
99101
- `--exclude $STR` is the inverse of `--filter`. `$STR` is a substring of the
@@ -196,7 +198,15 @@ might be optimized.
196198

197199
### Profiling local builds
198200

199-
To profile local builds:
201+
To self-profile a local build:
202+
```
203+
RUST_LOG=info ./target/release/collector --output-repo $OUTPUT_DIR --self-profile \
204+
bench_local $PROFILER --rustc $RUSTC --cargo $CARGO $ID
205+
```
206+
207+
Then view the results the same way as for the `bench_local` subcommand.
208+
209+
To profile a local build with a different profiler:
200210
```
201211
RUST_LOG=info ./target/release/collector --output-repo $OUTPUT_DIR \
202212
profile $PROFILER --rustc $RUSTC --cargo $CARGO $ID

collector/src/bin/rustc-perf-collector/execute.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,14 +310,12 @@ pub struct MeasureProcessor {
310310
base_incr_stats: (Stats, Option<SelfProfile>),
311311
clean_incr_stats: (Stats, Option<SelfProfile>),
312312
patched_incr_stats: Vec<(Patch, (Stats, Option<SelfProfile>))>,
313-
314-
collecting_self_profile: bool,
315-
316-
should_collect_self_profile: bool,
313+
is_first_collection: bool,
314+
self_profile: bool,
317315
}
318316

319317
impl MeasureProcessor {
320-
pub fn new(collect_self_profile: bool) -> Self {
318+
pub fn new(self_profile: bool) -> Self {
321319
// Check we have `perf` available.
322320
let has_perf = Command::new("perf").output().is_ok();
323321
assert!(has_perf);
@@ -327,28 +325,28 @@ impl MeasureProcessor {
327325
base_incr_stats: (Stats::new(), None),
328326
clean_incr_stats: (Stats::new(), None),
329327
patched_incr_stats: Vec::new(),
330-
collecting_self_profile: true,
328+
is_first_collection: true,
331329
// Command::new("summarize").status().is_ok()
332-
should_collect_self_profile: collect_self_profile,
330+
self_profile,
333331
}
334332
}
335333
}
336334

337335
impl Processor for MeasureProcessor {
338336
fn profiler(&self) -> Profiler {
339-
if self.collecting_self_profile && self.should_collect_self_profile {
337+
if self.is_first_collection && self.self_profile {
340338
Profiler::PerfStatSelfProfile
341339
} else {
342340
Profiler::PerfStat
343341
}
344342
}
345343

346344
fn start_first_collection(&mut self) {
347-
self.collecting_self_profile = true;
345+
self.is_first_collection = true;
348346
}
349347

350348
fn finished_first_collection(&mut self) -> bool {
351-
self.collecting_self_profile = false;
349+
self.is_first_collection = false;
352350
true
353351
}
354352

collector/src/bin/rustc-perf-collector/main.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ where
150150
fn process_commits(
151151
out_repo: outrepo::Repo,
152152
benchmarks: &[Benchmark],
153-
collect_self_profile: bool,
153+
self_profile: bool,
154154
) -> anyhow::Result<()> {
155155
println!("processing commits");
156156
let client = reqwest::Client::new();
@@ -180,7 +180,7 @@ fn process_commits(
180180
&benchmarks,
181181
3,
182182
true,
183-
collect_self_profile,
183+
self_profile,
184184
));
185185
if let Err(err) = result {
186186
panic!("failed to record success: {:?}", err);
@@ -254,7 +254,7 @@ fn bench_commit(
254254
benchmarks: &[Benchmark],
255255
iterations: usize,
256256
call_home: bool,
257-
collect_self_profile: bool,
257+
self_profile: bool,
258258
) -> CommitData {
259259
info!(
260260
"benchmarking commit {} ({}) for triple {}",
@@ -285,11 +285,11 @@ fn bench_commit(
285285
}
286286

287287
let has_measureme = Command::new("summarize").output().is_ok();
288-
if collect_self_profile {
288+
if self_profile {
289289
assert!(
290290
has_measureme,
291291
"needs `summarize` in PATH for self profile.\n\
292-
Pass --skip-self-profile` to opt out"
292+
Omit --self-profile` to opt out"
293293
);
294294
}
295295

@@ -298,8 +298,7 @@ fn bench_commit(
298298
continue;
299299
}
300300

301-
// Only collect self-profile if we have summarize in the path
302-
let mut processor = execute::MeasureProcessor::new(collect_self_profile);
301+
let mut processor = execute::MeasureProcessor::new(self_profile);
303302
let result =
304303
benchmark.measure(&mut processor, build_kinds, run_kinds, compiler, iterations);
305304
let result = match result {
@@ -398,7 +397,7 @@ fn main_result() -> anyhow::Result<i32> {
398397
(@arg exclude: --exclude +takes_value "Ignore all benchmarks that contain this")
399398
(@arg sync_git: --("sync-git") "Synchronize repository with remote")
400399
(@arg output_repo: --("output-repo") +required +takes_value "Output repository/directory")
401-
(@arg skip_self_profile: --("skip-self-profile") "Skip self-profile")
400+
(@arg self_profile: --("self-profile") "Collect self-profile")
402401

403402
(@subcommand bench_commit =>
404403
(about: "benchmark a bors merge from AWS")
@@ -456,7 +455,7 @@ fn main_result() -> anyhow::Result<i32> {
456455
let exclude = matches.value_of("exclude");
457456
let benchmarks = get_benchmarks(&benchmark_dir, filter, exclude)?;
458457
let use_remote = matches.is_present("sync_git");
459-
let collect_self_profile = !matches.is_present("skip_self_profile");
458+
let self_profile = matches.is_present("self_profile");
460459

461460
let get_out_dir = || {
462461
let path = PathBuf::from(matches.value_of_os("output_repo").unwrap());
@@ -484,7 +483,7 @@ fn main_result() -> anyhow::Result<i32> {
484483
&benchmarks,
485484
3,
486485
false,
487-
collect_self_profile,
486+
self_profile,
488487
))?;
489488
Ok(0)
490489
}
@@ -524,7 +523,7 @@ fn main_result() -> anyhow::Result<i32> {
524523
&benchmarks,
525524
1,
526525
false,
527-
collect_self_profile,
526+
self_profile,
528527
);
529528
get_out_repo(true)?.add_commit_data(&result)?;
530529
Ok(0)
@@ -537,7 +536,7 @@ fn main_result() -> anyhow::Result<i32> {
537536
}
538537

539538
("process", Some(_)) => {
540-
process_commits(get_out_repo(false)?, &benchmarks, collect_self_profile)?;
539+
process_commits(get_out_repo(false)?, &benchmarks, self_profile)?;
541540
Ok(0)
542541
}
543542

@@ -622,7 +621,7 @@ fn main_result() -> anyhow::Result<i32> {
622621
&benchmarks,
623622
1,
624623
false,
625-
collect_self_profile,
624+
self_profile,
626625
);
627626
} else {
628627
panic!("no commits");

0 commit comments

Comments
 (0)