From e9662ef8b6da853a58253ffb71c8be28f295482d Mon Sep 17 00:00:00 2001 From: Sayan Nandan Date: Sun, 8 Aug 2021 06:59:23 -0700 Subject: [PATCH] Use read_exact in loop-stage closure for getpool --- sky-bench/src/benchtool.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sky-bench/src/benchtool.rs b/sky-bench/src/benchtool.rs index f79c29dd..bb0eff0b 100644 --- a/sky-bench/src/benchtool.rs +++ b/sky-bench/src/benchtool.rs @@ -93,11 +93,15 @@ fn test_monoelement_calculation() { /// ``` #[allow(dead_code)] // TODO(@ohsayan): Remove this lint pub fn calculate_metaframe_size(queries: usize) -> usize { - let mut s = 0; - s += 1; // `*` - s += queries.to_string().len(); // the bytes in size string - s += 1; // `\n` - s + if queries == 1 { + SIMPLE_QUERY_SIZE + } else { + let mut s = 0; + s += 1; // `*` + s += queries.to_string().len(); // the bytes in size string + s += 1; // `\n` + s + } } #[test] @@ -210,9 +214,9 @@ pub fn runner( calculate_monoelement_dataframe_size(per_kv_size) + SIMPLE_QUERY_SIZE; let getpool = pool_config.with_loop_closure(move |sock: &mut TcpStream, packet: Vec| { sock.write_all(&packet).unwrap(); - // all `okay`s are returned (for both update and set) + // read exact for the key size let mut v = vec![0; get_response_packet_size]; - let _ = sock.read(&mut v).unwrap(); + let _ = sock.read_exact(&mut v).unwrap(); }); dt.create_timer("GET").unwrap(); dt.start_timer("GET").unwrap();