Skip to content

Commit 26cd5d8

Browse files
committed
Auto merge of #118724 - onur-ozkan:refactor-x-install, r=Mark-Simulacrum
speed up `x install` by skipping archiving and compression Performing archiving and compression on `x install` is nothing more than a waste of time and resources. Additionally, for systems like gentoo(which uses `x install`) this should be highly beneficial. [benchmark report](#118724 (comment)) Resolves #109308 r? Mark-Simulacrum (I think you want to review this, feel free to change it if otherwise.)
2 parents 43fdd49 + a13ec8d commit 26cd5d8

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
131131
severity: ChangeSeverity::Warning,
132132
summary: "The \"codegen\"/\"llvm\" profile has been removed and replaced with \"compiler\", use it instead for the same behavior.",
133133
},
134+
ChangeInfo {
135+
change_id: 118724,
136+
severity: ChangeSeverity::Info,
137+
summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.",
138+
},
134139
];

src/bootstrap/src/utils/tarball.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use std::{
33
process::Command,
44
};
55

6-
use crate::core::build_steps::dist::distdir;
76
use crate::core::builder::Builder;
7+
use crate::core::{build_steps::dist::distdir, builder::Kind};
88
use crate::utils::channel;
99
use crate::utils::helpers::t;
1010

@@ -325,7 +325,22 @@ impl<'a> Tarball<'a> {
325325
assert!(!formats.is_empty(), "dist.compression-formats can't be empty");
326326
cmd.arg("--compression-formats").arg(formats.join(","));
327327
}
328-
cmd.args(["--compression-profile", &self.builder.config.dist_compression_profile]);
328+
329+
// For `x install` tarball files aren't needed, so we can speed up the process by not producing them.
330+
let compression_profile = if self.builder.kind == Kind::Install {
331+
self.builder.verbose("Forcing dist.compression-profile = 'no-op' for `x install`.");
332+
// "no-op" indicates that the rust-installer won't produce compressed tarball sources.
333+
"no-op"
334+
} else {
335+
assert!(
336+
self.builder.config.dist_compression_profile != "no-op",
337+
"dist.compression-profile = 'no-op' can only be used for `x install`"
338+
);
339+
340+
&self.builder.config.dist_compression_profile
341+
};
342+
343+
cmd.args(&["--compression-profile", compression_profile]);
329344
self.builder.run(&mut cmd);
330345

331346
// Ensure there are no symbolic links in the tarball. In particular,

src/tools/rust-installer/src/compression.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use anyhow::{Context, Error};
22
use flate2::{read::GzDecoder, write::GzEncoder};
33
use rayon::prelude::*;
4-
use std::{convert::TryFrom, fmt, io::Read, io::Write, path::Path, str::FromStr};
4+
use std::{fmt, io::Read, io::Write, path::Path, str::FromStr};
55
use xz2::{read::XzDecoder, write::XzEncoder};
66

77
#[derive(Default, Debug, Copy, Clone)]
88
pub enum CompressionProfile {
9+
NoOp,
910
Fast,
1011
#[default]
1112
Balanced,
@@ -20,6 +21,7 @@ impl FromStr for CompressionProfile {
2021
"fast" => Self::Fast,
2122
"balanced" => Self::Balanced,
2223
"best" => Self::Best,
24+
"no-op" => Self::NoOp,
2325
other => anyhow::bail!("invalid compression profile: {other}"),
2426
})
2527
}
@@ -31,6 +33,7 @@ impl fmt::Display for CompressionProfile {
3133
CompressionProfile::Fast => f.write_str("fast"),
3234
CompressionProfile::Balanced => f.write_str("balanced"),
3335
CompressionProfile::Best => f.write_str("best"),
36+
CompressionProfile::NoOp => f.write_str("no-op"),
3437
}
3538
}
3639
}
@@ -78,10 +81,16 @@ impl CompressionFormat {
7881
CompressionProfile::Fast => flate2::Compression::fast(),
7982
CompressionProfile::Balanced => flate2::Compression::new(6),
8083
CompressionProfile::Best => flate2::Compression::best(),
84+
CompressionProfile::NoOp => panic!(
85+
"compression profile 'no-op' should not call `CompressionFormat::encode`."
86+
),
8187
},
8288
)),
8389
CompressionFormat::Xz => {
8490
let encoder = match profile {
91+
CompressionProfile::NoOp => panic!(
92+
"compression profile 'no-op' should not call `CompressionFormat::encode`."
93+
),
8594
CompressionProfile::Fast => {
8695
xz2::stream::MtStreamBuilder::new().threads(6).preset(1).encoder().unwrap()
8796
}

src/tools/rust-installer/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::{Context, Result};
2-
use clap::{self, Parser};
2+
use clap::Parser;
33

44
#[derive(Parser)]
55
struct CommandLine {

src/tools/rust-installer/src/tarballer.rs

+4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ actor! {
3838
impl Tarballer {
3939
/// Generates the actual tarballs
4040
pub fn run(self) -> Result<()> {
41+
if let CompressionProfile::NoOp = self.compression_profile {
42+
return Ok(());
43+
}
44+
4145
let tarball_name = self.output.clone() + ".tar";
4246
let encoder = CombinedEncoder::new(
4347
self.compression_formats

0 commit comments

Comments
 (0)