Instead of waiting for 1s before considering it dead, when most of the time the process dies quickly, delaying desktop or wineserver shutdown.
This saves ~2s on the prefix shutdown time, as measured with:
time bash -c 'wine cmd /c exit |& tee /dev/null'
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v2: Rebase on upstream HEAD.
server/process.c | 19 +++++++++++++++---- server/process.h | 1 + 2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/server/process.c b/server/process.c index 48b5d6d6dd4..343ad78270c 100644 --- a/server/process.c +++ b/server/process.c @@ -595,10 +595,20 @@ static void process_died( struct process *process ) static void process_sigkill( void *private ) { struct process *process = private; + int signal = 0;
- process->sigkill_timeout = NULL; - kill( process->unix_pid, SIGKILL ); - process_died( process ); + process->sigkill_delay *= 2; + if (process->sigkill_delay >= TICKS_PER_SEC / 2) + signal = SIGKILL; + + if (!kill( process->unix_pid, signal ) && !signal) + process->sigkill_timeout = add_timeout_user( -process->sigkill_delay, process_sigkill, process ); + else + { + process->sigkill_delay = TICKS_PER_SEC / 64; + process->sigkill_timeout = NULL; + process_died( process ); + } }
/* start the sigkill timer for a process upon exit */ @@ -606,7 +616,7 @@ static void start_sigkill_timer( struct process *process ) { grab_object( process ); if (process->unix_pid != -1) - process->sigkill_timeout = add_timeout_user( -TICKS_PER_SEC, process_sigkill, process ); + process->sigkill_timeout = add_timeout_user( -process->sigkill_delay, process_sigkill, process ); else process_died( process ); } @@ -630,6 +640,7 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla process->handles = NULL; process->msg_fd = NULL; process->sigkill_timeout = NULL; + process->sigkill_delay = TICKS_PER_SEC / 64; process->unix_pid = -1; process->exit_code = STILL_ACTIVE; process->running_threads = 0; diff --git a/server/process.h b/server/process.h index 55e4d6dced6..22ee8178368 100644 --- a/server/process.h +++ b/server/process.h @@ -53,6 +53,7 @@ struct process process_id_t group_id; /* group id of the process */ unsigned int session_id; /* session id */ struct timeout_user *sigkill_timeout; /* timeout for final SIGKILL */ + timeout_t sigkill_delay; /* delay before final SIGKILL */ unsigned short machine; /* client machine type */ int unix_pid; /* Unix pid for final SIGKILL */ int exit_code; /* process exit code */
Instead of waiting for wineserver to kills them on shutdown, after a 2s delay.
This saves another ~2s on the prefix shutdown time, as measured with:
time bash -c 'wine cmd /c exit |& tee /dev/null'
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- programs/services/services.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/programs/services/services.c b/programs/services/services.c index 39cd9ee4ffa..d969cf81ab9 100644 --- a/programs/services/services.c +++ b/programs/services/services.c @@ -520,6 +520,7 @@ static void scmdatabase_wait_terminate(struct scmdatabase *db) { struct process_entry *process = grab_process(LIST_ENTRY(ptr, struct process_entry, entry));
+ process_terminate(process); scmdatabase_unlock(db); WaitForSingleObject(process->process, INFINITE); scmdatabase_lock(db);
Rémi Bernon rbernon@codeweavers.com writes:
Instead of waiting for 1s before considering it dead, when most of the time the process dies quickly, delaying desktop or wineserver shutdown.
This saves ~2s on the prefix shutdown time, as measured with:
time bash -c 'wine cmd /c exit |& tee /dev/null'
Note that the fact that server shutdown is not immediate is on purpose, it's mean to avoid repeated startups/shutdowns when running multiple apps in sequence. There may be margin for improvement, but making the shutdown faster shouldn't be a goal in itself.
On 11/10/21 20:23, Alexandre Julliard wrote:
Rémi Bernon rbernon@codeweavers.com writes:
Instead of waiting for 1s before considering it dead, when most of the time the process dies quickly, delaying desktop or wineserver shutdown.
This saves ~2s on the prefix shutdown time, as measured with:
time bash -c 'wine cmd /c exit |& tee /dev/null'
Note that the fact that server shutdown is not immediate is on purpose, it's mean to avoid repeated startups/shutdowns when running multiple apps in sequence. There may be margin for improvement, but making the shutdown faster shouldn't be a goal in itself.
Sure and I understand that, yet I think the delay is not completely controlled and instead spread out over a few things that participate to it.
I think wineserver master socket timeout (and its kill timeout), and the desktop close timeout, should be the parameters we use to decide when to shutdown, and once it's decided it should be quick.
Currently it both depends on them but also on some additional implicit delays which are removed by these two patches.