Skip to content

Commit e6488b4

Browse files
authored
Merge pull request #1992 from lqd/cg_clif
Add optional `backends` parameter to benchmarking requests
2 parents c1a170e + 700be8c commit e6488b4

File tree

14 files changed

+142
-52
lines changed

14 files changed

+142
-52
lines changed

collector/src/api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod next_artifact {
99
include: Option<String>,
1010
exclude: Option<String>,
1111
runs: Option<i32>,
12+
backends: Option<String>,
1213
},
1314
}
1415

collector/src/bin/collector.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,26 @@ fn main_result() -> anyhow::Result<i32> {
961961
include,
962962
exclude,
963963
runs,
964+
backends: requested_backends,
964965
} => {
966+
// Parse the requested backends, with LLVM as a fallback if none or no valid
967+
// ones were explicitly specified, which will be the case for the vast
968+
// majority of cases.
969+
let mut backends = vec![];
970+
if let Some(requested_backends) = requested_backends {
971+
let requested_backends = requested_backends.to_lowercase();
972+
if requested_backends.contains("llvm") {
973+
backends.push(CodegenBackend::Llvm);
974+
}
975+
if requested_backends.contains("cranelift") {
976+
backends.push(CodegenBackend::Cranelift);
977+
}
978+
}
979+
980+
if backends.is_empty() {
981+
backends.push(CodegenBackend::Llvm);
982+
}
983+
965984
// FIXME: remove this when/if NextArtifact::Commit's include/exclude
966985
// changed from Option<String> to Vec<String>
967986
// to not to manually parse args
@@ -973,12 +992,10 @@ fn main_result() -> anyhow::Result<i32> {
973992
}
974993
};
975994
let sha = commit.sha.to_string();
976-
let sysroot = Sysroot::install(
977-
sha.clone(),
978-
&target_triple,
979-
vec![CodegenBackend::Llvm],
980-
)
981-
.with_context(|| format!("failed to install sysroot for {:?}", commit))?;
995+
let sysroot = Sysroot::install(sha.clone(), &target_triple, &backends)
996+
.with_context(|| {
997+
format!("failed to install sysroot for {:?}", commit)
998+
})?;
982999

