Skip to content

Commit 78cc71f

Browse files
committed
Remove majority of printing
1 parent 5338aa3 commit 78cc71f

4 files changed

Lines changed: 47 additions & 21 deletions

File tree

oxcache/src/bin/evaluationclient.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ struct Cli {
3535

3636
#[tokio::main]
3737
async fn main() -> Result<(), Box<dyn std::error::Error>> {
38-
let nr_queries = 10000;
38+
let nr_queries = 1000000;
3939
let nr_uuids = 1000;
4040
let mut queries: Arc<Mutex<Vec<GetRequest>>> = Arc::new(Mutex::new(Vec::new()));
4141
let args = Cli::parse();
4242
let counter = Arc::new(AtomicUsize::new(0));
43-
43+
let step = nr_queries / 10; // 10%
4444
let mut rng = rng(); // uses fast, thread-local RNG
4545

4646
let mut uuids = Vec::with_capacity(nr_uuids);
@@ -55,7 +55,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
5555
.choose(&mut rng)
5656
.expect("uuids vec should not be empty")
5757
.clone();
58-
58+
5959
queries.push(GetRequest {
6060
key: uuid.to_string(),
6161
size: 8192,
@@ -83,7 +83,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
8383
let (read_half, write_half) = split(stream);
8484
let mut reader = FramedRead::new(read_half, LengthDelimitedCodec::new());
8585
let mut writer = FramedWrite::new(write_half, LengthDelimitedCodec::new());
86-
86+
8787
loop {
8888
let query_num = counter.fetch_add(1, Ordering::Relaxed) + 1;
8989

@@ -97,10 +97,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
9797
q = queries.pop().unwrap();
9898
}
9999

100-
if query_num % 100 == 0 {
101-
println!("[t.{}] Query num: {}/{}", c, query_num, nr_queries);
100+
if query_num % step == 0 {
101+
let percent = (query_num as f64 / nr_queries as f64) * 100.0;
102+
println!("[t.{}] Query num: {}/{} ({:.0}%)", c, query_num, nr_queries, percent);
102103
}
103104

105+
104106
let encoded = bincode::serde::encode_to_vec(
105107
Request::Get(q),
106108
bincode::config::standard()
@@ -136,6 +138,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
136138

137139
println!("Executed {} queries across {} clients", nr_queries, args.num_clients);
138140
println!("Total run time: {:.2?}", duration);
139-
141+
140142
Ok(())
141143
}

oxcache/src/device.rs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,13 @@ impl Device for BlockInterface {
386386
fn append(&self, data: Vec<u8>) -> std::io::Result<ChunkLocation> {
387387
let mtx = self.state.clone();
388388
let mut state = mtx.lock().unwrap();
389+
389390
let chunk_location = match state.active_zones.remove_chunk_location() {
390391
Ok(location) => location,
391392
Err(()) => {
393+
eprintln!(
394+
"[append] Failed to allocate chunk: no available space in active zones"
395+
);
392396
return Err(std::io::Error::new(
393397
std::io::ErrorKind::StorageFull,
394398
"Cache is full",
@@ -397,16 +401,21 @@ impl Device for BlockInterface {
397401
};
398402
drop(state);
399403

400-
let mut mut_data = vec![0u8; get_aligned_buffer_size(data.len(), self.nvme_config.logical_block_size as usize)];
404+
let aligned_size = get_aligned_buffer_size(data.len(), self.nvme_config.logical_block_size as usize);
405+
let mut mut_data = vec![0u8; aligned_size];
401406
mut_data[..data.len()].copy_from_slice(&data[..]);
402407

408+
let write_addr = get_address_at(
409+
chunk_location.zone as u64,
410+
chunk_location.index,
411+
(self.chunks_per_zone * self.chunk_size) as u64,
412+
self.chunk_size as u64,
413+
);
414+
415+
// println!("[append] writing chunk to {} bytes at addr {}", chunk_location.zone, write_addr);
416+
403417
match nvme::ops::write(
404-
get_address_at(
405-
chunk_location.zone as u64,
406-
chunk_location.index,
407-
(self.chunks_per_zone * self.chunk_size) as u64,
408-
self.chunk_size as u64,
409-
),
418+
write_addr,
410419
self.nvme_config.fd,
411420
0,
412421
self.nvme_config.nsid,
@@ -417,14 +426,26 @@ impl Device for BlockInterface {
417426
let mtx = Arc::clone(&self.evict_policy);
418427
let mut policy = mtx.lock().unwrap();
419428
policy.write_update(ChunkLocation::new(
420-
chunk_location.zone, chunk_location.index, // addr should be in chunks
429+
chunk_location.zone,
430+
chunk_location.index,
421431
));
422432
Ok(chunk_location)
423-
},
424-
Err(err) => Err(err.try_into().unwrap()),
433+
}
434+
Err(err) => {
435+
// eprintln!(
436+
// "[append] nvme::ops::write failed: zone={}, index={}, addr={}, size={} bytes. Error: {:?}",
437+
// chunk_location.zone,
438+
// chunk_location.index,
439+
// write_addr,
440+
// mut_data.len(),
441+
// err
442+
// );
443+
Err(err.try_into().unwrap())
444+
}
425445
}
426446
}
427447

448+
428449
fn read_into_buffer(
429450
&self,
430451
location: ChunkLocation,

oxcache/src/remote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl RemoteBackend for S3Backend {
8686
impl RemoteBackend for EmulatedBackend {
8787
async fn get(&self, key: &str, offset: usize, size: usize) -> tokio::io::Result<Vec<u8>> {
8888
// TODO: Implement
89-
println!("GET {} {} {}", key, offset, size);
89+
// println!("GET {} {} {}", key, offset, size);
9090
self.gen_random_buffer(key, offset, size)
9191
}
9292
}

oxcache/src/server.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ async fn handle_connection<T: RemoteBackend + Send + Sync + 'static>(
163163
let bytes = f.as_ref();
164164
let msg: Result<(request::Request, usize), DecodeError> =
165165
bincode::serde::decode_from_slice(bytes, bincode::config::standard());
166-
println!("Received: {:?}", msg);
166+
// println!("Received: {:?}", msg);
167167

168168
match msg {
169169
Ok((request, _)) => {
170-
println!("Received: {:?}", request);
170+
// println!("Received: {:?}", request);
171171
match request {
172172
request::Request::Get(req) => {
173173
if let Err(e) = req.validate(chunk_size) {
@@ -185,12 +185,13 @@ async fn handle_connection<T: RemoteBackend + Send + Sync + 'static>(
185185
continue;
186186
}
187187

188-
println!("Received get request: {:?}", req);
188+
// println!("Received get request: {:?}", req);
189189
let chunk: Chunk = req.into();
190190

191191
cache.get_or_insert_with(
192192
chunk.clone(),
193193
{
194+
// println!("HIT {:?}", chunk);
194195
let writer = Arc::clone(&writer);
195196
let reader_pool = Arc::clone(&reader_pool);
196197
|location| async move {
@@ -233,6 +234,8 @@ async fn handle_connection<T: RemoteBackend + Send + Sync + 'static>(
233234
}
234235
},
235236
{
237+
// println!("MISS {:?}", chunk);
238+
236239
let chunk = chunk.clone();
237240
let writer = Arc::clone(&writer);
238241
let remote = Arc::clone(&remote);

0 commit comments

Comments
 (0)