From 457b8b79ee826b7fa83628d5eaa3fcc0b5db41f5 Mon Sep 17 00:00:00 2001 From: Sander Date: Wed, 27 Nov 2024 14:58:45 +0400 Subject: [PATCH] eval-cache: add tracing --- Cargo.lock | 1 + devenv-eval-cache/Cargo.toml | 1 + devenv-eval-cache/src/command.rs | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2556f46bd..66776564a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -584,6 +584,7 @@ dependencies = [ "tempdir", "thiserror", "tokio", + "tracing", ] [[package]] diff --git a/devenv-eval-cache/Cargo.toml b/devenv-eval-cache/Cargo.toml index 373c7b6ed..44c7178d6 100644 --- a/devenv-eval-cache/Cargo.toml +++ b/devenv-eval-cache/Cargo.toml @@ -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 diff --git a/devenv-eval-cache/src/command.rs b/devenv-eval-cache/src/command.rs index 2832cd555..077e00839 100644 --- a/devenv-eval-cache/src/command.rs +++ b/devenv-eval-cache/src/command.rs @@ -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, @@ -284,7 +285,7 @@ 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()) @@ -292,7 +293,12 @@ async fn query_cached_output( ); // 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; } @@ -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)?;