9831000
let mut benchmarks = get_compile_benchmarks(
9841001
&compile_benchmark_dir,
@@ -1001,7 +1018,7 @@ fn main_result() -> anyhow::Result<i32> {
10011018
Profile::Opt,
10021019
],
10031020
scenarios: Scenario::all(),
1004-
backends: vec![CodegenBackend::Llvm],
1021+
backends,
10051022
iterations: runs.map(|v| v as usize),
10061023
is_self_profile: self_profile.self_profile,
10071024
bench_rustc: bench_rustc.bench_rustc,
@@ -1174,7 +1191,7 @@ fn main_result() -> anyhow::Result<i32> {
11741191
let last_sha = String::from_utf8(last_sha.stdout).expect("utf8");
11751192
let last_sha = last_sha.split_whitespace().next().expect(&last_sha);
11761193
let commit = get_commit_or_fake_it(last_sha).expect("success");
1177-
let mut sysroot = Sysroot::install(commit.sha, &target_triple, codegen_backends.0)?;
1194+
let mut sysroot = Sysroot::install(commit.sha, &target_triple, &codegen_backends.0)?;
11781195
sysroot.preserve(); // don't delete it
11791196

11801197
// Print the directory containing the toolchain.

collector/src/toolchain.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ pub struct Sysroot {
2020
}
2121

2222
impl Sysroot {
23-
pub fn install(
24-
sha: String,
25-
triple: &str,
26-
backends: Vec<CodegenBackend>,
27-
) -> anyhow::Result<Self> {
23+
pub fn install(sha: String, triple: &str, backends: &[CodegenBackend]) -> anyhow::Result<Self> {
2824
let unpack_into = "cache";
2925

3026
fs::create_dir_all(unpack_into)?;

database/schema.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,12 @@ is attached to the entry in this table, it can be benchmarked.
238238
* exclude: which benchmarks should be excluded (corresponds to the `--exclude` benchmark parameter)
239239
* runs: how many iterations should be used by default for the benchmark run
240240
* commit_date: when was the commit created
241+
* backends: the codegen backends to use for the benchmarks (corresponds to the `--backends` benchmark parameter)
241242

242243
```
243244
sqlite> select * from pull_request_build limit 1;
244-
bors_sha pr parent_sha complete requested include exclude runs commit_date
245-
---------- -- ---------- -------- --------- ------- ------- ---- -----------
245+
bors_sha pr parent_sha complete requested include exclude runs commit_date backends
246+
---------- -- ---------- -------- --------- ------- ------- ---- ----------- --------
246247
1w0p83... 42 fq24xq... true <timestamp> 3 <timestamp>
247248
```
248249

database/src/bin/postgres-to-sqlite.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ impl Table for PullRequestBuild {
275275
}
276276

277277
fn postgres_select_statement(&self, _since_weeks_ago: Option<u32>) -> String {
278-
"select bors_sha, pr, parent_sha, complete, requested, include, exclude, runs from "
278+
"select bors_sha, pr, parent_sha, complete, requested, include, exclude, runs, backends from "
279279
.to_string()
280280
+ self.name()
281281
}
282282

283283
fn sqlite_insert_statement(&self) -> &'static str {
284-
"insert into pull_request_build (bors_sha, pr, parent_sha, complete, requested, include, exclude, runs) VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
284+
"insert into pull_request_build (bors_sha, pr, parent_sha, complete, requested, include, exclude, runs, backends) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"
285285
}
286286

287287
fn sqlite_execute_insert(&self, statement: &mut rusqlite::Statement, row: tokio_postgres::Row) {
@@ -296,6 +296,7 @@ impl Table for PullRequestBuild {
296296
row.get::<_, Option<&str>>(5),
297297
row.get::<_, Option<&str>>(6),
298298
row.get::<_, Option<i32>>(7),
299+
row.get::<_, Option<&str>>(8),
299300
])
300301
.unwrap();
301302
}

database/src/bin/sqlite-to-postgres.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ struct PullRequestBuildRow<'a> {
369369
exclude: Nullable<&'a str>,
370370
runs: Nullable<i32>,
371371
commit_date: Nullable<DateTime<Utc>>,
372+
backends: Nullable<&'a str>,
372373
}
373374

374375
impl Table for PullRequestBuild {
@@ -377,11 +378,11 @@ impl Table for PullRequestBuild {
377378
}
378379

379380
fn sqlite_attributes() -> &'static str {
380-
"bors_sha, pr, parent_sha, complete, requested, include, exclude, runs, commit_date"
381+
"bors_sha, pr, parent_sha, complete, requested, include, exclude, runs, commit_date, backends"
381382
}
382383

383384
fn postgres_attributes() -> &'static str {
384-
"bors_sha, pr, parent_sha, complete, requested, include, exclude, runs, commit_date"
385+
"bors_sha, pr, parent_sha, complete, requested, include, exclude, runs, commit_date, backends"
385386
}
386387

387388
fn postgres_generated_id_attribute() -> Option<&'static str> {
@@ -407,6 +408,7 @@ impl Table for PullRequestBuild {
407408
commit_date: Nullable(
408409
commit_date.map(|seconds| Utc.timestamp_opt(seconds, 0).unwrap()),
409410
),
411+
backends: row.get_ref(9).unwrap().try_into().unwrap(),
410412
})
411413
.unwrap();
412414
}

database/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub struct QueuedCommit {
2828
pub exclude: Option<String>,
2929
pub runs: Option<i32>,
3030
pub commit_date: Option<Date>,
31+
pub backends: Option<String>,
3132
}
3233

3334
#[derive(Debug, Hash, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]

