Re: libpq: SCRAM client proofs serialize across threads on OpenSSL 3 (re-init of the HMAC per PBKDF2 iteration)

From: Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>
To: Matthew Mochalkin <matthew(dot)mochalkin(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: libpq: SCRAM client proofs serialize across threads on OpenSSL 3 (re-init of the HMAC per PBKDF2 iteration)
Date: 2026-11-18 13:43:53
Message-ID: CAKZiRmyaAQZ_TJjrRa_Nu=_T3hPVNL8a8u1z7t1XRBoPrAbXxQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 17, 2026 at 5:37 PM Matthew Mochalkin
<matthew(dot)mochalkin(at)gmail(dot)com> wrote:
>
> Yes, same thing. The contention your perf report showed inside HMAC_Init_ex() is what the patch removes.
>
> I ran pgbench --connect through pgbouncer as you suggested. Same pgbench binary (master), base and patched libpq swapped with LD_LIBRARY_PATH. pgbouncer 1.24.1, auth_type = scram-sha-256, the role's SCRAM verifier in auth_file, PostgreSQL 16 behind it, OpenSSL 3.5.7, 8 CPUs for the client.
>
> pgbench --connect -n -c N -j N -T 20 -f select1.sql, connections per second:
>
> -c = -j base patched
> 1 403 451
> 8 1,170 5,380
> 16 734 8,555
>
> With the base libpq pgbench used 6-8 cores for those ~1,000 connections/s, the "1000% CPU" you saw. With the patch it uses about the same CPU for 5-8x the connections.
>

Cool! Perhaps just please register the $thread using
https://commitfest.postgresql.org and mark it as 'Needs review', so it's not
lost and somebody can later pick it up (You probably need to register there to
do that).

-J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matthew Mochalkin 2026-11-18 14:03:37 Re: libpq: SCRAM client proofs serialize across threads on OpenSSL 3 (re-init of the HMAC per PBKDF2 iteration)
Previous Message Rafael Chacón 2026-11-18 13:20:36 Re: Table synchronization cannot resume after a subscriber crash