-
Notifications
You must be signed in to change notification settings - Fork 114
pthread to libuv, fix 100% CPU usage, some memory leaks #21
Conversation
Hey @sarakusha, Sorry, I haven't had a chance to test this yet but have you tried it on Windows, Mac, and linux? |
I changed the |
Any chance of getting this merged? 100% cpu on linux systems would be nice to solve. |
@blahah I haven't tested it yet. Does this PR fix the issue? What are the details of your OS? |
I use this solution in production on ubuntu 14.10, 15.04, 15.10, 16.04 (x64) |
I had the same 100% CPU issue on BananaPi and RaspberryPi 3 while using Debian Jessie with node v4.4 or v6.3 and it was fixed by merging this PR. |
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Hey @sarakusha, So sorry about the lack of attention on this 😞. I just tested this out again and it does fix the 100% CPU issue 💯. One of my reservations on not merging was not having this same new One issue still present is things not wanting to exit gracefully (related to #35). And porting these changes over to macOS also introduced the same exiting issue to that platform (previously exited gracefully). This is reproducible if you run |
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Port #21 on top of the latest `master` > - Migration from `pthread` to `libuv`. > - Fix 100% CPU usage (using `poll()`): > source > > ``` c > /** > * udev_monitor_receive_device: > * @udev_monitor: udev monitor > ... > * The monitor socket is by default set to NONBLOCK. A variant of poll() on > * the file descriptor returned by udev_monitor_get_fd() should to be used to > * wake up when new devices arrive, or alternatively the file descriptor > * switched into blocking mode. > ... > **/ > ``` > - Out of the loop when receives SIGINT or SIGTERM signals for accurate completion of the program > - Fix some ome memory leaks > > ``` c > udev_monitor_unref(mon); > udev_unref(udev); > ``` > - For local functions and variables using the keyword `static` > > #21 (comment)
Heads-up, #46 was merged and published in 2.1.0 🚀 Thanks again @sarakusha ❤️ |
pthread
tolibuv
.poll()
):source
static
See #2