Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -3129,13 +3129,13 @@ histogram_bucket_timings(int index, double *b_start, double *b_end)
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.

for (int index = 0; index < hist_bucket_count_total; index++)
{
if (q_time >= hist_bucket_timings[index].start && q_time <= hist_bucket_timings[index].end)
if (q_time <= hist_bucket_timings[index].end)
return index;
}

/* 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.

return hist_bucket_count_total - 1;
}

Expand Down
Loading