Re: Unnecessary connection overhead due copy-on-write (mainly openssl) - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Unnecessary connection overhead due copy-on-write (mainly openssl)
Date
Msg-id 03fd56b7-9547-42cb-9d7f-73f4be48f837@eisentraut.org
Whole thread Raw
In response to Unnecessary connection overhead due copy-on-write (mainly openssl)  (Andres Freund <andres@anarazel.de>)
Responses Re: Unnecessary connection overhead due copy-on-write (mainly openssl)
List 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.




pgsql-hackers by date:

Previous
From: Ajin Cherian
Date:
Subject: Re: Proposal: Filter irrelevant change before reassemble transactions during logical decoding
Next
From: Dilip Kumar
Date:
Subject: Re: Fix slot synchronization with two_phase decoding enabled