Skip to content

Commit

Permalink
eval-cache: add tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed Nov 27, 2024
1 parent 9e676eb commit 457b8b7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions devenv-eval-cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ serde_repr.workspace = true
sqlx.workspace = true
thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true

[dev-dependencies]
tempdir.workspace = true
12 changes: 10 additions & 2 deletions devenv-eval-cache/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::path::{Path, PathBuf};
use std::process::{self, Command, Stdio};
use std::time::{SystemTime, UNIX_EPOCH};
use thiserror::Error;
use tracing::{debug, info, trace};

use crate::{
db, hash,
Expand Down Expand Up @@ -284,15 +285,20 @@ async fn query_cached_output(

let mut should_refresh = false;

let file_input_hash = hash::digest(
let new_input_hash = hash::digest(
&files
.iter()
.map(|f| f.content_hash.clone())
.collect::<String>(),
);

// Hash of input hashes do not match
if cmd.input_hash != file_input_hash {
if cmd.input_hash != new_input_hash {
debug!(
old_hash = cmd.input_hash,
new_hash = new_input_hash,
"Input hashes do not match, refreshing command",
);
should_refresh = true;
}

Expand Down Expand Up @@ -330,6 +336,8 @@ async fn query_cached_output(
if should_refresh {
Ok(None)
} else {
trace!("Command has not been modified, returning cached output");

db::update_command_updated_at(pool, cmd.id)
.await
.map_err(CommandError::Sqlx)?;
Expand Down

0 comments on commit 457b8b7

Please sign in to comment.