From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Support getrandom() for pg_strong_random() source |
Date: | 2025-07-22 06:43:35 |
Message-ID: | CAD21AoAjb2TP+Uj-fOr7s1cjv2Eq65BaUYi8xNMumcAXiYFM9Q@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi all,
Currently we have three options for pg_strong_random() sources:
1. OpenSSL's RAND_bytes()
2. Windows' CryptGenRandom() function
3. /dev/urandom
The patch supports the getrandom() function as a new source of
pg_strong_random(). The getrandom() function uses the same source as
the /dev/urandom device but it seems much faster than opening,
reading, and closing /dev/urandom. Here is the execution time of
generating 1 million UUIDv4 data measured on my environment:
HEAD(/dev/urandom): 1863.064 ms
Patched(getrandom()): 516.627 ms
I guess that while OpenSSL's RAND_bytes() should still be prioritized
where available it might be a good idea to support getrandom() for
builds where RAND_bytes() is not available.
Feedback is very welcome.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Support-getrandom-as-the-source-of-pg_strong_rand.patch | application/octet-stream | 5.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Vik Fearing | 2025-07-22 06:45:15 | Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions |
Previous Message | Amit Langote | 2025-07-22 06:43:26 | Re: generic plans and "initial" pruning |