Here’s a little benchmark complements of Jann Horn. It’s unexpectedly slow on Linux.
OpenBSD is so fast, I had to modify the program slightly to measure itself, as the time utility is missing sufficient precision to even record nonzero.
All it does is create one extra thread, then both existing threads create 256 sockets. What’s so hard about that?
#include
" , one . tv_sec , one . tv_usec ) ; return 0 ; }
On Linux, I get results approximately as so:
tedu@penguin:~$ ./a.out elapsed: 0.017770s tedu@penguin:~$ ./a.out elapsed: 0.026309s tedu@penguin:~$ ./a.out elapsed: 0.018414s
On OpenBSD, here we go, choo choo:
ox$ ./a.out a.out: a.out: socketsocket: : Too many open files Too many open files ox$ ulimit -n 1024 ox$ ./a.out elapsed: 0.006096s ox$ ./a.out elapsed: 0.002508s ox$ ./a.out elapsed: 0.002326s
These aren’t identical machines, but roughly comparable.
... continue reading