From 3197aee8b31faa200081143c9d353119400759df Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 22 Feb 2024 01:08:49 +0300 Subject: [PATCH 1/3] support `no-op` compression profile in rust-installer Signed-off-by: onur-ozkan --- src/tools/rust-installer/src/compression.rs | 11 ++++++++++- src/tools/rust-installer/src/main.rs | 2 +- src/tools/rust-installer/src/tarballer.rs | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/tools/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs index 902b2ec690784..4e840dbfbb441 100644 --- a/src/tools/rust-installer/src/compression.rs +++ b/src/tools/rust-installer/src/compression.rs @@ -1,11 +1,12 @@ use anyhow::{Context, Error}; use flate2::{read::GzDecoder, write::GzEncoder}; use rayon::prelude::*; -use std::{convert::TryFrom, fmt, io::Read, io::Write, path::Path, str::FromStr}; +use std::{fmt, io::Read, io::Write, path::Path, str::FromStr}; use xz2::{read::XzDecoder, write::XzEncoder}; #[derive(Default, Debug, Copy, Clone)] pub enum CompressionProfile { + NoOp, Fast, #[default] Balanced, @@ -20,6 +21,7 @@ impl FromStr for CompressionProfile { "fast" => Self::Fast, "balanced" => Self::Balanced, "best" => Self::Best, + "no-op" => Self::NoOp, other => anyhow::bail!("invalid compression profile: {other}"), }) } @@ -31,6 +33,7 @@ impl fmt::Display for CompressionProfile { CompressionProfile::Fast => f.write_str("fast"), CompressionProfile::Balanced => f.write_str("balanced"), CompressionProfile::Best => f.write_str("best"), + CompressionProfile::NoOp => f.write_str("no-op"), } } } @@ -78,10 +81,16 @@ impl CompressionFormat { CompressionProfile::Fast => flate2::Compression::fast(), CompressionProfile::Balanced => flate2::Compression::new(6), CompressionProfile::Best => flate2::Compression::best(), + CompressionProfile::NoOp => panic!( + "compression profile 'no-op' should not call `CompressionFormat::encode`." + ), }, )), CompressionFormat::Xz => { let encoder = match profile { + CompressionProfile::NoOp => panic!( + "compression profile 'no-op' should not call `CompressionFormat::encode`." + ), CompressionProfile::Fast => { xz2::stream::MtStreamBuilder::new().threads(6).preset(1).encoder().unwrap() } diff --git a/src/tools/rust-installer/src/main.rs b/src/tools/rust-installer/src/main.rs index 99acecdd43c35..efb4c5bcb83f9 100644 --- a/src/tools/rust-installer/src/main.rs +++ b/src/tools/rust-installer/src/main.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use clap::{self, Parser}; +use clap::Parser; #[derive(Parser)] struct CommandLine { diff --git a/src/tools/rust-installer/src/tarballer.rs b/src/tools/rust-installer/src/tarballer.rs index 7572dc6dcf885..e5a925b2cbf2d 100644 --- a/src/tools/rust-installer/src/tarballer.rs +++ b/src/tools/rust-installer/src/tarballer.rs @@ -38,6 +38,10 @@ actor! { impl Tarballer { /// Generates the actual tarballs pub fn run(self) -> Result<()> { + if let CompressionProfile::NoOp = self.compression_profile { + return Ok(()); + } + let tarball_name = self.output.clone() + ".tar"; let encoder = CombinedEncoder::new( self.compression_formats From 94597e85cfd2df40b467f087a12c8f727813b947 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 22 Feb 2024 01:09:12 +0300 Subject: [PATCH 2/3] force dist.compression-profile = "no-op" for `x install` Signed-off-by: onur-ozkan --- src/bootstrap/src/utils/tarball.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs index 573d923ed8fdd..a14dfd1ca1234 100644 --- a/src/bootstrap/src/utils/tarball.rs +++ b/src/bootstrap/src/utils/tarball.rs @@ -3,8 +3,8 @@ use std::{ process::Command, }; -use crate::core::build_steps::dist::distdir; use crate::core::builder::Builder; +use crate::core::{build_steps::dist::distdir, builder::Kind}; use crate::utils::channel; use crate::utils::helpers::t; @@ -325,7 +325,22 @@ impl<'a> Tarball<'a> { assert!(!formats.is_empty(), "dist.compression-formats can't be empty"); cmd.arg("--compression-formats").arg(formats.join(",")); } - cmd.args(["--compression-profile", &self.builder.config.dist_compression_profile]); + + // For `x install` tarball files aren't needed, so we can speed up the process by not producing them. + let compression_profile = if self.builder.kind == Kind::Install { + self.builder.verbose("Forcing dist.compression-profile = 'no-op' for `x install`."); + // "no-op" indicates that the rust-installer won't produce compressed tarball sources. + "no-op" + } else { + assert!( + self.builder.config.dist_compression_profile != "no-op", + "dist.compression-profile = 'no-op' can only be used for `x install`" + ); + + &self.builder.config.dist_compression_profile + }; + + cmd.args(&["--compression-profile", compression_profile]); self.builder.run(&mut cmd); // Ensure there are no symbolic links in the tarball. In particular, From a13ec8d00396ac6f5a3f285f8fcd95a2ab6c8824 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Thu, 22 Feb 2024 01:33:06 +0300 Subject: [PATCH 3/3] add changelog entry Signed-off-by: onur-ozkan --- src/bootstrap/src/utils/change_tracker.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs index b813d82ca6f53..9a50ad4437e73 100644 --- a/src/bootstrap/src/utils/change_tracker.rs +++ b/src/bootstrap/src/utils/change_tracker.rs @@ -131,4 +131,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[ severity: ChangeSeverity::Warning, summary: "The \"codegen\"/\"llvm\" profile has been removed and replaced with \"compiler\", use it instead for the same behavior.", }, + ChangeInfo { + change_id: 118724, + severity: ChangeSeverity::Info, + summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.", + }, ];