database/src/pool.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ pub trait Connection: Send + Sync {
121121
include: Option<&str>,
122122
exclude: Option<&str>,
123123
runs: Option<i32>,
124+
backends: Option<&str>,
124125
);
125126
/// Returns true if this PR was queued waiting for a commit
126127
async fn pr_attach_commit(

database/src/pool/postgres.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ static MIGRATIONS: &[&str] = &[
278278
alter table pstat_series drop constraint pstat_series_crate_profile_cache_statistic_key;
279279
alter table pstat_series add constraint test_case UNIQUE(crate, profile, scenario, backend, metric);
280280
"#,
281+
r#"alter table pull_request_build add column backends text;"#,
281282
];
282283

283284
#[async_trait::async_trait]
@@ -736,14 +737,15 @@ where
736737
include: Option<&str>,
737738
exclude: Option<&str>,
738739
runs: Option<i32>,
740+
backends: Option<&str>,
739741
) {
740742
if let Err(e) = self.conn()
741743
.execute(
742-
"insert into pull_request_build (pr, complete, requested, include, exclude, runs) VALUES ($1, false, CURRENT_TIMESTAMP, $2, $3, $4)",
743-
&[&(pr as i32), &include, &exclude, &runs],
744+
"insert into pull_request_build (pr, complete, requested, include, exclude, runs, backends) VALUES ($1, false, CURRENT_TIMESTAMP, $2, $3, $4, $5)",
745+
&[&(pr as i32), &include, &exclude, &runs, &backends],
744746
)
745747
.await {
746-
log::error!("failed to queue_pr({}, {:?}, {:?}, {:?}): {:?}", pr, include, exclude, runs, e);
748+
log::error!("failed to queue_pr({}, {:?}, {:?}, {:?}, {:?}): {:?}", pr, include, exclude, runs, backends, e);
747749
}
748750
}
749751
async fn pr_attach_commit(
@@ -767,7 +769,7 @@ where
767769
let rows = self
768770
.conn()
769771
.query(
770-
"select pr, bors_sha, parent_sha, include, exclude, runs, commit_date from pull_request_build
772+
"select pr, bors_sha, parent_sha, include, exclude, runs, commit_date, backends from pull_request_build
771773
where complete is false and bors_sha is not null
772774
order by requested asc",
773775
&[],
@@ -783,6 +785,7 @@ where
783785
exclude: row.get(4),
784786
runs: row.get(5),
785787
commit_date: row.get::<_, Option<_>>(6).map(Date),
788+
backends: row.get(7),
786789
})
787790
.collect()
788791
}
@@ -792,7 +795,7 @@ where
792795
.query_opt(
793796
"update pull_request_build SET complete = true
794797
where bors_sha = $1
795-
returning pr, bors_sha, parent_sha, include, exclude, runs, commit_date",
798+
returning pr, bors_sha, parent_sha, include, exclude, runs, commit_date, backends",
796799
&[&sha],
797800
)
798801
.await
@@ -805,6 +808,7 @@ where
805808
exclude: row.get(4),
806809
runs: row.get(5),
807810
commit_date: row.get::<_, Option<_>>(6).map(Date),
811+
backends: row.get(7),
808812
})
809813
}
810814
async fn collection_id(&self, version: &str) -> CollectionId {

database/src/pool/sqlite.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ static MIGRATIONS: &[Migration] = &[
385385
alter table pstat_series_new rename to pstat_series;
386386
"#,
387387
),
388+
Migration::new("alter table pull_request_build add column backends text"),
388389
];
389390

