Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is libuv under the hood use epoll or select(2) in unix

I have been reading around how nodejs uses libuv to perform asynchronous I/O. Reading more about it give me a feeling that it almost sound similar to how select(2) and epoll.

So, my question if I'm using libuv(via node) is it true internally I using select(2) or epoll.

Is libuv is wrapper over select(2) and epoll system call in unix.?

like image 307
Noobie Avatar asked Mar 12 '23 20:03

Noobie


1 Answers

libuv uses the most performant polling mechanism for every platform: that means epoll on Linux, kqueue on macOS and BSDs, /dev/poll on SunOS, etc. One interesting trick libuv does is it uses select() on a thread for some fds kqueue is unable to handle. I gave some details about that here: http://code.saghul.net/index.php/2016/05/24/libuv-internals-the-osx-select2-trick/

like image 108
saghul Avatar answered Mar 14 '23 09:03

saghul