Skip to content

Commit a9c241d

Browse files
committed
refactor: remove duplicate debug logs and bench recon instrumentation
1 parent 48f58f5 commit a9c241d

2 files changed

Lines changed: 1 addition & 90 deletions

File tree

src/cached_xet_client.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use cas_types::{
1111
};
1212
use mdb_shard::file_structs::MDBFileInfo;
1313
use merklehash::MerkleHash;
14-
use tracing::debug;
1514

1615
type Result<T> = std::result::Result<T, cas_client::CasClientError>;
1716

@@ -150,7 +149,6 @@ impl Client for CachedXetClient {
150149

151150
if let Some(full) = cached_full {
152151
if let Some(range) = bytes_range {
153-
debug!("reconstruction derived from full-file cache for {file_id}");
154152
let resp = derive_range_response(&full, range);
155153
// Mirror the CAS server's EOF contract:
156154
// - Non-empty file, range past EOF → None
@@ -167,7 +165,6 @@ impl Client for CachedXetClient {
167165
);
168166
return Ok(Some(resp));
169167
} else {
170-
debug!("reconstruction cache hit for {file_id}");
171168
tracing::debug!("recon: HIT file={:.8} range=None terms={}", file_id, full.terms.len());
172169
return Ok(Some(full));
173170
}

tests/bench.rs

Lines changed: 1 addition & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,5 @@
11
mod common;
22

3-
struct ReconStats {
4-
cas: usize,
5-
hit: usize,
6-
derv: usize,
7-
}
8-
9-
/// Spawn hf-mount-fuse with RUST_LOG=hf_mount::cached_xet_client=debug and stderr
10-
/// redirected to `log_path`. Used by the bench to count CAS/HIT/DERV calls.
11-
fn mount_bucket_bench(
12-
bucket_id: &str,
13-
mount_point: &str,
14-
cache_dir: &str,
15-
log_path: &std::path::Path,
16-
) -> std::process::Child {
17-
let token = std::env::var("HF_TOKEN").unwrap();
18-
let binary = std::env::current_exe()
19-
.unwrap()
20-
.parent()
21-
.unwrap()
22-
.parent()
23-
.unwrap()
24-
.join("hf-mount-fuse");
25-
let ep = common::endpoint();
26-
std::fs::create_dir_all(mount_point).ok();
27-
std::fs::create_dir_all(cache_dir).ok();
28-
// tracing_subscriber::fmt() writes to stdout by default; clone fd to also capture stderr.
29-
let log_file = std::fs::File::create(log_path).expect("create bench log file");
30-
let log_file2 = log_file.try_clone().expect("clone bench log file");
31-
let child = std::process::Command::new(&binary)
32-
.args([
33-
"--hf-token",
34-
&token,
35-
"--hub-endpoint",
36-
&ep,
37-
"--cache-dir",
38-
cache_dir,
39-
"--poll-interval-secs",
40-
"0",
41-
])
42-
.args(["bucket", bucket_id, mount_point])
43-
.env("RUST_LOG", "hf_mount::cached_xet_client=debug")
44-
.stdout(log_file)
45-
.stderr(log_file2)
46-
.spawn()
47-
.expect("Failed to spawn hf-mount-fuse");
48-
for i in 0..30 {
49-
std::thread::sleep(std::time::Duration::from_millis(500));
50-
if let Ok(mounts) = std::fs::read_to_string("/proc/mounts")
51-
&& mounts.lines().any(|line| line.contains(mount_point))
52-
{
53-
eprintln!("Mount ready after {}ms", (i + 1) * 500);
54-
return child;
55-
}
56-
}
57-
eprintln!("Warning: mount may not be ready after 15s");
58-
child
59-
}
60-
61-
/// Parse a recon log file and count CAS/HIT/DERV lines.
62-
fn parse_recon_stats(log_path: &std::path::Path) -> ReconStats {
63-
let content = std::fs::read_to_string(log_path).unwrap_or_default();
64-
ReconStats {
65-
cas: content.lines().filter(|l| l.contains("recon: CAS")).count(),
66-
hit: content.lines().filter(|l| l.contains("recon: HIT")).count(),
67-
derv: content.lines().filter(|l| l.contains("recon: DERV")).count(),
68-
}
69-
}
70-
713
const BENCH_SIZES: &[(usize, &str)] = &[
724
(50 * 1024 * 1024, "50MB"),
735
(200 * 1024 * 1024, "200MB"),
@@ -120,10 +52,9 @@ async fn test_bench() {
12052
// --- FUSE benchmark (read + write per size) ---
12153
let fuse_mount = format!("/tmp/hf-bench-fuse-{}", pid);
12254
let fuse_cache = format!("/tmp/hf-bench-fuse-cache-{}", pid);
123-
let fuse_log = std::path::PathBuf::from(format!("/tmp/hf-bench-fuse-recon-{}.log", pid));
12455

12556
let fuse_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
126-
let child = mount_bucket_bench(&bucket_id, &fuse_mount, &fuse_cache, &fuse_log);
57+
let child = common::mount_bucket(&bucket_id, &fuse_mount, &fuse_cache, &[]);
12758

12859
let mut reads = Vec::new();
12960
for (filename, expected) in &files {
@@ -139,8 +70,6 @@ async fn test_bench() {
13970
(reads, writes)
14071
}));
14172

142-
let fuse_recon = parse_recon_stats(&fuse_log);
143-
std::fs::remove_file(&fuse_log).ok();
14473
std::fs::remove_dir_all(&fuse_mount).ok();
14574
std::fs::remove_dir_all(&fuse_cache).ok();
14675

@@ -227,21 +156,6 @@ async fn test_bench() {
227156
}
228157
eprintln!();
229158

230-
// --- FUSE reconstruction call stats (total across all reads) ---
231-
eprintln!("============================================================");
232-
eprintln!(" FUSE Reconstruction Calls (total read session)");
233-
eprintln!("------------------------------------------------------------");
234-
eprintln!(" {:30} {:>12}", "CAS calls (network)", fuse_recon.cas);
235-
eprintln!(" {:30} {:>12}", "HIT calls (in-memory cache)", fuse_recon.hit);
236-
eprintln!(" {:30} {:>12}", "DERV calls (derived from cache)", fuse_recon.derv);
237-
eprintln!(
238-
" {:30} {:>12}",
239-
"Total",
240-
fuse_recon.cas + fuse_recon.hit + fuse_recon.derv
241-
);
242-
eprintln!("============================================================");
243-
eprintln!();
244-
245159
// Assertions
246160
for (i, &(_, label)) in BENCH_SIZES.iter().enumerate() {
247161
assert!(fuse_reads[i].is_ok(), "FUSE read benchmark failed for {}", label);

0 commit comments

Comments
 (0)