Closed deanlee closed 1 month ago
Since the vector return from CanParser::update_strings() groups data by address, caching dictionary references for each address key reduces redundant lookups. This simple adjustment significantly cuts execution time by at least half, often more.
Perhaps we refactor the C++ CAN Parser to structure the signals together?
disable wraparound and boundcheck, update_string does not require these two options. disabling them can slightly improve performance
This did not seem to make much of a difference for me on PC nor device. master
: 750 mean ms, disabled checks: 760 mean ms
master
:
6000 CAN packets, 20 runs
751.04 mean ms, 762.70 max ms, 733.57 min ms, 12.36 std ms
0.1252 mean ms / CAN packet
This branch before my commits:
6000 CAN packets, 20 runs
296.84 mean ms, 299.24 max ms, 290.97 min ms, 1.70 std ms
0.0495 mean ms / CAN packet
This branch w/ clean ups:
6000 CAN packets, 20 runs
293.75 mean ms, 295.81 max ms, 289.66 min ms, 1.42 std ms
0.0490 mean ms / CAN packet
Issue: The following two code blocks consume nearly two-thirds of cython's update_string()'s runtime:
Resolve:
the results of running
selfdrive/debug/check_can_parser_performance.py
:Before:
After: