@vbabka @vegard nope! here's another example with the same performance issue:
user@debian12:~/test$ cat slow2.c#include <pthread.h>
#include <unistd.h>
#include <err.h>
#include <sys/socket.h>
static void open_fds(void) {
for (int i=0; i<256; i++) {
int fd = dup(0);
if (fd == -1)
err(1, "dup");
}
}
static void *thread_fn(void *dummy) {
open_fds();
return NULL;
}
int main(void) {
pthread_t thread;
if (pthread_create(&thread, NULL, thread_fn, NULL))
errx(1, "pthread_create");
open_fds();
if (pthread_join(thread, NULL))
errx(1, "pthread_join");
return 0;
}
user@debian12:~/test$ gcc -O2 -o slow2 slow2.c -Wall
user@debian12:~/test$ time ./slow2
real 0m0.048s
user 0m0.001s
sys 0m0.000s
user@debian12:~/test$