Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: supports chains of StoreRevMut #175

Merged
merged 4 commits into from
Aug 2, 2023
Merged

feat: supports chains of StoreRevMut #175

merged 4 commits into from
Aug 2, 2023

Conversation

xinifinity
Copy link
Contributor

@xinifinity xinifinity commented Aug 2, 2023

This commits extends current implementation of StoreRevMut to support basing on top of another StoreRevMut, by chaining prev_deltas with current deltas from itself. This would be an essential step for Proposal support.

Base automatically changed from nit to main August 2, 2023 16:58
pub struct StoreRevMut {
base_space: Arc<dyn MemStoreR>,
deltas: Arc<RwLock<StoreRevMutDelta>>,
prev_deltas: Arc<StoreRevMutDelta>,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you change this to Arc<RwLock<StoreRevMutDelta>> this means you won't have to clone anything, just increasing reference counts. You'll have to get a few more read locks, but I think that's a very small price to pay.

I think this would allow you to remove a lot of the clone implementations too.

Suggested change
prev_deltas: Arc<StoreRevMutDelta>,
prev_deltas: Arc<RwLock<StoreRevMutDelta>>,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, discussed this offline. The reason I did a clone is in take_delta StoreDelta actually takes the ownership of the pages and the child StoreRevMut will no longer have reference to it. I tried a bit to share the references to the pages and give up, but let me try again. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, after debugged together, @rkuris posted the commit to defer the clone during take_delta(). This has to be fixed as it is expensive to do clone in commit, but we are trying to push down the clone so that we can complete remove that later. A new issue will be created for follow up.

Self {
base_space: other.base_space.clone(),
deltas: Default::default(),
prev_deltas: Arc::new(other.deltas.read().clone()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gets a lot easier with the type change above:

Suggested change
prev_deltas: Arc::new(other.deltas.read().clone()),
prev_deltas: other.deltas.clone(),

let wal_cfg = WalConfig::builder().build();
let disk_requester = init_buffer(buf_cfg, wal_cfg);

// TODO: Run the test in a separate standalone directory for concurrency reasons
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's doing this already?
nit: I think we have a method somewhere that creates a directory under target, which means cargo clean will remove it automatically.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you're right, I will remove the comment in a follow up PR.

There is still a bug to fix here in that the *guard assignment
should not be needed; will attempt to fix that today.
Copy link
Collaborator

@rkuris rkuris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We pair programmed some changes to unblock this for now

@xinifinity xinifinity merged commit 45cd6e6 into main Aug 2, 2023
5 checks passed
@xinifinity xinifinity deleted the store_rev_mut branch August 2, 2023 21:27
Copy link
Contributor

@richardpringle richardpringle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// TODO: Run the test in a separate standalone directory for concurrency reasons
let tmp_dir = TempDir::new("firewood").unwrap();
let path = get_file_path(tmp_dir.path(), file!(), line!());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants