public inbox for [email protected]  
help / color / mirror / Atom feed
Has gen_random_uuid() gotten much slower in v17?
8+ messages / 4 participants
[nested] [flat]

* Has gen_random_uuid() gotten much slower in v17?
@ 2024-09-10 13:58  David Mullineux <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Mullineux @ 2024-09-10 13:58 UTC (permalink / raw)
  To: [email protected]

I'm getting a bit concerned by the slow performance of generating uidds on
latest dev code versus older versions. Here I compare the time to generate
50k random uuids. Both son the same machine.
I must be missing something.

Any clues please ?


Attachments:

  [image/jpeg] IMG_20240910_145406_edit_500420330349988.jpg (798.0K, ../../CAGsyd8XBE7Ksq2Z75CTStrjSswOjVUE8S+i7qq1hGvYRj+_bcA@mail.gmail.com/3-IMG_20240910_145406_edit_500420330349988.jpg)
  download | view image

  [image/jpeg] IMG_20240910_145411_edit_500446221549093.jpg (742.9K, ../../CAGsyd8XBE7Ksq2Z75CTStrjSswOjVUE8S+i7qq1hGvYRj+_bcA@mail.gmail.com/4-IMG_20240910_145411_edit_500446221549093.jpg)
  download | view image

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-09-11 09:40  Peter Eisentraut <[email protected]>
  parent: David Mullineux <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Peter Eisentraut @ 2024-09-11 09:40 UTC (permalink / raw)
  To: David Mullineux <[email protected]>; [email protected]

On 10.09.24 15:58, David Mullineux wrote:
> I'm getting a bit concerned by the slow performance of generating uidds 
> on latest dev code versus older versions. Here I compare the time to 
> generate 50k random uuids. Both son the same machine.
> I must be missing something.

Are you sure that the 18devel installation isn't compiled with 
assertions enabled?

The underlying code for gen_random_uuid() is virtually unchanged between 
PG14 and current.






^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-09-11 10:47  David Mullineux <[email protected]>
  parent: Peter Eisentraut <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Mullineux @ 2024-09-11 10:47 UTC (permalink / raw)
  To: Peter Eisentraut <[email protected]>; +Cc: [email protected]

Good idea. Thanks.    I did check. It's not enabled by default but just in
case I did another build. This time explicitly defining --disable-debug and
--disable-cassert. And I tested. Still slower than old versions.

This feels like a build configuration problem. Just can't put my finger on
it yet.

On Wed, 11 Sept 2024, 10:40 Peter Eisentraut, <[email protected]> wrote:

> On 10.09.24 15:58, David Mullineux wrote:
> > I'm getting a bit concerned by the slow performance of generating uidds
> > on latest dev code versus older versions. Here I compare the time to
> > generate 50k random uuids. Both son the same machine.
> > I must be missing something.
>
> Are you sure that the 18devel installation isn't compiled with
> assertions enabled?
>
> The underlying code for gen_random_uuid() is virtually unchanged between
> PG14 and current.
>
>


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-11-20 10:35  Frédéric Yhuel <[email protected]>
  parent: David Mullineux <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Frédéric Yhuel @ 2024-11-20 10:35 UTC (permalink / raw)
  To: David Mullineux <[email protected]>; Peter Eisentraut <[email protected]>; +Cc: [email protected]



On 9/11/24 12:47, David Mullineux wrote:
> Good idea. Thanks.    I did check. It's not enabled by default but just 
> in case I did another build. This time explicitly defining --disable- 
> debug and --disable-cassert. And I tested. Still slower than old versions.
> 

4.5 seconds is very surprising.

on my machine:

postgres=# explain (analyze, costs off) select gen_random_uuid() from 
generate_series(1, 50000);
                                     QUERY PLAN 

----------------------------------------------------------------------------------
  Function Scan on generate_series (actual time=3.507..123.492 
rows=50000 loops=1)
  Planning Time: 0.031 ms
  Execution Time: 125.481 ms
(3 rows)

postgres=# select version();
                                            version 

----------------------------------------------------------------------------------------------
  PostgreSQL 18devel on x86_64-pc-linux-gnu, compiled by gcc (Debian 
12.2.0-14) 12.2.0, 64-bit

pg_config | grep CONFIGURE
CONFIGURE =  '--enable-cassert' '--enable-debug' '--with-python' 
'CFLAGS=-ggdb -Og -g3 -fno-omit-frame-pointer' '--prefix' 
'/postgres/pgenv/master'

> This feels like a build configuration problem. Just can't put my finger 
> on it yet.

Why not using a profiler to see what's going on?






^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-11-20 15:46  Tom Lane <[email protected]>
  parent: Frédéric Yhuel <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2024-11-20 15:46 UTC (permalink / raw)
  To: Frédéric Yhuel <[email protected]>; +Cc: David Mullineux <[email protected]>; Peter Eisentraut <[email protected]>; [email protected]

=?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= <[email protected]> writes:
> On 9/11/24 12:47, David Mullineux wrote:
>> This feels like a build configuration problem. Just can't put my finger 
>> on it yet.

> Why not using a profiler to see what's going on?

Yeah.  Also, are you building with openssl, or not?

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-11-20 22:11  David Mullineux <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Mullineux @ 2024-11-20 22:11 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Frédéric Yhuel <[email protected]>; Peter Eisentraut <[email protected]>; [email protected]

No, not at all!

On Wed, 20 Nov 2024, 15:46 Tom Lane, <[email protected]> wrote:

> =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= <[email protected]> writes:
> > On 9/11/24 12:47, David Mullineux wrote:
> >> This feels like a build configuration problem. Just can't put my finger
> >> on it yet.
>
> > Why not using a profiler to see what's going on?
>
> Yeah.  Also, are you building with openssl, or not?
>
>                         regards, tom lane
>


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-11-20 22:26  Tom Lane <[email protected]>
  parent: David Mullineux <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Tom Lane @ 2024-11-20 22:26 UTC (permalink / raw)
  To: David Mullineux <[email protected]>; +Cc: Frédéric Yhuel <[email protected]>; Peter Eisentraut <[email protected]>; [email protected]

[ please don't top-quote, it makes the conversation hard to follow ]

David Mullineux <[email protected]> writes:
> On Wed, 20 Nov 2024, 15:46 Tom Lane, <[email protected]> wrote:
>> Yeah.  Also, are you building with openssl, or not?

> No, not at all!

If you're not using openssl, then gen_random_uuid basically devolves
to a read of /dev/urandom.  Maybe you're using a different kernel
than before, and it has different properties around that?

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: Has gen_random_uuid() gotten much slower in v17?
@ 2024-11-26 15:23  David Mullineux <[email protected]>
  parent: Tom Lane <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: David Mullineux @ 2024-11-26 15:23 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Frédéric Yhuel <[email protected]>; Peter Eisentraut <[email protected]>; [email protected]

On Wed, 20 Nov 2024, 22:26 Tom Lane, <[email protected]> wrote:

> [ please don't top-quote, it makes the conversation hard to follow ]
>
> David Mullineux <[email protected]> writes:
> > On Wed, 20 Nov 2024, 15:46 Tom Lane, <[email protected]> wrote:
> >> Yeah.  Also, are you building with openssl, or not?
>
> > No, not at all!
>
> If you're not using openssl, then gen_random_uuid basically devolves
> to a read of /dev/urandom.  Maybe you're using a different kernel
> than before, and it has different properties around that?
>
>                         regards, tom lane
>

Just to say, thanks Tom. You were dead right. From the code in
pg_strong_random.c
it looks like each call will do an open("/dev/urandom")

And that cannot be fast.

Not sure why,but I guess there are good reasons to not keep a file
descriptor to that device open across calls ?

Thanks anyway


^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2024-11-26 15:23 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10 13:58 Has gen_random_uuid() gotten much slower in v17? David Mullineux <[email protected]>
2024-09-11 09:40 ` Peter Eisentraut <[email protected]>
2024-09-11 10:47   ` David Mullineux <[email protected]>
2024-11-20 10:35     ` Frédéric Yhuel <[email protected]>
2024-11-20 15:46       ` Tom Lane <[email protected]>
2024-11-20 22:11         ` David Mullineux <[email protected]>
2024-11-20 22:26           ` Tom Lane <[email protected]>
2024-11-26 15:23             ` David Mullineux <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox