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

perf: improve code generation performance #161

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

GabrielDertoni
Copy link
Contributor

Use BufWriter and avoid formatting generated code for faster build times.

BEFORE
rust_mavlink_master_comptime

AFTER
rust_mavlink_better_comptime

This PR still doesn't address the main issue which is the compilation time of the mavlink crate itself. But for a 14 line change I don't see a reason not to do this. It makes code generation 3x faster.

PS: The measurements were taken with cargo clean followed by cargo b --test encode_decode_tests --timings on a Ryzen 5 5600X processor.

@patrickelectric
Copy link
Member

@GabrielDertoni pls run cargo fmt.

Use `BufWriter` and avoid formatting generated code for faster build
times
@danieleades
Copy link
Contributor

@GabrielDertoni nice one!

how much of the speedup is from buffering the writing and how much from skipping the formatting?

@GabrielDertoni
Copy link
Contributor Author

@GabrielDertoni nice one!

how much of the speedup is from buffering the writing and how much from skipping the formatting?

@danieleades I first implemented these improvements along with a lot of other stuff I wanted to change. This is just a cherry pick. So I haven't measured in this last commit, but when I was first implementing it I did. When I measured, master took ~8s to run the build script. Then buffering took it down to ~4s and not formatting took it to ~2s.

@patrickelectric patrickelectric merged commit 240551b into mavlink:master Mar 21, 2023
@GabrielDertoni GabrielDertoni deleted the faster-compilation branch March 21, 2023 14:09
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.

None yet

3 participants