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

page_cache: eliminate PageWriteGuard #5119

Closed
wants to merge 1 commit into from

Conversation

problame
Copy link
Contributor

Since my #4994 , the page cache doesn't support mutating pages anymore.

The remaining role of PageWriteGuard is that of a fill handler. We can use FnOnce closures (or in an aysnc future: a Future) for that.

So, make the change now.

@problame problame requested a review from arpad-m August 28, 2023 09:06
@github-actions
Copy link

1624 tests run: 1547 passed, 0 failed, 77 skipped (full report)


The comment gets automatically updated with the latest test results
7d79ace at 2023-08-28T09:30:36.897Z :recycle:

@problame problame marked this pull request as ready for review August 28, 2023 12:13
@problame problame requested review from a team as code owners August 28, 2023 12:13
@problame problame requested review from conradludgate, skyzh and hlinnaka and removed request for a team, conradludgate and skyzh August 28, 2023 12:13
Copy link
Contributor

@hlinnaka hlinnaka left a comment

Choose a reason for hiding this comment

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

I don't know, the new interface doesn't feel very nice to me. I think the PageWriteGuard was a fine approach. Was the motivation just to simplify things? I like that this is less lines of code, but other than that I'm not sure it's really simpler.

If we turn this async in the future, we'll need to add an async variant that takes a Future, as you said. PageWriteGuard gives the caller more flexibility, and I don't think it's any more complicated in the callers either.

/// lock_for_read() return value
pub enum ReadBufResult<'a> {
Found(PageReadGuard<'a>),
NotFound(PageWriteGuard<'a>),
MissFilled,
Copy link
Contributor

Choose a reason for hiding this comment

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

In my head, this becomes "misfilled", i.e. filled incorrectly.

@@ -511,7 +445,14 @@ impl PageCache {
/// }
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the comment above

I find the usage a bit weird now. Could lock_for_read() always return PageReadGuard<'a> ? I.e it could do the looping and retrying.

Comment on lines +259 to +260
Already,
Inserted,
Copy link
Contributor

Choose a reason for hiding this comment

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

These need more comments and/or clearer names too, IMHO

@problame
Copy link
Contributor Author

I don't know, the new interface doesn't feel very nice to me. I think the PageWriteGuard was a fine approach. Was the motivation just to simplify things? I like that this is less lines of code, but other than that I'm not sure it's really simpler.

Motivation is the first point in #5111

The second point in #5111 is addressed by my #5122 which is stacked on top of this PR here.

@arpad-m
Copy link
Member

arpad-m commented Aug 28, 2023

FTR, as the remove_mapping function can stay sync, this PR isn't really required. (originally I wanted to make remove_mapping async in #5023 but Christian asked me if it's really needed to be async).

Also, personally I prefer the approach to just set the counter to 0 to this PR, like suggested in #5111.

@problame
Copy link
Contributor Author

problame commented Sep 1, 2023

Also, for the eventual switch to io-uring, having an owned buffer handle is required. PageWriteGuard is fit for that purpose. So, let's leave it and close this PR.

@problame problame closed this Sep 1, 2023
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