diff --git a/server/src/cache.rs b/server/src/cache.rs index 392ca6d..746aa7c 100644 --- a/server/src/cache.rs +++ b/server/src/cache.rs @@ -1,5 +1,5 @@ // cache.rs -use chrono; +use chrono::{self, DateTime, Utc}; use log::{debug, info}; use rocket::{fs::NamedFile, response::Redirect}; use std::collections::VecDeque; @@ -64,6 +64,7 @@ impl DiskCache { redis_read: &RwLockReadGuard<'_, RedisServer>, ) -> GetFileResult { let uid_str = uid.into_os_string().into_string().unwrap(); + let start_time: DateTime = Utc::now(); // Human-readable start time let mut cache = cache.lock().await; let redirect = redis_read.location_lookup(uid_str.clone()).await; if let Some((x, p)) = redirect { @@ -107,10 +108,24 @@ impl DiskCache { debug!("get_file: {}", file_name_str); cache.update_access(&file_name_str); let cache_file_path = cache.cache_dir.join(file_name); - match NamedFile::open(cache_file_path).await { - Ok(x) => GetFileResult::Hit(x), - Err(_) => GetFileResult::NotFoundOnS3(uid_str), - } + drop(cache); + let result = match NamedFile::open(cache_file_path).await { + Ok(file) => GetFileResult::Hit(file), + Err(_) => GetFileResult::NotFoundOnS3(uid_str.clone()), + }; + + let end_time: DateTime = Utc::now(); // Human-readable end time + let duration = end_time - start_time; + + debug!( + "Request for {} started at {} and ended at {}, taking {:?}", + uid_str.clone(), + start_time.to_rfc3339(), + end_time.to_rfc3339(), + duration + ); + + result } async fn get_s3_file_to_cache( @@ -226,7 +241,7 @@ impl ConcurrentDiskCache { let result = DiskCache::get_file(shard.clone(), uid.into(), connector.clone(), &redis_read).await; drop(redis_read); - debug!("{}", self.get_stats().await); + info!("{}", self.get_stats().await); result } diff --git a/server/src/redis.rs b/server/src/redis.rs index 64f0b23..c82bba6 100644 --- a/server/src/redis.rs +++ b/server/src/redis.rs @@ -127,10 +127,6 @@ impl RedisServer { } self.slot_to_node_mapping = new_mapping; - debug!( - "Updated slot-to-node mapping: {:?}", - self.slot_to_node_mapping - ); Ok(()) } // Location lookup function that uses the updated mapping diff --git a/server/src/storage/s3_storage_connector.rs b/server/src/storage/s3_storage_connector.rs index b4a5146..a3e0531 100644 --- a/server/src/storage/s3_storage_connector.rs +++ b/server/src/storage/s3_storage_connector.rs @@ -1,5 +1,6 @@ use async_trait::async_trait; use aws_sdk_s3::{Client, Config, Credentials, Region}; +use chrono::{DateTime, Utc}; use log::debug; use rocket::futures::StreamExt; use std::io; @@ -53,6 +54,12 @@ impl StorageConnector for S3StorageConnector { // Assemble the object key with the file name let object_key = file_name; let start = Instant::now(); + let start_time: DateTime = Utc::now(); // Record start time + debug!( + "Start fetching object '{}' at {}", + file_name, + start_time.to_rfc3339() + ); // Attempt to fetch the object from S3 let result = self .client @@ -77,11 +84,8 @@ impl StorageConnector for S3StorageConnector { } file.flush().await?; let duration = start.elapsed(); - - debug!( - "Object '{}' fetched and cached successfully with size: {} bytes in {:?}", - file_name, file_size, duration - ); + let end_time: DateTime = Utc::now(); + debug!("End fetching object '{}'. Started at: {}, Ended at: {}, Duration: {:?}, File size: {} bytes.", file_name, start_time.to_rfc3339(), end_time.to_rfc3339(), duration, file_size); Ok((Path::new("").join(file_name), file_size)) } Err(aws_sdk_s3::SdkError::ServiceError { err, .. }) => {