pty.js icon indicating copy to clipboard operation
pty.js copied to clipboard

100% CPU usage when pty stays on for long

Open pocha opened this issue 11 years ago • 3 comments

I have created a pseudo bash Terminal which uses pty.js in the backend.

I am seeing that sometimes the server shoots to 100% CPU for one core & it stays there till the Node server is restarted.

It is a multi user setup & when a user connects pty spaws with 'su -l ' as the users need to be jailed into this directory. This 'su' command in some cases is creating 100% CPU usage which I am able to zero in on this issue https://github.com/pocha/terminal-codelearn/issues/7#issuecomment-23223491

Server - Ubuntu 12.04 64 bit AMD

npm version

{ http_parser: '1.0', node: '0.10.17', v8: '3.14.5.9', ares: '1.9.0-DEV', uv: '0.10.14', zlib: '1.2.3', modules: '11', openssl: '1.0.1e', npm: '1.3.8', 'terminal-codelearn': '0.0.3' }

pocha avatar Aug 25 '13 07:08 pocha

Have you guys made any progress on this? Here's a v8 prof dump from a server that hits 100% cpu using pty.js: https://gist.github.com/vincentwoo/7797905

vincentwoo avatar Dec 05 '13 00:12 vincentwoo

My dump looked similar. So far no success in getting this resolved.

Ashish (Pocha) | Codelearn.org Learn Ruby on Rails by creating an app right in the browser Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Thursday, 5 December 2013 at 5:35 am, Vincent Woo wrote:

Have you guys made any progress on this? Here's a v8 prof dump from a server that hits 100% cpu using pty.js: https://gist.github.com/vincentwoo/7797905

— Reply to this email directly or view it on GitHub (https://github.com/chjj/pty.js/issues/39#issuecomment-29859386).

pocha avatar Dec 08 '13 09:12 pocha

For posterity: in researching this issue I discovered this commit from the "terminal" package for atom, which fixes this issue by running the pty.js process in its own child_process instead of the main process, I guess because of some bad interaction between the pty process and the main event loop.

I don't understand fully, but by copying the idea of this commit, I was able to avoid the high CPU usage problem and still communicate with the pty process.

https://github.com/atom-archive/terminal/commit/f945a35f84aeb3c8e1f52d79a3af24bf47634ea2

jeffgran avatar Oct 09 '15 05:10 jeffgran