Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duration attributed to cache writes in the log #1495

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/compiler/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,40 +348,52 @@ where
let duration = start.elapsed();
if !compiler_result.status.success() {
debug!(
"[{}]: Compiled but failed, not storing in cache",
out_pretty
"[{}]: Compiled in {}, but failed, not storing in cache",
out_pretty,
fmt_duration_as_secs(&duration)
);
return Ok((CompileResult::CompileFailed, compiler_result));
}
if cacheable != Cacheable::Yes {
// Not cacheable
debug!("[{}]: Compiled but not cacheable", out_pretty);
debug!(
"[{}]: Compiled in {}, but not cacheable",
out_pretty,
fmt_duration_as_secs(&duration)
);
return Ok((CompileResult::NotCacheable, compiler_result));
}
debug!(
"[{}]: Compiled in {}, storing in cache",
out_pretty,
fmt_duration_as_secs(&duration)
);
let start_create_artifact = Instant::now();
let mut entry = CacheWrite::from_objects(outputs, &pool)
.await
.context("failed to zip up compiler outputs")?;

entry.put_stdout(&compiler_result.stdout)?;
entry.put_stderr(&compiler_result.stderr)?;
debug!(
"[{}]: Created cache artifact in {}",
out_pretty,
fmt_duration_as_secs(&start_create_artifact.elapsed())
);

let out_pretty2 = out_pretty.clone();
// Try to finish storing the newly-written cache
// entry. We'll get the result back elsewhere.
let future = async move {
let start = Instant::now();
match storage.put(&key, entry).await {
Ok(_) => debug!("[{}]: Stored in cache successfully!", out_pretty2),
Err(ref e) => debug!("[{}]: Cache write error: {:?}", out_pretty2, e),
}

Ok(CacheWriteInfo {
object_file_pretty: out_pretty2,
duration,
duration: start.elapsed(),
})
};
let future = Box::pin(future);
Expand Down