about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-02-25 12:19:55 +0000
committerbors <bors@rust-lang.org>2024-02-25 12:19:55 +0000
commit26cd5d862e22c013ecb3396b177d3af80e95c836 (patch)
tree333da31f36a6b37e7f35afdd99f00f8181cb9e8a
parent43fdd4916d19f4004e23d422b5547637ad67ab21 (diff)
parenta13ec8d00396ac6f5a3f285f8fcd95a2ab6c8824 (diff)
downloadrust-26cd5d862e22c013ecb3396b177d3af80e95c836.tar.gz
rust-26cd5d862e22c013ecb3396b177d3af80e95c836.zip
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](https://github.com/rust-lang/rust/pull/118724#issuecomment-1848964908)

Resolves #109308

r? Mark-Simulacrum (I think you want to review this, feel free to change it if otherwise.)
-rw-r--r--src/bootstrap/src/utils/change_tracker.rs5
-rw-r--r--src/bootstrap/src/utils/tarball.rs19
-rw-r--r--src/tools/rust-installer/src/compression.rs11
-rw-r--r--src/tools/rust-installer/src/main.rs2
-rw-r--r--src/tools/rust-installer/src/tarballer.rs4
5 files changed, 37 insertions, 4 deletions
diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs
index b813d82ca6f..9a50ad4437e 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.",
+    },
 ];
diff --git a/src/bootstrap/src/utils/tarball.rs b/src/bootstrap/src/utils/tarball.rs
index 573d923ed8f..a14dfd1ca12 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,
diff --git a/src/tools/rust-installer/src/compression.rs b/src/tools/rust-installer/src/compression.rs
index 902b2ec6907..4e840dbfbb4 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 99acecdd43c..efb4c5bcb83 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 7572dc6dcf8..e5a925b2cbf 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