Re: UUID v7

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: "Andrey M(dot) Borodin" <x4mmm(at)yandex-team(dot)ru>
Cc: Sergey Prokhorenko <sergeyprokhorenko(at)yahoo(dot)com(dot)au>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Aleksander Alekseev <aleksander(at)timescale(dot)com>, pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Przemysław Sztoch <przemyslaw(at)sztoch(dot)pl>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Mat Arye <mat(at)timescaledb(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>, Junwang Zhao <zhjwpku(at)gmail(dot)com>
Subject: Re: UUID v7
Date: 2024-10-16 06:05:27
Message-ID: Zw9Xp1d_WLuoXioW@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Aug 04, 2024 at 03:50:37PM +0500, Andrey M. Borodin wrote:
> There was a bug: when time was not moving on, I was updating used
> time by a nanosecond, instead of 1/4096 of millisecond.
> V27 fixes that.

+static uint64 get_real_time_ns()
+{
+ struct timespec tmp;
+
+ clock_gettime(CLOCK_REALTIME, &tmp);
+ return tmp.tv_sec * 1000000000L + tmp.tv_nsec;
+}
[...]
+static uint64
+get_real_time_ns()
+{
+ FILETIME file_time;
+ ULARGE_INTEGER ularge;
+
+ GetSystemTimePreciseAsFileTime(&file_time);
+ ularge.LowPart = file_time.dwLowDateTime;
+ ularge.HighPart = file_time.dwHighDateTime;
+
+ return (ularge.QuadPart - epoch) * FILETIME_UNITS_TO_NS;
+}
+#endif

This part of the patch looks structurally wrong to me because we've
already spent some time refactoring the clock APIs into instr_time.h
that deals about cross-platform requirements for monotonic times.
Particularly, on MacOS, we have CLOCK_MONOTONIC_RAW, and your patch
does not use it. So you should avoid calling these routines, and
build something using the interface unified across the board, like
anywhere else. And you know, duplication.

The patch has a couple of typos, some spots:
- avaiable
- incresed_clock_precision
--
Michael

In response to

  • Re: UUID v7 at 2024-08-04 10:50:37 from Andrey M. Borodin

Responses

  • Re: UUID v7 at 2024-10-18 05:35:16 from Andrey M. Borodin

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2024-10-16 06:31:05 Re: Doc: shared_memory_size_in_huge_pages with the "SHOW" command.
Previous Message Yuto Sasaki (Fujitsu) 2024-10-16 06:04:23 Re: ECPG Refactor: move sqlca variable in ecpg_log()