Skip to content

Commit d0c8c80

Browse files
committed
Store artifact sizes into the database
1 parent 8c73955 commit d0c8c80

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

collector/src/bin/collector.rs

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use collector::compile::benchmark::{
1111
compile_benchmark_dir, get_compile_benchmarks, Benchmark, BenchmarkName,
1212
};
1313
use collector::{runtime, utils, CollectorCtx, CollectorStepBuilder};
14-
use database::{ArtifactId, Commit, CommitType, Connection, Pool};
14+
use database::{ArtifactId, ArtifactIdNumber, Commit, CommitType, Connection, Pool};
1515
use rayon::iter::{IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator};
1616
use std::cmp::Ordering;
1717
use std::ffi::OsStr;
@@ -978,6 +978,12 @@ fn run_benchmarks(
978978
compile: Option<CompileBenchmarkConfig>,
979979
runtime: Option<RuntimeBenchmarkConfig>,
980980
) -> anyhow::Result<()> {
981+
rt.block_on(record_toolchain_sizes(
982+
connection.as_mut(),
983+
&shared.artifact_id,
984+
&shared.toolchain,
985+
));
986+
981987
let collector = rt.block_on(init_collection(
982988
connection.as_mut(),
983989
&shared,
@@ -1190,6 +1196,38 @@ fn bench_compile(
11901196
errors
11911197
}
11921198

1199+
/// Records the sizes of individual components (rustc, libLLVM, etc.) for the given toolchain
1200+
/// and artifact id into the database.
1201+
async fn record_toolchain_sizes(
1202+
conn: &mut dyn Connection,
1203+
artifact_id: &ArtifactId,
1204+
toolchain: &Toolchain,
1205+
) {
1206+
let aid = conn.artifact_id(artifact_id).await;
1207+
1208+
async fn record(
1209+
conn: &mut dyn Connection,
1210+
aid: ArtifactIdNumber,
1211+
component: &str,
1212+
path: Option<&Path>,
1213+
) {
1214+
if let Some(path) = path {
1215+
if let Ok(size) = fs::metadata(path).map(|m| m.len()) {
1216+
conn.record_artifact_size(aid, component, size).await;
1217+
}
1218+
}
1219+
}
1220+
1221+
let paths = &toolchain.components;
1222+
record(conn, aid, "rustc", Some(&paths.rustc)).await;
1223+
record(conn, aid, "rustdoc", paths.rustdoc.as_deref()).await;
1224+
record(conn, aid, "cargo", Some(&paths.cargo)).await;
1225+
record(conn, aid, "librustc_driver", paths.lib_rustc.as_deref()).await;
1226+
record(conn, aid, "libstd", paths.lib_std.as_deref()).await;
1227+
record(conn, aid, "libtest", paths.lib_test.as_deref()).await;
1228+
record(conn, aid, "libLLVM", paths.lib_llvm.as_deref()).await;
1229+
}
1230+
11931231
fn add_perf_config(directory: &Path, category: Category) {
11941232
let data = serde_json::json!({
11951233
"category": category.to_string()

0 commit comments

Comments
 (0)