Closed sanssecours closed 1 month ago
The same problem also occurs with the SocketCAN interface on Linux. The only difference seems to be that the SocketCAN backend drops CAN packets without raising an exception. That is also the reason why I thought everything was working fine.
Always check the measurement data for lost packages.
Measuring performance on one of the efficiency cores of the M1 MacBook with:
taskpolicy -b fish -c 'icon measure -t 10 -n Test-STH'
showed about 30% performance usage without any code in AsyncStreamBuffer.on_message_received
.
We are already working on ideas to improve the performance in the branch 🐌
, which should also be the basis for version 2.0
of the package (see also issue #51). Currently we simplified the data structure returned by the streaming API to keep the performance problems in check.
Other ideas:
on_message_received
methodNote: It might make sense to count the number of instructions for a certain number of messages
In theory the latest changes (currently in the branch 🌱; planned for release 2.0) should impove the performance slightly. Another big advantage of the new code is that it raises an exception, if the buffer for streaming data exceeds a certain fixed size (currently 10 000 elements).
With the addition of a performance test to the extended manual tests I will close this issue for now.
Description
It seems that the “new”
Network
class (based onpython-can
) might have some performance issues, if we use the PCAN interface (standard interface for PEAK CAN adapter on macOS and Windows) to stream data to the computer. After some amount of time the code throws aPcanCanOperationError
declaring that the “receive queue was read too late”.The same code works fine using the SocketCAN interface on Linux.Steps to Reproduce
Install ICOc in development mode
Check out commit 4b260bce for test script
new.py
Execute the following command in the repository
Expected Result
The script finishes without any problems.
Actual Result
After a certain amount of time the script prints the an error message that looks like this:
Additional Information
I tested the script three times on all of the (more or less) supported operating systems. One reason behind the failure (on macOS and Windows) might be the additional code (on top of python-can) in this repository. However replacing it with something like
pass
did not solve the problem (on macOS) when I tried. The CPU utilization stayed pretty much the same as far as I can tell.Regarding the CPU usage: Please take the values below with a grain of salt. I “measured” the CPU utilization using the graphical system monitor software provided by the different operating systems. This process is obviously not very accurate, especially since modern systems contain multiple CPU cores. In the case of the M1 machine below, these cores even have very different performance characteristics.
Linux
System
i7-4702@2.2GHz
(2013)Test Results
CPU Usage: ~ 80% CPU (of single core)
macOS
System
M1 Max@2.0/3.2GHz
(2021)CPU Usage: ~ 60% – 65% (of single core)
Windows
System
i5-5300@2.3GHz
(2015)Test Results
CPU Usage: ~ 60% – 80% (of single core)