Currently, a call to DynamicSupervisor.terminate_child waits until the process has exited (or the shutdown times out) before processing any other messages. This can take up to `shutdown` milliseconds, which could be a long time depending on what the application has configured.
I have run into this problem before in my work, and solved it in my project by ensuring that a process is in a "ready to terminate" state before asking the DynamicSupervisor to terminate it. This works for us, but we have to be really careful with this and if we make a mistake it could have a huge performance impact.
After reading the code, I think it is possible to process these terminations asynchronously. This would allow other work (including process restarts, starting new processes, terminating other processes) to continue unimpeded.
The downside is that the DynamicSupervisor would get more complex. The upside is that we could solve a potentially big performance bottleneck in people's apps.
Is this a change that would be considered?