Poor PCAN Peak performance
Posted: Wed 25. Oct 2023, 15:42
Hi to all,
I have encountered a performance bottleneck using a PCAN Peak device, and opened a new issue on the python-can's github page:
h**ps://github.com/hardbyte/python-can/issues/1685
Since in my opinion it seems that the problem is outside of Python, I'll post it here as well. I don't want to spam, it's just to get some more insight on what might be going on. Here is the copy-paste (sort of) of the github issue:
Describe the bug
To put it simply, I have a python script that implements a simple protocol to flash a device via canbus. I'm using the python-can library, and have access to a PCAN peak and a VN1630 from Vector. Very easy to use, just change the interface and channel (at a speed of 500k, can non-fd, every other setting is the default) and the script works flawlessly with both hardware devices.
The problem I'm having is actually with performance: with no modifications to the script (except obviously to the channel and interface), with the PCAN Peak the bus usage sits at around 30%, and with the VN1630 at around 74%. Obviously the latter finishes much quicker. I tried profiling using cProfile and Snakeviz to visualize the results, and here they are:
Using the PCAN Peak:

Using the Vector VN1630:

As you can see, the vast majority of the time in both cases is spent inside the `_winapi.WaitForSingleObject` call; and in fact, being called approx. 82k times in both cases, with the Peak the "percall" time is much higher than with the VN1630.
Am I missing something? Is this due to some driver implementation detail? Can this be fixed/improved/circumvented without touching the device's drivers?
To Reproduce
I'll link both `.prof` files in case anyone else want to take a look at it:
h**ps://github.com/hardbyte/python-can/files/13166237/programperf.zip
Expected behavior
The performance of both devices should match, or at least not be so great.
Additional context
OS and version: Windows 10
Python version: 3.11.3
python-can version: 4.2.2
Edit by Admin ** read Forum Rules - external links are NOT allowed **
I have encountered a performance bottleneck using a PCAN Peak device, and opened a new issue on the python-can's github page:
h**ps://github.com/hardbyte/python-can/issues/1685
Since in my opinion it seems that the problem is outside of Python, I'll post it here as well. I don't want to spam, it's just to get some more insight on what might be going on. Here is the copy-paste (sort of) of the github issue:
Describe the bug
To put it simply, I have a python script that implements a simple protocol to flash a device via canbus. I'm using the python-can library, and have access to a PCAN peak and a VN1630 from Vector. Very easy to use, just change the interface and channel (at a speed of 500k, can non-fd, every other setting is the default) and the script works flawlessly with both hardware devices.
The problem I'm having is actually with performance: with no modifications to the script (except obviously to the channel and interface), with the PCAN Peak the bus usage sits at around 30%, and with the VN1630 at around 74%. Obviously the latter finishes much quicker. I tried profiling using cProfile and Snakeviz to visualize the results, and here they are:
Using the PCAN Peak:
Using the Vector VN1630:
As you can see, the vast majority of the time in both cases is spent inside the `_winapi.WaitForSingleObject` call; and in fact, being called approx. 82k times in both cases, with the Peak the "percall" time is much higher than with the VN1630.
Am I missing something? Is this due to some driver implementation detail? Can this be fixed/improved/circumvented without touching the device's drivers?
To Reproduce
I'll link both `.prof` files in case anyone else want to take a look at it:
h**ps://github.com/hardbyte/python-can/files/13166237/programperf.zip
Expected behavior
The performance of both devices should match, or at least not be so great.
Additional context
OS and version: Windows 10
Python version: 3.11.3
python-can version: 4.2.2
Edit by Admin ** read Forum Rules - external links are NOT allowed **