hardbyte / hardbyte/python-can
Poor PCAN Peak performance
- 主要語言
- Python
- 星號
- 1.6k
- 分支
- 697
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### Describe the bug
To put it simply, I have a 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:
[programperf.zip](https://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
貢獻指南
研究方向
首先,使用提供的腳本重現 Windows 10 上的效能差異,並比較 programperf.zip 中的兩個設定檔。判斷 _winapi.WaitForSingleObject 較慢的行為是出在 python-can 還是 PCAN 驅動程式中,然後記錄一個範圍明確的修正或替代方案,並驗證匯流排使用率有所提升。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- embedded-iot, networking
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 需要釐清
- 新手友好度
- 42/100