lkml.org 
[lkml]   [2021]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v5] do_wait: make PIDTYPE_PID case O(1) instead of O(n)
From
Date
On 3/12/21 12:22, Andrew Morton wrote:
>
> Could we please see some performance testing results to permit us to
> evaluate the value of this change?

Sure. I've been doing some ad-hoc measurements with the code below. It
forks 8k children and then waits for them in reverse order (forcing a
full list traversal each time). I'll need to reboot a couple times to
get apples-to-apples measurements on bare metal, though. I'll plan to
run with NUMCHILDREN = 0 -> 8000, by 100.

Does this look like it'd be sufficient, or is there more you'd like to
see? The current form doesn't use ptrace, but I expect the results to be
similar; (maybe more pronounced when tracing threaded children, since
every thread is in the tracee list instead of just the group leaders).

#define NUMCHILDREN 8000

void fork_and_wait() {
pid_t children[NUMCHILDREN];
for (int i = 0; i < NUMCHILDREN; ++i) {
pid_t forkrv = fork();
if (forkrv < 0) {
perror("fork");
exit(1);
}
if (forkrv == 0) {
// child
exit(0);
}
// parent
children[i] = forkrv;
}
for (int i = 0; i < NUMCHILDREN; ++i) {
int wstatus;
if (waitpid(children[NUMCHILDREN - i - 1], &wstatus, 0) < 0) {
perror("waitpid");
exit(1);
}
}
}

\
 
 \ /
  Last update: 2021-03-12 19:40    [W:0.078 / U:2.656 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site