Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can_capnp_to_list: direct capnp to vector<CanData> conversion #34303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deanlee
Copy link
Contributor

@deanlee deanlee commented Dec 22, 2024

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):

6000 CAN packets, 10 runs
353.46 mean ms, 359.61 max ms, 351.58 min ms, 2.14 std ms
0.0582 mean ms / CAN packet

Benchmark (Master):

6000 CAN packets, 10 runs
491.51 mean ms, 492.63 max ms, 490.43 min ms, 0.71 std ms
0.0819 mean ms / CAN packet

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant