Open deanlee opened 2 months ago
How much does this improve performance? I don't see much of a difference on a comma 3X
This change won't significantly impact the performance of the master branch, as the master spends lots of time on Cython code. However, it will enhance the performance of the C++ code, particularly after https://github.com/commaai/opendbc/pull/1046. Currently, there are two performance bottlenecks in the C++ code that can be addressed: memory-aligned copying and the use of vectors. This adjustment is expected to boost the performance of the C++ code, with even greater improvements expected on devices.
When parsing CAN messages,
CanParser
creates a memory copy for each message solely to satisfy the checksum calculation function's requirement, which expects astd::vector<uint8_t>
as parameter. This approach is inefficient and slows down the parsing process.This PR updates all functions responsible for handling CAN data to accept raw data pointers
uint8_t* data
and size parameterssize_t size
instead of usingstd::vector<uint8_t>
. This adjustment aims to enhance performance and reduce memory overhead by avoiding unnecessary memory allocations and copies associated with vector usage.