Skip to content

Commit c9b28e7

Browse files
chore: Cache random stuff (#118)
* Be a bit more aggressive with caching
1 parent 4cae481 commit c9b28e7

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.github/workflows/enzyme-ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ jobs:
4545
with:
4646
path: build/build/x86_64-unknown-linux-gnu/enzyme
4747
key: ${{ matrix.os }}-enzyme-${{ steps.enzyme-commit.outputs.HEAD }}
48+
- name: Cache bootstrap/stage0 artifacts for incremental builds
49+
uses: actions/cache@v4
50+
with:
51+
path: |
52+
build/build/bootstrap/
53+
build/build/x86_64-unknown-linux-gnu/stage0-rustc/
54+
build/build/x86_64-unknown-linux-gnu/stage0-std/
55+
build/build/x86_64-unknown-linux-gnu/stage0-tools/
56+
build/build/x86_64-unknown-linux-gnu/stage1-std/
57+
# Approximate stable hash. It doesn't matter too much when this goes out of sync as it just caches
58+
# some stage0/stage1 dependencies and stdlibs which *hopefully* are hash-keyed.
59+
key: enzyme-rust-incremental-${{ runner.os }}-${{ hashFiles('src/**/Cargo.lock', 'Cargo.lock') }}
60+
restore-keys: |
61+
enzyme-rust-incremental-${{ runner.os }}
4862
- name: Build
4963
run: |
5064
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,12 @@ impl HashStamp {
12111211

12121212
fn is_done(&self) -> bool {
12131213
match fs::read(&self.path) {
1214-
Ok(h) => self.hash.as_deref().unwrap_or(b"") == h.as_slice(),
1214+
Ok(h) => {
1215+
let unwrapped = self.hash.as_deref().unwrap_or(b"");
1216+
let res = unwrapped == h.as_slice();
1217+
eprintln!("Result for {:?}: {res:?} for expected '{unwrapped:?}' and read '{h:?}'", self.path);
1218+
res
1219+
},
12151220
Err(e) if e.kind() == io::ErrorKind::NotFound => false,
12161221
Err(e) => {
12171222
panic!("failed to read stamp file `{}`: {}", self.path.display(), e);

src/bootstrap/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,9 @@ pub fn generate_smart_stamp_hash(dir: &Path, additional_input: &str) -> String {
18661866
.map(|o| String::from_utf8(o.stdout).unwrap_or_default())
18671867
.unwrap_or_default();
18681868

1869+
eprintln!("Computing stamp for {dir:?}");
1870+
eprintln!("Diff output: {diff:?}");
1871+
18691872
let status = Command::new("git")
18701873
.current_dir(dir)
18711874
.arg("status")
@@ -1876,13 +1879,19 @@ pub fn generate_smart_stamp_hash(dir: &Path, additional_input: &str) -> String {
18761879
.map(|o| String::from_utf8(o.stdout).unwrap_or_default())
18771880
.unwrap_or_default();
18781881

1882+
eprintln!("Status output: {status:?}");
1883+
eprintln!("Additional input: {additional_input:?}");
18791884
let mut hasher = sha2::Sha256::new();
18801885

18811886
hasher.update(diff);
18821887
hasher.update(status);
18831888
hasher.update(additional_input);
18841889

1885-
hex_encode(hasher.finalize().as_slice())
1890+
let result = hex_encode(hasher.finalize().as_slice());
1891+
1892+
eprintln!("Final hash: {result:?}");
1893+
1894+
result
18861895
}
18871896

18881897
/// Ensures that the behavior dump directory is properly initialized.

0 commit comments

Comments
 (0)