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
Very high CPU load with serialport input #2928
Comments
We have some issues with low level modules like serialport since the way they post events is keep waking up our Node.js message loop, fixing this is impossible or extremely hard. A popular way to work around this is to fork a Node process to use |
Thanks for the feedback. A process fork seems like a plausible workaround. Could you be a bit more specific about what is going on with these events? I'd love to understand the problem with serialport a bit more in-depth. How are these events in Electron handled differently from a regular Node environment and what kind of modules are affected? How can you detect when these events walk up the message loop? |
Electron has its own message loop, so we get notified of Node's events by listening to Node's message loop's backend fd. However when some modules like If you are interested in this you can look at the |
Thanks for this info. Do you think this is something that can be solved by the libraries by not using these special events? Then I would report this to serialport so they can consider it for a future update. The fork works well. In a previous naive attempt I launched two node processes manually and had them talk over TCP. A fork is much more convenient and efficient. |
No, those special events are required for their implementations, it is not possible for those libraries to remove that. |
OK thanks a lot for your help! |
I am getting this error when I try child_process.fork with serialport, and I get really lost about it.
Im using Windows 7x64 and 0.36.7 |
@leyenda, were you able to get this to work? :D |
Hello @ruipimentel, unfortunately I give up on forking, and that was the specific action giving this error message to me. I end up sending the data to my other program over tcp. I am sorry for not being helpful. |
I understand! (so much that I'm actually reconsidering the whole stuff, too!) |
for those of you who needs help on using serialport, i built a little tool here for serialport run inside electron https://github.com/weiway/node-serialport-worker |
This should have been fixed with #5378. |
I have a problem with Electron in combination with serialport. I need to talk to a device which emits frames of 519 bytes at an interval of 27ms and a baudrate of 115200. So nothing spectacular really.
When I run the test code directly in Node it runs fine and uses less than 2% cpu. If I then run the exact same code in Electron my CPU goes through the roof at 130%.
I've tested the code on OSX with iojs v1, v2 and more recently node v4.1.1. The behavior is exactly the same. Also it doesn't make a difference if I run the code in the Electron main or renderer process.
I've shared my test code here. Of course without the device you can't use the serialport test code without altering it a little.
I'm hoping someone can give me pointers on how to investigate further, maybe by profiling the main process? I would love to use Electron for the project but with this bug it's not an option.
The text was updated successfully, but these errors were encountered: