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: mark dna::complement as inline #510
Conversation
This speeds up computing the complement on a long string by ~2.3x.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, this makes sense. Can you also do the same for the complement
function in src/alphabet/rna.rs
?
I didn't manage to compile your benchmarks
Benchmarks require using nightly
- did you try that? It'd be nice to add an alphabets.rs
file to the benchmarks
directory for testing some of these string functions like complement
and revcomp
.
Sure, will do.
Didn't know that. Will give it a go. |
Thanks but it looks like you added |
This reverts commit d1928cb.
For real, this time.
Thanks for the thorough review. I blame my lingering cold. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Thanks for merging! |
This speeds up computing the complement on a long string by ~2.3x. Not sure why rust doesn't inline such a trivial function on its own.
I didn't manage to compile your benchmarks, hence I can only point to the results from my own project.
There is still a small overhead of Rust over C. I think Rust repeatedly checks that
a as usize
is a valid index inCOMPLEMENT
. While that is usually not a problem, it is here, because the loop is so small and the extra instructions clog the pipeline.