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-13990 Make handle-related stats private in the checkpoint module #11402

Merged
merged 9 commits into from
Jan 14, 2025

Conversation

etienneptl
Copy link
Contributor

This PR creates APIs in order to make the existing struct WT_CKPT_HANDLE_STATS private.

Copy link

github-actions bot commented Jan 10, 2025

Thanks for creating a pull request! Please answer the questions below by editing this comment.

Type of change made in this PR

  • Functional change
  • Test-only change
  • Refactor-only change
  • Other non-functional change

What makes this change safe?

Answering this question helps the reviewers understand where they should focus their attention. Please consider these prompts:

  • How risky is this change? Why?
    Low risk, creating new APIs to refactor the code.
  • What tests are you adding, changing or relying on? Why?
    Existing ones.
  • What, if anything, are you concerned about that you'd like the reviewer to focus on?
    Please double check the APIs are correct and if they make sense, they might seem overkill just to get to a private module.

References:

Checklist before requesting a review

  • I have performed a self-review of my code.
  • I have made corresponding changes to the documentation, or no documentation change is needed.
  • I have tests that show my change is correct, or have described above why functional test changes are not required.

Copy link

wiredtiger-prbot bot commented Jan 10, 2025

Test coverage is ok, please refer to the Code change/coverage report links below and try to improve it if feasible.

Metric (for added/changed code) Coverage
Line coverage 100% (27/27)
Branch coverage 76% (35/46)

Copy link
Contributor

@ershov ershov left a comment

Choose a reason for hiding this comment

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

Thanks Etienne, I like the change!
Just a couple of comments inside.

Comment on lines 667 to 670
if (F_ISSET(S2BT(session), WT_BTREE_SKIP_CKPT))
__wt_checkpoint_skip_handle_stats(session, &conn->ckpt, time_diff);
else
__wt_checkpoint_apply_handle_stats(session, &conn->ckpt, time_diff);
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you think to move this "if" into the function and merge the "skip" and "apply" functions into one? Then here it'd be just one function call and this logic would move inside the function.

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, I pointed out that it was a bit overkill in the description above. I am glad you think the same.
The issue with this approach is that we need something from the caller to tell us if we should be in the if or else statement.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought, the function could be literally like:

__wt_checkpoint_apply_handle_stats(...)
{
        if (F_ISSET(S2BT(session), WT_BTREE_SKIP_CKPT)) {
...
        } else {
...
        }

But it's a nitpick.

Copy link
Contributor Author

@etienneptl etienneptl Jan 13, 2025

Choose a reason for hiding this comment

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

I did not want to add more btree stuff in the checkpoint but I think it should be fine, what do you think about it @sueloverso?
Updated in 9575d88 but happy to revert if that was the wrong move.


/*
* __wt_checkpoint_set_handle_stats --
* Reset handle-related stats.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment copy-pasted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch! Fixed in c11788f

Copy link
Contributor

@ershov ershov left a comment

Choose a reason for hiding this comment

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

I have some readability suggestions but otherwise I'm happy with the PR!

* Update the skip handle-related stats.
*/
void
__wt_checkpoint_skip_handle_stats(
Copy link
Contributor

Choose a reason for hiding this comment

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

If you decide to keep these functions separate, then because this function is very similar to __wt_checkpoint_apply_handle_stats, I think it'd be more clear to put them next to each other.

Comment on lines 667 to 670
if (F_ISSET(S2BT(session), WT_BTREE_SKIP_CKPT))
__wt_checkpoint_skip_handle_stats(session, &conn->ckpt, time_diff);
else
__wt_checkpoint_apply_handle_stats(session, &conn->ckpt, time_diff);
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought, the function could be literally like:

__wt_checkpoint_apply_handle_stats(...)
{
        if (F_ISSET(S2BT(session), WT_BTREE_SKIP_CKPT)) {
...
        } else {
...
        }

But it's a nitpick.

struct __wti_ckpt_handle_stats {
uint64_t apply; /* handles applied */
uint64_t apply_time; /* applied handles gather time */
uint64_t drop; /* handles dropped */
Copy link
Contributor

@Sean04 Sean04 Jan 13, 2025

Choose a reason for hiding this comment

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

While we're here could you please improve this comment. I've been mislead by this implying dropping handles but it's actually dropping checkpoints for that handle. So I would replace it with:
handle checkpoints dropped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it mean we need to update the other fields too?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, updating the comment here where we define it is okay. If you encounter it elsewhere I expect the comment where it's defined to be what clarifies it.

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 in 738caf6

Copy link
Contributor

@Sean04 Sean04 left a comment

Choose a reason for hiding this comment

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

LGTM, nice change

@@ -664,13 +664,7 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle,
if (time_start != 0) {
time_stop = __wt_clock(session);
time_diff = WT_CLOCKDIFF_US(time_stop, time_start);
if (F_ISSET(S2BT(session), WT_BTREE_SKIP_CKPT)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible to have them incremented within the file_func?
Then there is no need to call a seperate function and the logic would become easier to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does it make it easier to understand though? You have to trace back what "file_func" is to know what it does.
Did you want to use file_func in __checkpoint_apply_operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed with @Siddhartha8899 online, we won't do it. This PR improves encapsulation but, unfortunately, not coupling. It would be great to revisit the code flow and make some effort towards making the coupling less complex.

Copy link
Member

@sueloverso sueloverso left a comment

Choose a reason for hiding this comment

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

LGTM

@etienneptl etienneptl added this pull request to the merge queue Jan 13, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 13, 2025
@etienneptl etienneptl added this pull request to the merge queue Jan 14, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 14, 2025
@etienneptl etienneptl added this pull request to the merge queue Jan 14, 2025
Merged via the queue into develop with commit d48adcd Jan 14, 2025
10 checks passed
@etienneptl etienneptl deleted the WT-13990-ckpt-handle-stats-api branch January 14, 2025 01:37
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.

5 participants