Giter Site home page Giter Site logo

Comments (5)

patmorin avatar patmorin commented on June 2, 2024

from arraylayout.

jonhoo avatar jonhoo commented on June 2, 2024

First implementation here: https://github.com/jonhoo/ordsearch

from arraylayout.

jonhoo avatar jonhoo commented on June 2, 2024

Some observations: it seems like the implemented algorithm is only faster when n is small and when the data type is relatively large. A straightforward binary search is faster once you go to L3, and sooner if you're operating on smaller data types (e.g., u8). I tried implementing deep prefetching, and if anything it seems to have made things slower (C=0 gives no improvement, C=1 gives a 10% slowdown, and C=2 gives a 20% slowdown).

The implementation of search (called find_gte) is here: https://github.com/jonhoo/ordsearch/blob/master/src/lib.rs#L282-L325

It'd be awesome if you could take a look if you have some spare time and see if I'm doing something clearly silly? If I'm interpreting the relationship between the trends I see and the results in the paper correctly, it seems like the prefetching isn't working properly?

from arraylayout.

jonhoo avatar jonhoo commented on June 2, 2024

@patmorin after doing some more experiments, my code is actually faster if I comment out the pre-fetching, which suggests that it's prefetching the wrong value. However, as far as I can tell, it does exactly the same prefetching as the C++ code. The one thing I can't quite wrap my head around is how offset is computed to be multiplier + multiplier / 2. For the 16 great-great-grandchildren, shouldn't the leftmost child (and thus the start of the prefetch) be at 16i + 8 + 4 + 2 + 1? Which would make offset = multiplier - 1?

from arraylayout.

jonhoo avatar jonhoo commented on June 2, 2024

Sorry for the spam, but I walked through the calculation carefully, and I think I get it now. Left a somewhat long-winded comment here: https://github.com/jonhoo/ordsearch/blob/b17cb0b3f5089112145af25dfad6bbc8376c408a/src/lib.rs#L292

However, given that this all seems correct, I do not understand why the prefetching does not speed anything up? The search is still faster without any prefetching.

from arraylayout.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.