mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
performance improvement: setup signal notify in a new go routine
There is a big loop(at least 65 times) in `signal.Notify`, it costs as much time as `runc init`, so we can call it in parallel ro reduce the container start time. In a general test, it can be reduced about 38.70%. Signed-off-by: lifubang <lifubang@acmcoder.com> (cyphar: move signal channel definition inside goroutine) Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
+2
-1
@@ -246,7 +246,7 @@ func (r *runner) run(config *specs.Process) (int, error) {
|
||||
// Setting up IO is a two stage process. We need to modify process to deal
|
||||
// with detaching containers, and then we get a tty after the container has
|
||||
// started.
|
||||
handler := newSignalHandler(r.enableSubreaper, r.notifySocket)
|
||||
handlerCh := newSignalHandler(r.enableSubreaper, r.notifySocket)
|
||||
tty, err := setupIO(process, r.container, config.Terminal, detach, r.consoleSocket)
|
||||
if err != nil {
|
||||
return -1, err
|
||||
@@ -285,6 +285,7 @@ func (r *runner) run(config *specs.Process) (int, error) {
|
||||
return -1, err
|
||||
}
|
||||
}
|
||||
handler := <-handlerCh
|
||||
status, err := handler.forward(process, tty, detach)
|
||||
if err != nil {
|
||||
r.terminate(process)
|
||||
|
||||
Reference in New Issue
Block a user