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

WT-12693 Use bounded cursor for history store #10508

Draft
wants to merge 16 commits into
base: develop
Choose a base branch
from

Conversation

quchenhao
Copy link
Contributor

No description provided.

@quchenhao
Copy link
Contributor Author

quchenhao commented Apr 19, 2024

This is a POC of using bounded cursor for history store. We can optimize based on this initial implementation.

@@ -283,7 +283,7 @@ __curfile_reset(WT_CURSOR *cursor)
* guarding the call to cursor bound reset with the API_USER_ENTRY macro. Doing so prevents
* internal API calls from resetting cursor bounds unintentionally, e.g. cursor->remove.
*/
if (API_USER_ENTRY(session))
if (WT_IS_HS(session->dhandle) || API_USER_ENTRY(session))
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is done to allow for the history store cursor's reset logic to still reset the bounds

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, that's correct.

}
}
}
WT_RET(cursor->bound(cursor, "bound=lower,inclusive=true"));
Copy link
Contributor

Choose a reason for hiding this comment

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

In order for this to be performant, we need to use precompiled config. See bounded_cursor_perf.cpp for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
WT_RET(cursor->bound(cursor, "bound=lower,inclusive=true"));
WT_RET(cursor->next(cursor));
WT_RET(cursor->bound(cursor, "action=clear"));
Copy link
Contributor

Choose a reason for hiding this comment

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

The clear config should be compiled too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -630,6 +631,13 @@ __cursor_row_prev(
key->data = WT_INSERT_KEY(ins);
key->size = WT_INSERT_KEY_SIZE(ins);

if (WT_IS_HS(session->dhandle) && F_ISSET(&cbt->iface, WT_CURSTD_BOUND_UPPER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I understand why this is needed but I can't say I'm a fan of it. I think we'll need to think of a more generalizable solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not either. Do you have any better idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

At this stage my only thought is wondering if we can go a layer down and write a __cursor_row_search_before / after that intentionally places the cursor at the lowest level of WiredTiger. That sounds tedious and not like what we'd want right now. At the very least we should move this into its own function, I'll keep thinking, and have looped in Jie.

@@ -449,6 +450,13 @@ __cursor_row_next(
key->data = WT_INSERT_KEY(ins);
key->size = WT_INSERT_KEY_SIZE(ins);

if (WT_IS_HS(session->dhandle) && F_ISSET(&cbt->iface, WT_CURSTD_BOUND_LOWER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is already a function to check the bounds below. __wt_btcur_bounds_early_exit, If that function doesn't satisfy the requirement for HS, how about changing it to support HS also instead of adding separate code here?

@@ -501,6 +509,13 @@ __cursor_row_next(
*/
WT_RET(__cursor_row_slot_key_return(cbt, rip, &kpack));

if (WT_IS_HS(session->dhandle) && F_ISSET(&cbt->iface, WT_CURSTD_BOUND_LOWER)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here as well.

@luke-pearson
Copy link
Contributor

Jie and I have discussed this ticket and we both would like to explore alternate solutions to read uncommitted isolation support. We will create a ticket to track that work separately then revisit this. Is that okay @quchenhao?

@quchenhao
Copy link
Contributor Author

Jie and I have discussed this ticket and we both would like to explore alternate solutions to read uncommitted isolation support. We will create a ticket to track that work separately then revisit this. Is that okay @quchenhao?

SGTM!

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