Skip to content

Commit

Permalink
chore: Cache random stuff (#118)
Browse files Browse the repository at this point in the history
* Be a bit more aggressive with caching
  • Loading branch information
I-Al-Istannen authored Apr 22, 2024
1 parent 4cae481 commit c9b28e7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/enzyme-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ jobs:
with:
path: build/build/x86_64-unknown-linux-gnu/enzyme
key: ${{ matrix.os }}-enzyme-${{ steps.enzyme-commit.outputs.HEAD }}
- name: Cache bootstrap/stage0 artifacts for incremental builds
uses: actions/cache@v4
with:
path: |
build/build/bootstrap/
build/build/x86_64-unknown-linux-gnu/stage0-rustc/
build/build/x86_64-unknown-linux-gnu/stage0-std/
build/build/x86_64-unknown-linux-gnu/stage0-tools/
build/build/x86_64-unknown-linux-gnu/stage1-std/
# Approximate stable hash. It doesn't matter too much when this goes out of sync as it just caches
# some stage0/stage1 dependencies and stdlibs which *hopefully* are hash-keyed.
key: enzyme-rust-incremental-${{ runner.os }}-${{ hashFiles('src/**/Cargo.lock', 'Cargo.lock') }}
restore-keys: |
enzyme-rust-incremental-${{ runner.os }}
- name: Build
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
Expand Down
7 changes: 6 additions & 1 deletion src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,12 @@ impl HashStamp {

fn is_done(&self) -> bool {
match fs::read(&self.path) {
Ok(h) => self.hash.as_deref().unwrap_or(b"") == h.as_slice(),
Ok(h) => {
let unwrapped = self.hash.as_deref().unwrap_or(b"");
let res = unwrapped == h.as_slice();
eprintln!("Result for {:?}: {res:?} for expected '{unwrapped:?}' and read '{h:?}'", self.path);
res
},
Err(e) if e.kind() == io::ErrorKind::NotFound => false,
Err(e) => {
panic!("failed to read stamp file `{}`: {}", self.path.display(), e);
Expand Down
11 changes: 10 additions & 1 deletion src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1866,6 +1866,9 @@ pub fn generate_smart_stamp_hash(dir: &Path, additional_input: &str) -> String {
.map(|o| String::from_utf8(o.stdout).unwrap_or_default())
.unwrap_or_default();

eprintln!("Computing stamp for {dir:?}");
eprintln!("Diff output: {diff:?}");

let status = Command::new("git")
.current_dir(dir)
.arg("status")
Expand All @@ -1876,13 +1879,19 @@ pub fn generate_smart_stamp_hash(dir: &Path, additional_input: &str) -> String {
.map(|o| String::from_utf8(o.stdout).unwrap_or_default())
.unwrap_or_default();

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

hasher.update(diff);
hasher.update(status);
hasher.update(additional_input);

hex_encode(hasher.finalize().as_slice())
let result = hex_encode(hasher.finalize().as_slice());

eprintln!("Final hash: {result:?}");

result
}

/// Ensures that the behavior dump directory is properly initialized.
Expand Down

0 comments on commit c9b28e7

Please sign in to comment.