vg giraffe chaining mode speedup#4910
Conversation
|
Nope the last thing I was playing with ended up being bad, so this is it. |
adamnovak
left a comment
There was a problem hiding this comment.
This looks pretty good, but I think the sort_value_t generation could be substantially simplified to avoid throwing around the big tuples.
| ZipCode::code_type_t code_type; | ||
| size_t offset_in_chain; | ||
| size_t length; | ||
| size_t chain_component; | ||
| bool is_reversed; | ||
| std::tie(code_type, offset_in_chain, length, chain_component, is_reversed) \ | ||
| = seed.zipcode.get_chain_child_sort_info(interval.depth+1); |
There was a problem hiding this comment.
Nope we're unpacking it ourselves and not just < comparing it.
When I see sorting and tuples together I assume we're building a sort key and we're going to compare those tuples with the tuple operator<, but that's not what's happening here.
This is probably a good candidate for a struct, which then gives a place to explain how/why we can't just make an operator<. But then we need to ask why that struct isn't already just the same as sort_value_t? Why can't get_chain_child_sort_info() take seed.pos and node_offset, which seem to be the only inputs to the code below here to set up sort_values_by_seed[zipcode_sort_order[i]] that don't come out of get_chain_child_sort_info(), and then return the completed sort_value_t, instead of a whole collection of things that we use only to build it?
There was a problem hiding this comment.
I set it up so now the ZipCodeForest takes responsibility for figuring out its sort values, and it actually just directly sets the various fields of the sort_value_t by reference instead of return.
Changelog Entry
To be copied to the draft changelog by merger:
vg giraffechaining/long-read modeDescription
A collection of small tweaks to optimize around ziptrees. Each tweak was individually tested to make sure it actually was a speed improvement. Output does not change.
add_child_to_chain(), instead of using the zipcode to look up the chain component for the new child, use the memory within the sorting information; much quicker to access.sort_one_interval()and we're sorting the children of a chain, instead of separately looking up each thing the zipcode stores, page through the entire zipcode at once (seeget_chain_child_sort_info())distance_iteratorchange: instead of usingpos.indexto look up the item at the current index, store an iterator for the backing vector and dereference that as needed.pos.indexoutside of the helpershift_index_by()/change_index_to()functions, it'll work.I'm futzing around with a final optimization, will push that if it turns out to help.