From d0a93fecd3bd7267c74fe8558a862eb00fcc1c67 Mon Sep 17 00:00:00 2001 From: Sajad Karim Date: Fri, 19 Jul 2024 20:11:48 +0200 Subject: [PATCH] Add to change to see its impact on the read performance of nvm-tree. --- betree/src/tree/imp/mod.rs | 2 +- betree/src/tree/imp/node.rs | 6 ++++-- betree/src/tree/imp/nvminternal.rs | 24 +++++++++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/betree/src/tree/imp/mod.rs b/betree/src/tree/imp/mod.rs index 04612987..64c403cc 100644 --- a/betree/src/tree/imp/mod.rs +++ b/betree/src/tree/imp/mod.rs @@ -128,7 +128,7 @@ where dml: X, storage_preference: StoragePreference, ) -> Self { - let root_node = dml.insert(Node::empty_leaf(true), tree_id, PivotKey::Root(tree_id)); + let root_node = dml.insert(Node::empty_leaf(false), tree_id, PivotKey::Root(tree_id)); Tree::new(root_node, tree_id, msg_action, dml, storage_preference) } diff --git a/betree/src/tree/imp/node.rs b/betree/src/tree/imp/node.rs index 2f081640..3342e464 100644 --- a/betree/src/tree/imp/node.rs +++ b/betree/src/tree/imp/node.rs @@ -499,6 +499,7 @@ impl Object for Node< data_start: data_start, data_end: data_end, node_size: size, + d_id: None, checksum: Some(checksum), nvm_load_details: std::sync::RwLock::new(NVMLazyLoadDetails{ need_to_load_data_from_nvm: true, @@ -600,12 +601,13 @@ impl Object for Node< data_start: data_start, data_end: data_end, node_size: size, - checksum: Some(checksum), + checksum: Some(checksum), + d_id: Some(d_id), nvm_load_details: std::sync::RwLock::new(NVMLazyLoadDetails{ need_to_load_data_from_nvm: true, time_for_nvm_last_fetch: SystemTime::now(), nvm_fetch_counter: 0}), - }.complete_object_refs(d_id)))) + }/*.complete_object_refs(d_id)*/))) } else if data[0..4] == (NodeInnerType::NVMLeaf as u32).to_be_bytes() { let meta_data_len: usize = usize::from_be_bytes(data[4..12].try_into().unwrap()); let data_len: usize = usize::from_be_bytes(data[12..20].try_into().unwrap()); diff --git a/betree/src/tree/imp/nvminternal.rs b/betree/src/tree/imp/nvminternal.rs index c6492f2f..eddc5bf3 100644 --- a/betree/src/tree/imp/nvminternal.rs +++ b/betree/src/tree/imp/nvminternal.rs @@ -53,6 +53,7 @@ pub(super) struct NVMInternalNode { pub data_end: usize, pub node_size: crate::vdev::Block, pub checksum: Option, + pub d_id: Option, pub nvm_load_details: std::sync::RwLock } @@ -400,7 +401,7 @@ impl NVMInternalNode { // Also since at this point I am loading all the data so assuming that 'None' suggests all the data is already fetched. // if (*self.need_to_load_data_from_nvm.read().unwrap()) { - // println!("..............true"); + //panic!("..............true"); // } else { // println!("..............false"); // } @@ -418,6 +419,22 @@ impl NVMInternalNode { *self.data.write().unwrap() = Some(node); + let first_pk = match self.meta_data.pivot.first() { + Some(p) => PivotKey::LeftOuter(p.clone(), self.d_id.unwrap()), + None => unreachable!( + "The store contains an empty NVMInternalNode, this should never be the case." + ), + }; + for (id, pk) in [first_pk] + .into_iter() + .chain(self.meta_data.pivot.iter().map(|p| PivotKey::Right(p.clone(), self.d_id.unwrap()))) + .enumerate() + { + // SAFETY: There must always be pivots + 1 many children, otherwise + // the state of the Internal Node is broken. + self.data.write().as_mut().unwrap().as_mut().unwrap().children[id].as_mut().unwrap().complete_object_ref(pk) + } + return Ok(()); }, Err(e) => { @@ -455,6 +472,7 @@ impl NVMInternalNode { data_end: 0, node_size: crate::vdev::Block(0), checksum: None, + d_id: None, nvm_load_details: std::sync::RwLock::new(NVMLazyLoadDetails{ need_to_load_data_from_nvm: false, time_for_nvm_last_fetch: SystemTime::UNIX_EPOCH, @@ -804,6 +822,7 @@ impl NVMInternalNode { data_end: 0, node_size: crate::vdev::Block(0), checksum: None, + d_id: None, nvm_load_details: std::sync::RwLock::new(NVMLazyLoadDetails{ need_to_load_data_from_nvm: false, time_for_nvm_last_fetch: SystemTime::UNIX_EPOCH, @@ -1046,6 +1065,7 @@ impl<'a, N: Size + HasStoragePreference> PrepareMergeChild<'a, N> { impl<'a, N: Size + HasStoragePreference> NVMTakeChildBuffer<'a, N> { pub fn node_pointer_mut(&mut self) -> (&std::sync::Arc>>>, usize) where N: ObjectReference{ self.node.load_all_data(); + //self.node.complete_object_refs(self.node.d_id.unwrap()); //&mut self.node.data.write().as_mut().unwrap().as_mut().unwrap().children[self.child_idx].as_mut().unwrap().node_pointer (&self.node.data, self.child_idx) } @@ -1109,6 +1129,7 @@ mod tests { data_end: 0, node_size: crate::vdev::Block(0), checksum: None, + d_id: None, nvm_load_details: std::sync::RwLock::new(NVMLazyLoadDetails{ need_to_load_data_from_nvm: false, time_for_nvm_last_fetch: SystemTime::UNIX_EPOCH, @@ -1158,6 +1179,7 @@ mod tests { data_end: 0, node_size: crate::vdev::Block(0), checksum: None, + d_id: None, nvm_load_details: std::sync::RwLock::new(NVMLazyLoadDetails{ need_to_load_data_from_nvm: false, time_for_nvm_last_fetch: SystemTime::UNIX_EPOCH,