-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add reserve method to Cigar for use in get_cigar
#206
Conversation
While this performance difference can be observed in how your benchmarks are defined, i.e., creating a new buffer for each iteration; in practice, there shouldn't be a difference with the current BAM decoder. The CIGAR buffer in a
Can you share this report? When a |
Thanks for the reply. I should've added a little more color to my use case. I'll have a closer look tonight and follow up, but I think the lack of reuse is due to me working with a lazy BAM record, then calling noodles/noodles-bam/src/lazy/record/cigar.rs Lines 48 to 62 in 38836a4
Edit: If |
Ah, I see. Since this only affects the conversion use case, can we use the ops iterator instead of the decoder in the implementation of |
Cool, thanks for the feedback. Please let me know if the update is what you had in mind. |
Co-authored-by: Michael Macias <[email protected]>
Thanks! (And sorry for the slow responses; I just got back from vacation.) |
All good -- appreciate the education/patience |
Hi,
I'd like to propose a PR that I think could improve BAM cigar parsing performance. I noticed while profiling a tool of mine that calls to
get_cigar
may have do n allocations based on the number of cigar ops. Looking at theget_cigar
function, it already takes the number of ops, so this PR adds areserve
method onCigar
so thatget_cigar
can make use of it.I did a little benchmark via criterion that seems to indicate reduced runtime and reduced runtime variance.
I put the (slightly overcomplicated 😅) benchmark code in a separate branch here: https://github.com/tshauck/noodles/tree/add-reserve-to-cigar-decode-benches/target/criterion (with some changes to
noodles-bam
too).