You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by yj...@apache.org on 2025/03/31 04:25:43 UTC
(cloudberry) 02/02: Add optional support for CLOCK_MONOTONIC_COARSE when explain analyze.
This is an automated email from the ASF dual-hosted git repository.
yjhjstz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 7847a1534eb266ff62c5493bcc672f017152f2f3
Author: Jianghua Yang <yj...@gmail.com>
AuthorDate: Thu Mar 27 09:52:10 2025 +0800
Add optional support for CLOCK_MONOTONIC_COARSE when explain analyze.
Resolution of CLOCK_MONOTONIC_COARSE: 0.004000000 seconds, this change improve
explain analyze performance.
---
src/backend/executor/instrument.c | 2 +-
src/include/portability/instr_time.h | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/backend/executor/instrument.c b/src/backend/executor/instrument.c
index dc33c2b8e3..12561e0c05 100644
--- a/src/backend/executor/instrument.c
+++ b/src/backend/executor/instrument.c
@@ -123,7 +123,7 @@ InstrStopNodeSync(Instrumentation *instr, uint64 nTuples)
if (INSTR_TIME_IS_ZERO(instr->starttime))
elog(ERROR, "InstrStopNode called without start");
- INSTR_TIME_SET_CURRENT(endtime);
+ INSTR_TIME_SET_CURRENT_COARSE(endtime);
INSTR_TIME_ACCUM_DIFF(instr->counter, endtime, instr->starttime);
INSTR_TIME_SET_ZERO(instr->starttime);
diff --git a/src/include/portability/instr_time.h b/src/include/portability/instr_time.h
index 914d1b4431..124e1a065b 100644
--- a/src/include/portability/instr_time.h
+++ b/src/include/portability/instr_time.h
@@ -91,6 +91,12 @@ typedef struct timespec instr_time;
#define INSTR_TIME_SET_CURRENT(t) ((void) clock_gettime(PG_INSTR_CLOCK, &(t)))
+#ifdef CLOCK_MONOTONIC_COARSE
+#define INSTR_TIME_SET_CURRENT_COARSE(t) ((void) clock_gettime(CLOCK_MONOTONIC_COARSE, &(t)))
+#else
+#define INSTR_TIME_SET_CURRENT_COARSE(t) INSTR_TIME_SET_CURRENT(t)
+#endif
+
#define INSTR_TIME_ASSIGN(x,y) ((x).tv_sec = (y).tv_sec, (x).tv_nsec = (y).tv_nsec)
#define INSTR_TIME_ADD(x,y) \
@@ -157,6 +163,8 @@ typedef struct timeval instr_time;
#define INSTR_TIME_SET_CURRENT(t) gettimeofday(&(t), NULL)
+#define INSTR_TIME_SET_CURRENT_COARSE(t) INSTR_TIME_SET_CURRENT(t)
+
#define INSTR_TIME_ASSIGN(x,y) ((x).tv_sec = (y).tv_sec, (x).tv_usec = (y).tv_usec)
#define INSTR_TIME_ADD(x,y) \
@@ -223,6 +231,8 @@ typedef LARGE_INTEGER instr_time;
#define INSTR_TIME_SET_CURRENT(t) QueryPerformanceCounter(&(t))
+#define INSTR_TIME_SET_CURRENT_COARSE(t) INSTR_TIME_SET_CURRENT(t)
+
#define INSTR_TIME_ASSIGN(x,y) ((x).QuadPart = (y).QuadPart)
#define INSTR_TIME_ADD(x,y) \
@@ -257,6 +267,6 @@ GetTimerFrequency(void)
/* same macro on all platforms */
#define INSTR_TIME_SET_CURRENT_LAZY(t) \
- (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
+ (INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT_COARSE(t), true : false)
#endif /* INSTR_TIME_H */
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org