Re: Unnecessary connection overhead due copy-on-write (mainly openssl)

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Unnecessary connection overhead due copy-on-write (mainly openssl)
Date: 2025-06-06 11:56:08
Message-ID: 03fd56b7-9547-42cb-9d7f-73f4be48f837@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 05.06.25 21:58, Andres Freund wrote:
> The reason for this difference is that by default openssl registers an atexit
> handler that frees a lot of memory that was initialized in postmaster. That in
> turn triggers page-faults due to the relevant pages now differing in child
> processes. Which a) isn't cheap b) causes contention with postmaster, since
> those datastructures are shared.
>
>
> It's possible to tell openssl to not register an atexit handler, see [2]:
>
>> OPENSSL_INIT_NO_ATEXIT
>> By default OpenSSL will attempt to clean itself up when the process exits via
>> an "atexit" handler. Using this option suppresses that behaviour. This means
>> that the application will have to clean up OpenSSL explicitly using
>> OPENSSL_cleanup().

It seems weird to me that openssl spends so much effort tidying up its
memory allocations just before exiting. We could just skip that.
Looking through the code of OPENSSL_cleanup(), there might be one or two
cases of log or trace files that get flushed during cleanup, so it's not
an absolute no-brainer to skip all the cleanup.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-06-06 12:03:27 Re: Fix slot synchronization with two_phase decoding enabled
Previous Message Ajin Cherian 2025-06-06 11:44:44 Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding