Passing gen_server's `start_opts` to supervisors

So I was investigating how to reduce the memory consumption of an ssl connection, and my findings go more or less this way: ssl starts a tls_dyn_connection_sup supervisor, which starts a receiver and a sender process for the ssl flow. Now, ssl:handshake/3 accepts a hibernate_after option, which is passed to the underlying gen behaviour, but tls_dyn_connection_sup does not get such flag, even though it is too a gen_server under the hood, and just as often it might not be needed entirely.

I was tracing this process and manually running a garbage collection under the hood and memory would usually go from 6KB to 3KB, so when I have like 1M ssl connections, that diff can give me a 3GB memory saving.

But tls_dyn_connection_sup doesn’t get such hibernation flag because the supervisor API doesn’t provide a way to give it to begin with. So maybe it could be useful to give to supervisors a new start_link/4 function just like gen_servers do? And so then the ssl app can pass it to the dynamic supervisor too :slight_smile:

1 Like

Popping this up and, gently pinging @ingela, maybe you have a thought about this for the SSL part? Don’t know whom from the OTP team might be the right person to ask about supervisors though, but this might be a good addition for the next release I guess :see_no_evil:

I just tried out a PR here Supervisor/gen spawn options by NelsonVides · Pull Request #9256 · erlang/otp · GitHub