Hi all,
I'm currently writing a new addon via C++, which targets to find out
busy loops in Node.js.
Sometimes we may write a busy loop in javascript, such as:
while (a > 1) {
// do something
}
a +1; // oops, never get here
Most of the time, easy to find. But there're some situation it is
too tricky to find these points.
And since we're in the busy loop, any of the other javascript code
can't happen.
To find these busy loops, my basic idea is to use profile. V8
provides a way to start a profile, and if we have a chance to start
it, profile result will show where the busy loop is. But like I
said, have no way to trigger anything inside javascript land when
loop.
I had a little scratch
here to show
my mind. The basic idea is to catch a signal, like SIGINT, to fire
an alarm and begin a profile. When the alarm is alert, stop that
profile. Hotest code should be the code where busy loop is.
I'm not familiar with Linux programing neither with Node's kernel.
So I'm wondering is it a good idea to use alert in C++ addon to have
a profile?
--
Best Regards,
liuyanghejerry