From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | 杨江华 <yjhjstz(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Use CLOCK_MONOTONIC_COARSE for instr_time when available |
Date: | 2025-03-27 14:19:23 |
Message-ID: | xmtlid722biwnhrc7e7fvoqgr45evtinmjztjmjnbet4udfvae@dru4h3regeld |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On 2025-03-26 23:09:42 -0400, Tom Lane wrote:
> =?UTF-8?B?5p2o5rGf5Y2O?= <yjhjstz(at)gmail(dot)com> writes:
> > This patch modifies the instr_time.h header to prefer CLOCK_MONOTONIC_COARSE
> > when available.
>
> As far as I know, our usage of instr_time really needs the highest
> resolution available, because we are usually trying to measure pretty
> short intervals. You say that this patch reduces execution time,
> and I imagine that's true ... but I wonder if it doesn't do so at
> the cost of totally destroying the reliability of the output numbers.
The reason, on x86, the timestamp querying has a somewhat high overhead is
that the "accurate" "read the tsc" instruction serves as a barrier for
out-of-order execution. With modern highly out-of-order execution that means
we'll wait for all scheduled instructions to finish before determining the
current time, multiple times for each tuple. That of course slows things down
substantially.
There's a patch to use the version of rdtsc that does *not* have barrier
semantics:
https://postgr.es/m/CAP53PkzO2KpscD-tgFW_V-4WS%2BvkniH4-B00eM-e0bsBF-xUxg%40mail.gmail.com
Greetings,
Andres Freund
From | Date | Subject | |
---|---|---|---|
Next Message | Vik Fearing | 2025-03-27 14:27:50 | Re: SQL:2023 JSON simplified accessor support |
Previous Message | Álvaro Herrera | 2025-03-27 14:15:25 | Re: NOT ENFORCED constraint feature |