Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is epoll_pwait in node.js application and what can I do about it?

My application is a web version of the board game Settlers of Catan.

I'm using node --prof app.js to profile the app and node --prof-process ISOLATE_LOG_FILE > processed.txt to turn them into a processed file.

I do get a lot of Code move event for unknown code events: https://prnt.sc/q69ugk

At the end I'm left with a file, like so:

Statistical profiling result from isolate-0x3df60c0-v8.log, (13113 ticks, 192 unaccounted, 0 excluded).

enter image description here

  1. What is this epoll_pwait in the context of node.js?
  2. Why is it using 60% of my application?
  3. What can I do about this?
like image 465
Esqarrouth Avatar asked Dec 04 '19 20:12

Esqarrouth


People also ask

Does node use Epoll?

The epoll module is used by onoff to detect such interrupts. epoll supports Node.

How does node js handle concurrent tasks?

To address these issues, Node. JS uses a single thread with an event-loop. In this way, Node can handle 1000s of concurrent connections without any of the traditional detriments associated with threads. There is essentially no memory overhead per-connection, and there is no context switching.

What is offloading in node js?

In Node, I/O operations are offloaded to the C++ APIs (libUV) which allows the Node. js main thread to continue executing your code without having to wait for file or network operations to finish. In this tutorial we will: Learn how to write synchronous and asynchronous file callbacks in Node.

What should I not use node js for?

js receives a CPU bound task: Whenever a heavy request comes to the event loop, Node. js would set all the CPU available to process it first, and then answer other requests queued. That results in slow processing and overall delay in the event loop, which is why Node. js is not recommended for heavy computation.


1 Answers

epoll_pwait essentially means your application (event loop) is waiting for something, i.e I/O operation.

Quoting the link above:

A call to epoll_pwait() will block until either:

   • a file descriptor delivers an event;

   • the call is interrupted by a signal handler; or

   • the timeout expires.

for further debugging, what really comes to my mind is, if you have any setInterval code with little or zero timeout, if so, please post this callback function you're passing to the interval.

like image 104
Mu-Majid Avatar answered Sep 22 '22 01:09

Mu-Majid