Re: UUID v7

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
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>, Michael Paquier <michael(at)paquier(dot)xyz>, 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>, Stepan Neretin <sncfmgg(at)gmail(dot)com>
Subject: Re: UUID v7
Date: 2024-11-23 07:58:09
Message-ID: CAD21AoAe9b_GxxyRGXuWHXh8-K4KdqupV-38SCttEc-gpGWGMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 22, 2024 at 2:37 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Thu, Nov 21, 2024 at 1:22 PM Andrey M. Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
> >
> >
> >
> > > On 21 Nov 2024, at 02:24, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
> > >
> > > But does replacing the least significant 2 bits
> > > with random 2 bits really not affect monotonicity?
> >
> > You are right. We have to take into account this when calculating monotonicity. PFA another version.
> >
>
> While it works fine, I think we need a comment for this change:
>
> -#define SUB_MILLISECOND_STEP ((NS_PER_MS / (1 << 12)) + 1)
> +#if defined(__darwin__) || _MSC_VER
> +#define SUB_MILLISECOND_BITS 10
> +#else
> +#define SUB_MILLISECOND_BITS 12
> +#endif
> +#define SUB_MILLISECOND_STEP ((NS_PER_MS / (1 << SUB_MILLISECOND_BITS)) + 1)
>
> because the reader might think we should use SUB_MILLISECOND_BITS
> here too at a glance:
>
> + /* sub-millisecond timestamp fraction (12 bits) */
> + increased_clock_precision = ((ns % NS_PER_MS) * (1 << 12)) / NS_PER_MS;
>

I've attached an updated patch that squashed changes I made for v33.
We're still discussing increasing entropy on Windows and macOS, but
the patch seems to be in good shape.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v36-0001-Implement-UUID-v7.patch application/octet-stream 19.7 KB

In response to

  • Re: UUID v7 at 2024-11-22 22:37:25 from Masahiko Sawada

Responses

  • Re: UUID v7 at 2024-11-23 08:20:28 from Andrey M. Borodin

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrey M. Borodin 2024-11-23 08:20:28 Re: UUID v7
Previous Message jian he 2024-11-23 05:19:27 Re: CREATE SCHEMA ... CREATE DOMAIN support