Skip to content

Conversation

@KRRT7
Copy link

@KRRT7 KRRT7 commented Jan 8, 2026

Replace bit-by-bit CRC-8 calculation with precomputed lookup table for improved performance.

@KRRT7 KRRT7 changed the title body: optimize CRC-8 checksum with lookup table optimize CRC-8 checksum with lookup table Jan 8, 2026
@github-actions github-actions bot added car related to opendbc/car/ body labels Jan 8, 2026
Copy link
Collaborator

@jyoung8607 jyoung8607 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to optimize this routine, but there's no need to store the LUT. It makes more sense to generate them at startup, as we do for the other CRC algorithms.

I would merge a version of this that adds CRC8BODY to crc.py with poly 0xD5. See the CRC8J1850 example in the Chrysler car port.

@sshane
Copy link
Contributor

sshane commented Jan 12, 2026

can also use a @cache instead of globals to cache the generation if you go this route

elkoled and others added 3 commits January 19, 2026 21:19
Generate CRC-8 table with polynomial 0xD5 at import time,
following the existing pattern for other CRC tables.
Replace hardcoded 256-entry lookup table with import from
shared crc module, following reviewer feedback.
@KRRT7
Copy link
Author

KRRT7 commented Jan 20, 2026

went with the CRC8J1850 example

@KRRT7
Copy link
Author

KRRT7 commented Jan 20, 2026

@sshane @jyoung8607 are you guys interested in performance optimizations for opendbc?

@adeebshihadeh
Copy link
Contributor

@sshane @jyoung8607 are you guys interested in performance optimizations for opendbc?

Yes, but they need to be visible changes that someone will notice, not micro-optimizations. Making tests faster is a good place to start, e.g. #3024.

@KRRT7
Copy link
Author

KRRT7 commented Jan 21, 2026

sounds good, I'll see what I can come up with.

@github-actions
Copy link
Contributor

No car changes detected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

body car related to opendbc/car/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants