node-serialport icon indicating copy to clipboard operation
node-serialport copied to clipboard

SerialPort on Node v20 incurs high CPU load.

Open mousseq opened this issue 2 years ago • 6 comments

SerialPort Version

8.0.2

Node Version

20.4.0

Electron Version

No response

Platform

Linux pi4-1 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

Architecture

Raspberry Pi 4 (ARM)

Hardware or chipset of serialport

FTDI

What steps will reproduce the bug?

The enclosed program opens three serial ports and reads from them (and does nothing with the data). The ports receive data at relatively modest rates (1000 bytes 30 times a second).

What happens?

When built and run with Node v19.8.1, the CPU load is negligible. When built and run with Node v20, the CPU load increases dramatically. One of the four cores runs at 100%. The machine is a Raspberry Pi 4 running the Debian Bullseye version of the OS.

What should have happened?

I expect that the CPU load will not very significantly between the Node 19.8.1 and Node 20.4 versions. sptest.tar.gz

Additional information

No response

mousseq avatar Jul 21 '23 01:07 mousseq

Would you be able to check if you experience the same issue with node 20.2?

GazHank avatar Jul 21 '23 07:07 GazHank

Gareth:

Good call! When build and run with Node 20.2 (a test I was going to run later ...), the load is back to manageable levels. None of the cores are heavily loaded.

Thanks: Adam


From: Gareth Hancock @.> Sent: Friday, July 21, 2023 3:54 AM To: serialport/node-serialport @.> Cc: Adam Greenberg @.>; Author @.> Subject: Re: [serialport/node-serialport] SerialPort on Node v20 incurs high CPU load. (Issue #2659)

Would you be able to check if you experience the same issue with node 20.2?

— Reply to this email directly, view it on GitHubhttps://github.com/serialport/node-serialport/issues/2659#issuecomment-1645163602, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AX65Z5ZKM5C5UXIPJOSHLL3XRIYSBANCNFSM6AAAAAA2SF7VXM. You are receiving this because you authored the thread.Message ID: @.***>

mousseq avatar Jul 21 '23 09:07 mousseq

thanks @mousseq

In that case I strongly suspect this is related to the node js upgrade of libuv which occurred in node 20.3. Issue https://github.com/serialport/node-serialport/issues/2656 is another symptom of this.

I'm trying to investigate the root cause and get sufficient info about the problem so that we can get a fix applied to libuv, but it's proving a bit messy/time consuming so far.

GazHank avatar Jul 21 '23 09:07 GazHank

node 20.8.1 and 21.0.0 are still affected.

Thanks for the hint regarding node 20.2. That version works still very well.

uncaught avatar Oct 22 '23 07:10 uncaught

News on this?

robertsLando avatar Jan 17 '24 14:01 robertsLando