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

fastunion vs |= in a loop #417

Open
maxdemarzi opened this issue Dec 8, 2022 · 1 comment
Open

fastunion vs |= in a loop #417

maxdemarzi opened this issue Dec 8, 2022 · 1 comment

Comments

@maxdemarzi
Copy link

I have a std::vector of Roaring64Maps

std::vector<roaring::Roaring64Map> results = // some process

When I use fastunion (probably incorrectly):

    auto sharded_results = new const roaring::Roaring64Map*[results.size()];
    for (size_t i = 0; i < results.size(); ++i) {
        sharded_results[i] = &results.data()[i];
    }

    roaring::Roaring64Map combined = roaring::Roaring64Map::fastunion(results.size(), sharded_results);

It takes almost 5 seconds to combine them. However when I just do:

    roaring::Roaring64Map combined;
      for(const auto& sharded : results) {
        combined |= sharded;
    } 

It takes 2.8 seconds. In this case I only have 4 maps, and the combined carnality ends up just above 3 million.
Am I doing something wrong or is this expected?

@lemire
Copy link
Member

lemire commented Dec 8, 2022

It is not the case that the approach you take (two-by-two ORs) is necessarily inferior. More importantly, we don't currently have solid benchmarks for fastunion. That is something that we should add.

https://github.com/RoaringBitmap/CRoaring/blob/a644f44898d3c0f27af4406827bbde5f42a06b53/cpp/roaring64map.hh#LL1381

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

No branches or pull requests

2 participants