Re: Optimize scram_SaltedPassword performance

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Zixuan Fu <r33s3n6(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Optimize scram_SaltedPassword performance
Date: 2025-02-03 08:16:01
Message-ID: Z6B7QXlPwPXewaQZ@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 03, 2025 at 03:11:48PM +0800, Zixuan Fu wrote:
> With this change, the performance improves by approximately **4x** (reducing
> execution time from 4ms to 1ms). The built-in PostgreSQL HMAC implementation
> does not support context reuse, and modifying it would require substantial
> changes. Therefore, `pg_hmac_reuse()` simply calls `pg_hmac_init()` in that
> case, maintaining the existing logic.

I suspect that keeping an interface like pg_hmac_reuse() is going to
encourage incorrect practices in the long term, for a behavior that's
hidden in OpenSSL itself. In short, while I agree that the
performance could be better based on the information you are providing
(did not test nor check OpenSSL across the branches we support), your
proposal to address the problem makes me wonder that we'd better limit
this change localized into scram_SaltedPassword() rather than increase
the footprint of the APIs in the two HMAC-specific files of
src/common/.
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-02-03 08:50:15 Re: Show WAL write and fsync stats in pg_stat_io
Previous Message Álvaro Herrera 2025-02-03 07:57:21 Re: pgbench with partitioned tables