Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b29a1e0

Browse files
committedNov 27, 2023
Auto merge of #118352 - Zalathar:llvm-hash, r=onur-ozkan
bootstrap: Memoize the LLVM rebuild hash to avoid very slow `x check` Recently I've encountered a massive regression in the performance of re-running `x check` after making no changes. It used to take around 2 seconds, and now it takes 20-30 seconds. That's quite a hassle when r-a runs it every time I save. After some poking around, what I've found is that each individual call to `generate_smart_stamp_hash` doesn't take a particularly long time (around 0.5 sec), but it gets called dozens of times during `x check`, and that seems to be what's adding up to 20-30 seconds. --- https://rust-lang.zulipchat.com/#narrow/stream/326414-t-infra.2Fbootstrap/topic/Massive.20regression.20in.20no-op.20.60x.20check.60 cc `@onur-ozkan`
2 parents cc11307 + 4f1cf0b commit b29a1e0

File tree

1 file changed

+9
-5
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+9
-5
lines changed
 

‎src/bootstrap/src/core/build_steps/llvm.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::fs::{self, File};
1515
use std::io;
1616
use std::path::{Path, PathBuf};
1717
use std::process::Command;
18+
use std::sync::OnceLock;
1819

1920
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2021
use crate::core::config::{Config, TargetSelection};
@@ -105,13 +106,16 @@ pub fn prebuilt_llvm_config(
105106
let llvm_cmake_dir = out_dir.join("lib/cmake/llvm");
106107
let res = LlvmResult { llvm_config: build_llvm_config, llvm_cmake_dir };
107108

108-
let smart_stamp_hash = generate_smart_stamp_hash(
109-
&builder.config.src.join("src/llvm-project"),
110-
&builder.in_tree_llvm_info.sha().unwrap_or_default(),
111-
);
109+
static STAMP_HASH_MEMO: OnceLock<String> = OnceLock::new();
110+
let smart_stamp_hash = STAMP_HASH_MEMO.get_or_init(|| {
111+
generate_smart_stamp_hash(
112+
&builder.config.src.join("src/llvm-project"),
113+
&builder.in_tree_llvm_info.sha().unwrap_or_default(),
114+
)
115+
});
112116

113117
let stamp = out_dir.join("llvm-finished-building");
114-
let stamp = HashStamp::new(stamp, Some(&smart_stamp_hash));
118+
let stamp = HashStamp::new(stamp, Some(smart_stamp_hash));
115119

116120
if stamp.is_done() {
117121
if stamp.hash.is_none() {

0 commit comments

Comments
 (0)
Failed to load comments.