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

Alignment with macros and using const-values for faster processing #4

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

Conversation

frehberg
Copy link
Contributor

Not sure this is a useful patch, I tried to increase performance using macros, and using "const" values so that the compiler can do more static optimization regarding the alignment, but bench-tests showed no improvement. Please let me know if this patch is doing any good in your environment?

@frehberg
Copy link
Contributor Author

Btw: I realized the Serializer/Deser. is using Result-Error-type around heavy struct Error-type,in contrast to a lightweight enum would do. This might cause lot of overhead for each return-statement. Did you check if CDR lib could use a more lightweight Result-Error-Type based on light-weight enum?

@hrektts
Copy link
Owner

hrektts commented Jan 14, 2019

In my environment, which is Ubuntu 18.04, modified one is partially slower than the original. Here are my results.

Original:

test lidar_point_msg                       ... bench:     918,800 ns/iter (+/- 30,570)
test lidar_point_msg_without_encapsulation ... bench:     914,525 ns/iter (+/- 30,187)
test string_msg                            ... bench:         234 ns/iter (+/- 6)
test string_msg_without_encapsulation      ... bench:         201 ns/iter (+/- 33)

Modified:

test lidar_point_msg                       ... bench:     933,000 ns/iter (+/- 26,260)
test lidar_point_msg_without_encapsulation ... bench:     935,650 ns/iter (+/- 48,097)
test string_msg                            ... bench:         227 ns/iter (+/- 5)
test string_msg_without_encapsulation      ... bench:         192 ns/iter (+/- 5)

I don't know whether the code below is evaluated as const or not:

const ALIGNMENT: usize = std::mem::size_of::<$T>();

@hrektts
Copy link
Owner

hrektts commented Jan 14, 2019

As for the error handling, I'll take benchmarks and modify it. Thank you for letting me know :)

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.

2 participants