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.