-
Notifications
You must be signed in to change notification settings - Fork 57
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
100% CPU utilization #7
Comments
I have the same issue. It is because of fast check changes in FileWatcher. You need to change node_modules/gpio/gpio.js line 62 And CPU will utilization be 5% |
+1 @EugenePikalov thanks for that, was dived into the C code for some time with no luck. |
You would think it's fine checking the contents of a file each ms, especially when the file contains only 1 byte. But yeah, I never intended for that to be a permanent solution. I rolled out the custom filewatcher because node fs's watcher looks for metadata changes on the file and doesn't work properly when we manually change the gpio header via hardware. I used interval = 1 because I wanted to get close to realtime. Doesn't make sense to drive a robot that responds too slowly. But then again, no one in their right mind would write an autonomous robot in JavaScript. For now, I think I'll add the ability to set the FileWatcher interval in the API and default it to 100ms. Thanks Eugene for pointing this out. I'll look at some low level tools to catch file changes without having to read the file itself; should significantly reduce cpu usage even at small intervals (a coworker of mine mentioned inotify). I'll keep this issue open until I can figure that out. If you guys have any ideas, I'd love to hear it! |
I smell kernel drivers here, linux has it's controversial ground on hardware triggers (a.k.a. interrupt). |
I'm gonna close this issue. With e306269 the default interval is now 100 and there's an option to set the interval when exporting a pin. |
For even the simplest programs using 'gpio', node uses 100% CPU on my Raspberry PI with Raspbian. For example:
started with
results in 100% CPU usage. Am I doing something wrong? How can I debug this?
The text was updated successfully, but these errors were encountered: