Skip to content

Clean up get_histogram_bucket()#753

Open
jeltz wants to merge 1 commit into
percona:mainfrom
jeltz:clean-get-historgram-bucket
Open

Clean up get_histogram_bucket()#753
jeltz wants to merge 1 commit into
percona:mainfrom
jeltz:clean-get-historgram-bucket

Conversation

@jeltz

@jeltz jeltz commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

In commit b2e5c69 I accidentally pushed the wrong thing plus a typo in a comment. While at it also remove a pointless lower range check because we already know that as we loop from low to high.

PG-0

Question for the reviewers: I am not sure what the cleanest way to write this function is but what I accidentally merged was a bit of mess where the comment contradicted the code.

In commit b2e5c69 I accidentally pushed
the wrong thing plus a typo in a comment. While at it also remove a
pointless lower range check because we already know that as we loop from
low to high.
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.13%. Comparing base (b2e5c69) to head (2eb7cbd).

Files with missing lines Patch % Lines
src/pg_stat_monitor.c 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #753      +/-   ##
==========================================
- Coverage   88.36%   88.13%   -0.23%     
==========================================
  Files           3        3              
  Lines        1332     1332              
  Branches      202      202              
==========================================
- Hits         1177     1174       -3     
- Misses         72       74       +2     
- Partials       83       84       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/pg_stat_monitor.c
}

/* Given the uppermost bound is inifity we should never reach this */
/* Given the uppermost bound is infinity we should never reach this */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The cleanup looks good, but is this comment always true?

	else if (index == b_count - 1 && q_max < HISTOGRAM_MAX_TIME)
	{
		*b_start = q_max;
		*b_end = INFINITY;
		return;
	}

But it can be also HISTOGRAM_MAX_TIME, in which case we don't add infinity.

Comment thread src/pg_stat_monitor.c
static int
get_histogram_bucket(double q_time)
{
for (int index = 0; index < hist_bucket_count_total - 1; index++)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought it was done intentionally. We don't check last bucket as it's always has open end bound and we will return this bucket as last option on line 3139.

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