can_capnp_to_list: direct capnp to vector<CanData> conversion #34303
+18
−13
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reopening #33952, which was auto-closed by the bot due to inactivity.
This PR depends on commaai/opendbc#1452.
It simplifies the data conversion process between C++ and python by directly converting Capnp data to vector[CanData] within the C++ space. Previously, the data passed between C++ and Cython involved multiple conversions, including unnecessary back-and-forth transformations between vector[CanData] and Python nested lists. This PR eliminates those redundant steps, improving performance and reducing complexity in the interaction between C++ and python.
Below is the benchmark comparison on the 3X device:
Benchmark (PR):
Benchmark (Master):
With the PR from commaai/opendbc#1439, the benchmark time could drop from 0.0819 ms to around 0.02 ms per CAN packet. This brings a significant performance boost, almost matching the speed of pure C++ for parsing CAN strings by minimizing the overhead between C++ and Cython.