390391
#[async_trait::async_trait]
@@ -909,13 +910,14 @@ impl Connection for SqliteConnection {
909910
include: Option<&str>,
910911
exclude: Option<&str>,
911912
runs: Option<i32>,
913+
backends: Option<&str>,
912914
) {
913915
self.raw_ref()
914916
.prepare_cached(
915-
"insert into pull_request_build (pr, complete, requested, include, exclude, runs) VALUES (?, 0, strftime('%s','now'), ?, ?, ?)",
917+
"insert into pull_request_build (pr, complete, requested, include, exclude, runs, backends) VALUES (?, 0, strftime('%s','now'), ?, ?, ?, ?)",
916918
)
917919
.unwrap()
918-
.execute(params![pr, include, exclude, &runs])
920+
.execute(params![pr, include, exclude, &runs, backends])
919921
.unwrap();
920922
}
921923
async fn pr_attach_commit(
@@ -939,7 +941,7 @@ impl Connection for SqliteConnection {
939941
async fn queued_commits(&self) -> Vec<QueuedCommit> {
940942
self.raw_ref()
941943
.prepare_cached(
942-
"select pr, bors_sha, parent_sha, include, exclude, runs, commit_date from pull_request_build
944+
"select pr, bors_sha, parent_sha, include, exclude, runs, commit_date, backends from pull_request_build
943945
where complete is false and bors_sha is not null
944946
order by requested asc",
945947
)
@@ -954,7 +956,8 @@ impl Connection for SqliteConnection {
954956
include: row.get(3).unwrap(),
955957
exclude: row.get(4).unwrap(),
956958
runs: row.get(5).unwrap(),
957-
commit_date: row.get::<_, Option<i64>>(6).unwrap().map(|timestamp| Date(DateTime::from_timestamp(timestamp, 0).unwrap()))
959+
commit_date: row.get::<_, Option<i64>>(6).unwrap().map(|timestamp| Date(DateTime::from_timestamp(timestamp, 0).unwrap())),
960+
backends: row.get(7).unwrap(),
958961
})
959962
})
960963
.collect::<Result<Vec<_>, _>>()
@@ -974,7 +977,7 @@ impl Connection for SqliteConnection {
974977
assert_eq!(count, 1, "sha is unique column");
975978
self.raw_ref()
976979
.query_row(
977-
"select pr, sha, parent_sha, include, exclude, runs, commit_date from pull_request_build
980+
"select pr, sha, parent_sha, include, exclude, runs, commit_date, backends from pull_request_build
978981
where sha = ?",
979982
params![sha],
980983
|row| {
@@ -985,7 +988,8 @@ impl Connection for SqliteConnection {
985988
include: row.get(3).unwrap(),
986989
exclude: row.get(4).unwrap(),
987990
runs: row.get(5).unwrap(),
988-
commit_date: row.get::<_, Option<i64>>(6).unwrap().map(|timestamp| Date(DateTime::from_timestamp(timestamp, 0).unwrap()))
991+
commit_date: row.get::<_, Option<i64>>(6).unwrap().map(|timestamp| Date(DateTime::from_timestamp(timestamp, 0).unwrap())),
992+
backends: row.get(7).unwrap(),
989993
})
990994
},
991995
)

site/frontend/src/pages/status/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export type MissingReason =
3939
include: string | null;
4040
exclude: string | null;
4141
runs: number | null;
42+
backends: string | null;
4243
};
4344
}
4445
| {

site/src/load.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub enum MissingReason {
3333
include: Option<String>,
3434
exclude: Option<String>,
3535
runs: Option<i32>,
36+
backends: Option<String>,
3637
},
3738
InProgress(Option<Box<MissingReason>>),
3839
}
@@ -382,6 +383,7 @@ fn calculate_missing_from(
382383
exclude,
383384
runs,
384385
commit_date,
386+
backends,
385387
} in queued_pr_commits
386388
.into_iter()
387389
// filter out any queued PR master commits (leaving only try commits)
@@ -407,6 +409,7 @@ fn calculate_missing_from(
407409
include,
408410
exclude,
409411
runs,
412+
backends,
410413
},
411414
));
412415
}
@@ -579,6 +582,7 @@ mod tests {
579582
exclude: None,
580583
runs: None,
581584
commit_date: None,
585+
backends: None,
582586
},
583587
QueuedCommit {
584588
sha: "b".into(),
@@ -588,6 +592,7 @@ mod tests {
588592
exclude: None,
589593
runs: None,
590594
commit_date: None,
595+
backends: None,
591596
},
592597
QueuedCommit {
593598
sha: "a".into(),
@@ -597,6 +602,7 @@ mod tests {
597602
exclude: None,
598603
runs: None,
599604
commit_date: None,
605+
backends: None,
600606
},
601607
];
602608
let in_progress_artifacts = vec![];
@@ -640,6 +646,7 @@ mod tests {
640646
include: None,
641647
exclude: None,
642648
runs: None,
649+
backends: None,
643650
},
644651
),
645652
];
@@ -689,6 +696,7 @@ mod tests {
689696
exclude: None,
690697
runs: None,
691698
commit_date: None,
699+
backends: None,
692700
},
693701
// A try run
694702
QueuedCommit {
@@ -699,6 +707,7 @@ mod tests {
699707
exclude: None,
700708
runs: None,
701709
commit_date: None,
710+
backends: None,
702711
},
703712
];
704713
let in_progress_artifacts = vec![];
@@ -746,6 +755,7 @@ mod tests {
746755
include: None,
747756
exclude: None,
748757
runs: None,
758+
backends: None,
749759
},
750760
),
751761
];

0 commit comments

Comments
 (0)