Skip to content

Commit 51a87fc

Browse files
committed
feat: vendor crates required by opt-dist to collect profiles
These are the default package set required by opt-dist to correctly work, hence for people wanting to build a production grade of rustc in a sandboxed / air-gapped environment, these need to be vendored. The size of `rustc-src-nightly.tar.xz` before and after this change: * Before: 298M * After: 323M (+8%) These crates are the default set of packages required by opt-dist to correctly work, hence for people wanting to build a production grade of rustc in an sandboxed / air-gapped environment, these need to be vendored. The size of `rustc-src-nightly.tar.xz` before and after this change: * Before: 298M * After: 323M (+8%) Size change might or might not be a concern. See the previous discussion: rust-lang#125166 (comment) Previous efforts on making: * rust-lang#125125 * rust-lang#125166 --- Note that extra works still need to be done to make it fully vendored. * The current pinned rustc-perf uses `tempfile::Tempdir` as the working directory when collecting profiles from some of these packages. This "tmp" working directory usage make it impossible for Cargo to pick up the correct vendor sources setting in `.cargo/config.toml` bundled in the rustc-src tarball. [^1] * opt-dist verifies the final built rustc against a subset of rustc test suite. However it rolls out its own `config.toml` without setting `vendor = true`, and that results in `./vendor/` directory removed. [^2] [^1]: https://github.com/rust-lang/rustc-perf/blob/4f313add609f43e928e98132358e8426ed3969ae/collector/src/compile/benchmark/mod.rs#L164-L173 [^2]: https://github.com/rust-lang/rust/blob/606afbb617a2949a4e35c4b0258ff94c980b9451/src/tools/opt-dist/src/tests.rs#L62-L77
1 parent 3017fe5 commit 51a87fc

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+15
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,21 @@ impl Step for PlainSourceTarball {
10411041
.env("RUSTC_BOOTSTRAP", "1")
10421042
.current_dir(plain_dst_src);
10431043

1044+
// Vendor packages that are required by opt-dist to collect PGO profiles.
1045+
let pkgs_for_pgo_training = build_helper::metrics::LLVM_PGO_CRATES
1046+
.iter()
1047+
.chain(build_helper::metrics::RUSTC_PGO_CRATES)
1048+
.map(|pkg| {
1049+
let mut manifest_path =
1050+
builder.src.join("./src/tools/rustc-perf/collector/compile-benchmarks");
1051+
manifest_path.push(pkg);
1052+
manifest_path.push("Cargo.toml");
1053+
manifest_path
1054+
});
1055+
for manifest_path in pkgs_for_pgo_training {
1056+
cmd.arg("--sync").arg(manifest_path);
1057+
}
1058+
10441059
let config = if !builder.config.dry_run() {
10451060
t!(String::from_utf8(t!(cmd.output()).stdout))
10461061
} else {

src/tools/build_helper/src/metrics.rs

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
use serde_derive::{Deserialize, Serialize};
22

3+
/// The default set of crates for opt-dist to collect LLVM profiles.
4+
pub const LLVM_PGO_CRATES: &[&str] = &[
5+
"syn-1.0.89",
6+
"cargo-0.60.0",
7+
"serde-1.0.136",
8+
"ripgrep-13.0.0",
9+
"regex-1.5.5",
10+
"clap-3.1.6",
11+
"hyper-0.14.18",
12+
];
13+
14+
/// The default set of crates for opt-dist to collect rustc profiles.
15+
pub const RUSTC_PGO_CRATES: &[&str] = &[
16+
"externs",
17+
"ctfe-stress-5",
18+
"cargo-0.60.0",
19+
"token-stream-stress",
20+
"match-stress",
21+
"tuple-stress",
22+
"diesel-1.4.8",
23+
"bitmaps-3.1.0",
24+
];
25+
326
#[derive(Serialize, Deserialize)]
427
#[serde(rename_all = "snake_case")]
528
pub struct JsonRoot {

src/tools/opt-dist/src/training.rs

+1-21
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,10 @@ use crate::exec::{cmd, CmdBuilder};
33
use crate::utils::io::{count_files, delete_directory};
44
use crate::utils::with_log_group;
55
use anyhow::Context;
6+
use build_helper::metrics::{LLVM_PGO_CRATES, RUSTC_PGO_CRATES};
67
use camino::{Utf8Path, Utf8PathBuf};
78
use humansize::BINARY;
89

9-
const LLVM_PGO_CRATES: &[&str] = &[
10-
"syn-1.0.89",
11-
"cargo-0.60.0",
12-
"serde-1.0.136",
13-
"ripgrep-13.0.0",
14-
"regex-1.5.5",
15-
"clap-3.1.6",
16-
"hyper-0.14.18",
17-
];
18-
19-
const RUSTC_PGO_CRATES: &[&str] = &[
20-
"externs",
21-
"ctfe-stress-5",
22-
"cargo-0.60.0",
23-
"token-stream-stress",
24-
"match-stress",
25-
"tuple-stress",
26-
"diesel-1.4.8",
27-
"bitmaps-3.1.0",
28-
];
29-
3010
fn init_compiler_benchmarks(
3111
env: &Environment,
3212
profiles: &[&str],

0 commit comments

Comments
 (0)