Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I still get 130% CPU usage after 20 hours of uptime #4

Closed
crazyyi opened this issue Oct 11, 2017 · 4 comments
Closed

I still get 130% CPU usage after 20 hours of uptime #4

crazyyi opened this issue Oct 11, 2017 · 4 comments

Comments

@crazyyi
Copy link

crazyyi commented Oct 11, 2017

For the first few hours I can play without any problem. But then the game become very slow. CPU usage is up to 130%. Any idea what is wrong with the code? I think using setImmediate(gameloop) is the culprit.

@crazyyi crazyyi changed the title I still get 100% CPU usage after 10 hours uptime I still get 130% CPU usage after 20 hours of playing Oct 11, 2017
@crazyyi crazyyi changed the title I still get 130% CPU usage after 20 hours of playing I still get 130% CPU usage after 20 hours of uptime Oct 11, 2017
@Jared-Sprague
Copy link

Jared-Sprague commented Nov 20, 2017

I was also getting over 100% CPU on my game server with no clients connected immediately after starting the server. I traced this down using the built in node profiler to figure out that node-gameloop was the culprit.

After downgrading to 0.1.0, the problem went away and CPU levels went back to normal. I definitely think this is a major bug in this node-gameloop and makes the current version unusable in production environments.

Below is my CPU prorofile, looks like it might be the use of node::Hrtime

 [C++]:
   ticks  total  nonlib   name
   4579    9.2%   11.2%  node::Hrtime(v8::FunctionCallbackInfo<v8::Value> const&)

...

   4579    9.2%  node::Hrtime(v8::FunctionCallbackInfo<v8::Value> const&)
   4579  100.0%    /usr/bin/node
   4579  100.0%      LazyCompile: *gameLoop /usr/share/games/zorbio/node_modules/node-gameloop/lib/gameloop.js:54:27
   4576   99.9%        LazyCompile: *runCallback timers.js:666:21
   4576  100.0%          LazyCompile: tryOnImmediate timers.js:641:24
   4576  100.0%            LazyCompile: *processImmediate timers.js:592:26


@Jared-Sprague
Copy link

After doing some more research I tracked down the CPU degredation to 0.1.3.

See before and after screen shots:

0.1.2

screenshot from 2017-11-20 11-30-05

0.1.3

screenshot from 2017-11-20 11-28-51

@Jared-Sprague
Copy link

tracked down the exact line that is causing the CPU issue the process.hrtime() call here:
f10cd69

This is confirmed by my CPU profiling above.

@crazyyi
Copy link
Author

crazyyi commented Nov 21, 2017

@Jared-Sprague Hi I am going to close this issue as this is my fault. I had some memory leak in my game logic code. Now it is fixed. The problem is not related to this module. Your problem looks a bit different than mine. Feel free to create a new issue if you like.

@crazyyi crazyyi closed this as completed Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants