I have noticed that when calling a simple code given below
strace node -e 'setTimeout(()=>{console.log("hola")},10000)'
on arm instance (graviton c7g.2xlarge and Ubuntu 20.04.3 LTS ) with node v18.12.1 it uses epoll_pwait to wait
user@laptop:~$ strace -e epoll_pwait,epoll_wait -c node -e 'setTimeout(()=>{console.log("hola")},10000)'
hola
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
0.00 0.000000 0 10 epoll_pwait
------ ----------- ----------- --------- --------- ----------------
100.00 0.000000 10 total
while on AMD c6a.2xlarge with Ubuntu 20.04.5 LTS with node v18.12.1 same command waits using epoll_wait
user@laptop:~$ strace -e epoll_pwait,epoll_wait -c node -e 'setTimeout(()=>{console.log("hola")},10000)'
hola
% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ----------------
100.00 0.000012 1 10 epoll_wait
------ ----------- ----------- --------- --------- ----------------
100.00 0.000012 10 total
my doubts are
- why is nodejs on arm using epoll_pwait vs epoll_wait on x86 architecture
- is there any performance hit between using epoll_pwait and epoll_wait
- can this behaviour be made uniform using some configuration or am i missing something in my analysis.
Linux doesn't have the
epoll_waitsyscall on ARM64. When theepoll_waitsyscall doesn't exist, Glibc implements theepoll_waitfunction in terms ofepoll_pwaitinstead. This is in accordance with this comment in the Linux kernel:On ARM64, this isn't a meaningful question, since there is no
epoll_waitthere to compare to. On x86_64,epoll_pwaitdoes slightly more work thanepoll_wait, as you can see in their definitions in the Linux kernel, but I doubt it's significant.If you really wanted, you could modify the source of nodejs to use
epoll_pwaiteverywhere and then compile it yourself, but I see no benefit to doing this.