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

Optimization #25

Merged
merged 6 commits into from
May 16, 2017
Merged

Optimization #25

merged 6 commits into from
May 16, 2017

Conversation

dcjones
Copy link
Member

@dcjones dcjones commented Apr 18, 2017

Revisiting my old hobby of optimizing IntervalTrees.

So far:

  • Avoid using isless, since depending on the interval type it can unnecessarily compare things other than first and last, e.g. sequence name.
  • Store leaf entries in a plain array, avoiding some overhead from Slice.
  • Faster nextintersection! function for iterative intersection.

My simple benchmark goes from:

  • successive intersection: 5.9s -> 5.3s 5.4s
  • iterative intersection: 8.4s -> 7.3s 5.8s

TODO:

  • Better cost analysis of successive versus iterative intersection. Often it chooses incorrectly and runs the empirically slower algorithm.
  • Implement a third algorithm: run successive B vs A instead of successive A vs B, which is O(|B| log |A|) instead of O(|A| log |B|).
  • Store leaf keys redundantly in contiguous memory. Uses more memory, but it looks like cache misses from having to follow leaf entry pointers slows things down a lot.
  • Investigate using StaticArrays to store keys.
  • Anything else that may occur to me along the way.

@codecov-io
Copy link

codecov-io commented Apr 18, 2017

Codecov Report

Merging #25 into master will decrease coverage by 1.58%.
The diff coverage is 92.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #25      +/-   ##
==========================================
- Coverage    93.2%   91.62%   -1.59%     
==========================================
  Files           3        3              
  Lines         692      776      +84     
==========================================
+ Hits          645      711      +66     
- Misses         47       65      +18
Impacted Files Coverage Δ
src/slice.jl 93.22% <75%> (-6.78%) ⬇️
src/IntervalTrees.jl 92.72% <94.19%> (-1.53%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1f1bb8b...5da2d2d. Read the comment docs.

@bicycle1885
Copy link
Member

bicycle1885 commented Apr 19, 2017

Cool! I'm interested in the performance impact of simple iteration over all intervals in a tree, because when I tried it before it was much slower than I expected.

@dcjones
Copy link
Member Author

dcjones commented Apr 19, 2017

Curiously iteration is about the same on julia 0.5, but significantly slower with this change on master. I'll look into that. 😦

dcjones added 2 commits May 14, 2017 15:51
This is 2-4x faster that the proper immutable state iterator.
@dcjones dcjones merged commit e1f1f2c into master May 16, 2017
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.

3 participants