]> arthur.barton.de Git - bup.git/commit
git.py: when seeking inside a midx, use statistical guessing.
authorAvery Pennarun <apenwarr@gmail.com>
Fri, 27 Aug 2010 02:31:24 +0000 (19:31 -0700)
committerAvery Pennarun <apenwarr@gmail.com>
Fri, 27 Aug 2010 03:03:08 +0000 (20:03 -0700)
commit2ae3f8d5f360daf55b0932b0cce7d3ccbe24c503
tree70b9e10e8bd9ef820bfeab25c29188dc1142b87b
parent9fbcff9aba8331769d80bf7fd7ba9fe3ecbd7863
git.py: when seeking inside a midx, use statistical guessing.

Instead of using a pure binary search (where we seek to the middle of the
area and do a greater/lesser comparison) we now use an "interpolation
search" (http://en.wikipedia.org/wiki/Interpolation_search), which means we
seek to where we statistically *expect* the desired value to be.

In my test data, this reduces the number of typical search steps in my test
midx from 8.7 steps/object to 4.8 steps/object.

This reduces memory churn when using a midx, since sometimes a given search
region spans two pages, and this technique allows us to more quickly
eliminate one of the two pages sometimes, allowing us to dirty one fewer
page.

Unfortunately the implementation requires some futzing, so this actually
makes memtest run about 35% *slower*.  Will try to fix that next.

The original link to this algorithm came from this article:
http://sna-projects.com/blog/2010/06/beating-binary-search/

Thanks, article!

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
lib/bup/git.py