-
Notifications
You must be signed in to change notification settings - Fork 106
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
BM optimistic reads #1409
BM optimistic reads #1409
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1409 +/- ##
==========================================
+ Coverage 92.71% 92.74% +0.03%
==========================================
Files 642 642
Lines 22102 22126 +24
==========================================
+ Hits 20491 20521 +30
+ Misses 1611 1605 -6
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
e311c6c
to
57934bd
Compare
This PR adds
optimisticRead
interface to BM following the VMCache design. Any writes to file pages should go throughpin
/unpin
, and reads can go throughoptimisticRead
, which lifts the read-read lock contentions.Page states and versions
Pages managed by BM now have four states: a) Locked, b) Unlocked, c) Marked, d) Evicted.
Every page is initialized as in the Evicted state. When a page is pinned, it transits to the Locked state.
When the caller finishes changes to the page, it calls
unpin
, which releases the lock on the page, thus, the page transits to the Unlocked state.Any optimistic reads on Unlocked pages should not make any changes to the page, and reads on Marked pages will first set their states to Unlocked, and then read the page optimistically. For Evicted pages, optimistic reads will trigger pin and unpin to read pages from disk into frames.
Besides the page state, each page also has a version number. The version number is used to identify any potential writes on the page. Each time a page transits from Locked to Unlocked state, it will increment its version. When a page is pinned, then unpinned, it will transit from Locked to the Unlocked state, and its version will be incremented. During the pin and unpin, we assume the page's content in its corresponding frame might have changed, thus, we increment the version number to forbid stale reads on it.
Eviction
We still use queue-based eviction strategy.
To track pages that can potentially be evicted, we push unlocked pages into the eviction queue, and set their states to Marked, which means they are ready to be evicted.
After the candidate was enqueued: