v2-0002-pg_test_timing-use-int64-for-largest-observed-tim.patch
application/octet-stream
Filename: v2-0002-pg_test_timing-use-int64-for-largest-observed-tim.patch
Type: application/octet-stream
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0002
Subject: pg_test_timing: use int64 for largest observed time delta
| File | + | − |
|---|---|---|
| src/bin/pg_test_timing/pg_test_timing.c | 6 | 6 |
From d17974f31f8b11e240ffadaf0f134b4e82b7e2de Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Thu, 2 Apr 2026 10:29:06 +0800
Subject: [PATCH v2 2/2] pg_test_timing: use int64 for largest observed time
delta
pg_test_timing obtains timing deltas with INSTR_TIME_GET_NANOSEC(),
which returns a nanosecond value that should be stored in int64. Adjust
diff and largest_diff to use int64 accordingly.
Also fix the corresponding printf format specifiers so these values are
printed correctly.
Author: Chao Li <lic@highgo.com>
Reviewed-by: Lukas Fittl <lukas@fittl.com>
Discussion: https://postgr.es/m/F780CEEB-A237-4302-9F55-60E9D8B6533D@gmail.com
---
src/bin/pg_test_timing/pg_test_timing.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/bin/pg_test_timing/pg_test_timing.c b/src/bin/pg_test_timing/pg_test_timing.c
index cbdc5af09d9..323d98bbb61 100644
--- a/src/bin/pg_test_timing/pg_test_timing.c
+++ b/src/bin/pg_test_timing/pg_test_timing.c
@@ -25,7 +25,7 @@ static long long int histogram[32];
static long long int direct_histogram[NUM_DIRECT];
/* separately record highest observed duration */
-static int32 largest_diff;
+static int64 largest_diff;
static long long int largest_diff_count;
@@ -176,8 +176,8 @@ test_timing(unsigned int duration)
while (INSTR_TIME_GT(end_time, cur))
{
- int32 diff,
- bits;
+ int64 diff;
+ int32 bits;
instr_time diff_time;
prev = cur;
@@ -191,13 +191,13 @@ test_timing(unsigned int duration)
if (unlikely(diff < 0))
{
fprintf(stderr, _("Detected clock going backwards in time.\n"));
- fprintf(stderr, _("Time warp: %d ns\n"), diff);
+ fprintf(stderr, _("Time warp: %lld ns\n"), diff);
exit(1);
}
/* What is the highest bit in the time diff? */
if (diff > 0)
- bits = pg_leftmost_one_pos32(diff) + 1;
+ bits = pg_leftmost_one_pos64(diff) + 1;
else
bits = 0;
@@ -319,7 +319,7 @@ output(uint64 loop_count)
double prct = (double) largest_diff_count * 100 / loop_count;
printf("...\n");
- printf("%*d %*.4f %*.4f %*lld\n",
+ printf("%*lld %*.4f %*.4f %*lld\n",
len1, largest_diff,
len2, prct,
len3, 100.0,
--
2.50.1 (Apple Git-155)