-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
CANParser: expose MessageState
to Cython to eliminate data copying
#1382
Conversation
be80445
to
b4557e3
Compare
b4557e3
to
1fa97ff
Compare
eef22f6
to
3b3f351
Compare
Benchmarks on a 3X: PR:
master (after bus/addr filter PR):
|
3b3f351
to
1fa97ff
Compare
@sshane : FYI, this PR also resolves issue #1066, as it no longer relies on timestamps for updating the last values. Instead, it updates the updated_addresses set whenever a CAN signal is successfully parsed.
This approach ensures the updated values are tracked more reliably, independent of the timestamp. I believe we can close issue #1066 once this is merged. |
Nice clean up! |
@deanlee do you mind making the same change with PlotJuggler? It used |
@sshane : commaai/PlotJuggler#67 should work, However, since I'm still unable to build PlotJuggler, feel free to take over it if you'd like. |
This PR greatly simplifies the update logic, resulting in reduced code complexity and eliminating unnecessary data copying.
Main Changes:
SignalValue
Struct andCANParser::query_latest
Function: These components, previously used for copying updated values to Cython, have been removed. This change streamlines the data flow between C++ and Cython.MessageState
to Cython:MessageState
is now directly accessible from Cython, allowing values to be read straight from the C++ object. This eliminates the need for intermediate copying, optimizing performance and simplifying the overall code structure.Additionally, this PR includes changes from #1381, where value dictionaries are now initialized directly from DBC messages, though it does not include the
test_parser_empty_list()
function.Below are the performance benchmark results comparing this PR against the current master branch:
Benchmark (PR):
Benchmark (Master):
Most of the time is spent converting and copying messages from Python to C++. so while the current results don't show a massive improvement, after #1383 is merged, this PR could reduce the time per packet from 0.0318 ms to under 0.02 ms. I will run additional benchmarks to confirm once that change is integrated.