Skip to content

Commit

Permalink
Add to change to see its impact on the read performance of nvm-tree.
Browse files Browse the repository at this point in the history
  • Loading branch information
SajadKarim committed Jul 19, 2024
1 parent 3752f12 commit d0a93fe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion betree/src/tree/imp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 4 additions & 2 deletions betree/src/tree/imp/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,7 @@ impl<R: ObjectReference + HasStoragePreference + StaticSize> Object<R> 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,
Expand Down Expand Up @@ -600,12 +601,13 @@ impl<R: ObjectReference + HasStoragePreference + StaticSize> Object<R> 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());
Expand Down
24 changes: 23 additions & 1 deletion betree/src/tree/imp/nvminternal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub(super) struct NVMInternalNode<N: 'static> {
pub data_end: usize,
pub node_size: crate::vdev::Block<u32>,
pub checksum: Option<crate::checksum::XxHash>,
pub d_id: Option<DatasetId>,
pub nvm_load_details: std::sync::RwLock<NVMLazyLoadDetails>
}

Expand Down Expand Up @@ -400,7 +401,7 @@ impl<N: ObjectReference> NVMInternalNode<N> {
// 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");
// }
Expand All @@ -418,6 +419,22 @@ impl<N: ObjectReference> NVMInternalNode<N> {

*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) => {
Expand Down Expand Up @@ -455,6 +472,7 @@ impl<N> NVMInternalNode<N> {
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,
Expand Down Expand Up @@ -804,6 +822,7 @@ impl<N: ObjectReference> NVMInternalNode<N> {
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,
Expand Down Expand Up @@ -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<std::sync::RwLock<Option<InternalNodeData<N>>>>, 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)
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d0a93fe

Please sign in to comment.