Skip to content

Commit dcaf6cc

Browse files
committed
fix: resolving build errors
1 parent ccdcecc commit dcaf6cc

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

src/shell.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,20 @@ pub fn interpret_command(command: &str) {
275275
use crate::pmc;
276276
use core::hint::black_box;
277277

278+
// 'bench' -> RDTSC only (safe under plain QEMU/TCG)
279+
// 'bench pmc' -> also read LLC misses (ONLY under KVM -cpu host,pmu=on / bare metal)
280+
// 'bench disk' -> also run the FAT32 path (writes to disk)
281+
let want_pmc = arg.contains("pmc");
282+
let want_disk = arg.contains("disk");
283+
278284
println!("=== Axiom OS Benchmark Suite ===");
279285
println!("[bench] RDTSC cycle counts; black_box throughout to block dead-code elimination");
280-
println!("[bench] LLC-miss counts are valid ONLY under KVM (-cpu host,pmu=on) or bare metal;");
281-
println!("[bench] under pure QEMU/TCG they are meaningless and should not be reported.");
282-
pmc::init_cache_miss_counter();
286+
if want_pmc {
287+
println!("[bench] PMC on: LLC-miss counts valid ONLY under KVM (-cpu host,pmu=on)/bare metal");
288+
pmc::init_cache_miss_counter();
289+
} else {
290+
println!("[bench] PMC off (rdpmc faults under plain QEMU); run 'bench pmc' under KVM for misses");
291+
}
283292
println!("");
284293

285294
println!("--- BLAKE3 hash throughput ---");
@@ -318,7 +327,7 @@ pub fn interpret_command(command: &str) {
318327
println!("--- read+verify: whole-file vs block-level (proportional access) ---");
319328
println!("[bench] setup (alloc + insert) is OUTSIDE the timed loop; only read+verify is timed");
320329
{
321-
let sizes: [usize; 6] = [4096, 16384, 65536, 262144, 1048576, 4194304];
330+
let sizes: [usize; 5] = [4096, 16384, 65536, 262144, 1048576];
322331
for &sz in sizes.iter() {
323332
// --- setup once, OUTSIDE the timed region ---
324333
let mut v = crate::vfs::VirtualFS::new();
@@ -340,15 +349,17 @@ pub fn interpret_command(command: &str) {
340349
let _ = black_box(r);
341350
});
342351

343-
// single-shot cycles + LLC misses for each path (KVM/bare-metal only)
344-
let (_, wmiss, wcyc) = pmc::measure(|| { let r = v.read(black_box("bench")); black_box(r); });
345-
let (_, bmiss, bcyc) = pmc::measure(|| { let r = v.read_range(black_box("bench"), 0, 4096); black_box(r); });
346-
347352
println!("[size={} bytes, {} blocks]", sz, nblocks);
348353
bw.report();
349354
bb.report();
350-
println!("[pmc] wholefile: {} cyc, {} LLC-miss | block: {} cyc, {} LLC-miss",
351-
wcyc, wmiss, bcyc, bmiss);
355+
356+
// cycles + LLC misses per path — only when explicitly asked (KVM/bare-metal)
357+
if want_pmc {
358+
let (_, wmiss, wcyc) = pmc::measure(|| { let r = v.read(black_box("bench")); black_box(r); });
359+
let (_, bmiss, bcyc) = pmc::measure(|| { let r = v.read_range(black_box("bench"), 0, 4096); black_box(r); });
360+
println!("[pmc] wholefile: {} cyc, {} LLC-miss | block: {} cyc, {} LLC-miss",
361+
wcyc, wmiss, bcyc, bmiss);
362+
}
352363
}
353364
println!("[bench] expected shape: wholefile grows ~linearly with size; block stays ~flat");
354365
}
@@ -384,7 +395,7 @@ pub fn interpret_command(command: &str) {
384395

385396
println!("--- FAT32 persistent read+verify (skipped by default — it WRITES to disk) ---");
386397
println!("[bench] run 'bench disk' to include it, and ONLY against a throwaway disk image");
387-
if arg.trim() == "disk" {
398+
if want_disk {
388399
let payload = alloc::vec![0xCDu8; 512];
389400
FAT32.lock().write_file("bench.dat", &payload);
390401
let mut b = Benchmark::new("fat32_read_verify_512B");

0 commit comments

Comments
 (0)