Skip to content

Commit

Permalink
chore: remove a bunch of in-line logging
Browse files Browse the repository at this point in the history
  • Loading branch information
rphmeier committed Aug 24, 2024
1 parent 3b060c0 commit 7f19541
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 75 deletions.
3 changes: 0 additions & 3 deletions nomt/src/beatree/ops/update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ pub fn update(
leaf_writer: &mut LeafStoreWriter,
bbn_writer: &mut bbn::BbnStoreWriter,
) -> Result<Vec<BranchId>> {
let now = std::time::Instant::now();
println!("start update");
let mut ctx = Ctx {
bbn_index,
bbn_writer,
Expand All @@ -66,7 +64,6 @@ pub fn update(

updater.complete(&mut ctx);

println!("update {}us", now.elapsed().as_micros());
Ok(updater.obsolete_branches)
}

Expand Down
3 changes: 3 additions & 0 deletions nomt/src/bitbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,10 @@ impl BucketAllocator {
let meta_map = self.shared.meta_map.read();
let mut probe_seq = ProbeSequence::new(&page_id, &meta_map);

let mut i = 0;
loop {
i += 1;
assert!(i < 10000, "hash-table full");
match probe_seq.next(&meta_map) {
ProbeResult::PossibleHit(bucket) => {
// skip unless another page has freed the bucket.
Expand Down
71 changes: 1 addition & 70 deletions nomt/src/io/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ use super::{CompleteIo, IoCommand, IoKind, IoKindResult, IoPacket, PAGE_SIZE};
use crossbeam_channel::{Receiver, Sender, TryRecvError};
use io_uring::{cqueue, opcode, squeue, types, IoUring};
use slab::Slab;
use std::{
collections::VecDeque,
time::{Duration, Instant},
};
use std::collections::VecDeque;

const RING_CAPACITY: u32 = 128;

Expand All @@ -15,7 +12,6 @@ const MAX_IN_FLIGHT: usize = RING_CAPACITY as usize;
struct PendingIo {
command: IoCommand,
completion_sender: Sender<CompleteIo>,
start: Instant,
}

pub fn start_io_worker(io_workers: usize) -> Sender<IoPacket> {
Expand Down Expand Up @@ -67,12 +63,9 @@ fn run_worker(command_rx: Receiver<IoPacket>) {
.expect("Error building io_uring");

let (submitter, mut submit_queue, mut complete_queue) = ring.split();
let mut stats = Stats::new();
let mut retries = VecDeque::<IoPacket>::new();

loop {
stats.log();

// 1. process completions.
if !pending.is_empty() {
complete_queue.sync();
Expand All @@ -83,11 +76,8 @@ fn run_worker(command_rx: Receiver<IoPacket>) {
let PendingIo {
command,
completion_sender,
start,
} = pending.remove(completion_event.user_data() as usize);

stats.note_completion(start.elapsed().as_micros() as u64);

// io_uring never uses errno to pass back error information.
// Instead, completion_event.result() will contain what the equivalent
// system call would have returned in case of success,
Expand Down Expand Up @@ -139,13 +129,10 @@ fn run_worker(command_rx: Receiver<IoPacket>) {
}
};

stats.note_arrival();

to_submit = true;
let pending_index = pending.insert(PendingIo {
command: next_io.command,
completion_sender: next_io.completion_sender,
start: Instant::now(),
});

let entry = submission_entry(&mut pending.get_mut(pending_index).unwrap().command)
Expand All @@ -166,62 +153,6 @@ fn run_worker(command_rx: Receiver<IoPacket>) {
}
}

struct Stats {
last_log: Instant,
total_inflight_us: u64,
completions: usize,
arrivals: usize,
}

impl Stats {
fn new() -> Self {
Stats {
last_log: Instant::now(),
total_inflight_us: 0,
completions: 0,
arrivals: 0,
}
}

fn note_completion(&mut self, inflight_us: u64) {
self.completions += 1;
self.total_inflight_us += inflight_us;
}

fn note_arrival(&mut self) {
self.arrivals += 1;
}

fn log(&mut self) {
const LOG_DURATION: Duration = Duration::from_millis(1000);

let elapsed = self.last_log.elapsed();
if elapsed < LOG_DURATION {
return;
}

self.last_log = Instant::now();
let arrival_rate = self.arrivals as f64 * 1000.0 / elapsed.as_millis() as f64;
let average_inflight = self.total_inflight_us as f64 / self.completions as f64;
println!(
"arrivals={} (rate {}/s) completions={} avg_inflight={}us | {}ms",
self.arrivals,
arrival_rate as usize,
self.completions,
average_inflight as usize,
elapsed.as_millis(),
);
println!(
" estimated-QD={:.1}",
arrival_rate * average_inflight / 1_000_000.0
);

self.completions = 0;
self.arrivals = 0;
self.total_inflight_us = 0;
}
}

fn submission_entry(command: &mut IoCommand) -> squeue::Entry {
match command.kind {
IoKind::Read(fd, page_index, ref mut buf) => {
Expand Down
2 changes: 0 additions & 2 deletions nomt/src/store/writeout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub fn run(
ln_extend_file_sz: Option<u64>,
new_meta: Meta,
) {
let now = std::time::Instant::now();
let io = IoDmux::new(io_handle);
do_run(
Cx {
Expand All @@ -52,7 +51,6 @@ pub fn run(
},
io,
);
println!("writeout {}us", now.elapsed().as_micros());
}

fn do_run(mut cx: Cx, mut io: IoDmux) {
Expand Down

0 comments on commit 7f19541

Please sign in to comment.