Skip to content

[NEW] How about support Roaring Bitmaps in valkeyΒ #1480

Open

Description

@im-bravo

The problem/use-case that the feature addresses
I want store large number of user id whitelist (10,000,000 ~ 50,000,000 ) with using bitmap and the max value of the user ID will be 2,147,483,647.
If there is only 1 user in the bitmap and the value is 2,147,483,647, it will spend around 320MB memory.
If we can use some compression technology to reduce memory usage without affecting performance or even improve some performance, I think that would definitely be a great thing.
Maybe roaring bitmap is good choose to do some improvement.

Description of the feature
Support Roaring Bitmaps with new Commands

Alternatives you've considered
Support Roaring Bitmaps with existing bitmap commands if bitmap_engine="roaring" in config file.
bitmap_engine="string" as the default config to keep existing behavior.

Additional information

About Roaring Bitmap
https://roaringbitmap.org/
https://github.com/RoaringBitmap/CRoaring
Some implementations from others
https://github.com/aviggiano/redis-roaring

Activity

  1. added
    client-changes-needed
    on Jan 12, 2025
  2. im-bravo commented on Mar 10, 2025

    @im-bravo
    Author

    For java client, user may can integrate with Jedis to define some custom commands ?
    https://github.com/redis/jedis?tab=readme-ov-file#using-redis-modules

  3. arthurkiller commented on Mar 10, 2025

    @arthurkiller
    Member

    croaring is under Apache license and redis-roaring is MIT, you can use them with valkey freely

  4. arthurkiller commented on Mar 10, 2025

    @arthurkiller
    Member

    and if you look a little deeply into roaring implementation, you will find roaring can adaptively choose bitmap_engine based on your data scale

  5. fjmaco commented on Aug 25, 2026

    @fjmaco
  6. yzqzss commented on Aug 25, 2026

    @yzqzss

    https://github.com/aviggiano/redis-roaring is essentially a Redis distribution that includes the redis-roaring module. You can actually build the module separately and use it with Valkey. I have done this myself without encountering any issues: https://github.com/yzqzss/redis-roaring-builder

  7. fjmaco commented on Aug 25, 2026

    @fjmaco

    @yzqzss Yep, I know redis-roaring well β€” I've used it, and you're right that the module builds and loads into Valkey without issues (nice builder repo!). valkey-roaring exists for a different reason: it's a ground-up Rust rewrite on roaring-rs and Valkey's official Rust SDK, command-compatible with redis-roaring, plus one addition redis-roaring doesn't have. R.EXPORT/R.IMPORT for raw binary serialization in the CRoaring portable format. My main use case is microservice communication: a service asks for a large membership set and instead of an integer-array reply, it gets the compressed bitmap itself β€” typically an order of magnitude smaller on the wire β€” and deserializes it natively with any Roaring library (Java/Go/Python/C++/Rust). Low bandwidth, low memory on the receiving side, no parsing step.

  8. added a commit that references this issue on Oct 16, 2026
  9. lemire commented on Oct 16, 2026

    @lemire
    Contributor

    If one of the maintainers wants to support this feature, we can create a pull request to resolve this issue very quickly.

    Here is a fully functional PR:

    unstable...lemire:valkey:roaring-bitmaps

    I donate this code btw, feel free to just take it without credit.

    It is tested. It is fast.

    Though it is a clean room implementation, it is essentially 'compatible' (to a point) with the recently merged roaring implementation inside Redis. (It follows the same user-space conventions.)

  10. lemire commented on Oct 16, 2026

    @lemire
    Contributor

    (I meant that I do not seek credit.)

  11. added
    major-decision-pending
    on Oct 27, 2026
  12. madolson commented on Oct 27, 2026

    @madolson
    Member

    I've heard more recent ask for this. I'll throw this on the next weekly meeting to see if we can get some quick consensus.

  13. yzqzss commented on Oct 27, 2026

    @yzqzss

    R.EXPORT/R.IMPORT for raw binary serialization in the CRoaring portable format.

    @fjmaco This is indeed a good feature.

  14. lbuesching commented on Oct 30, 2026

    @lbuesching

    Redis has recently incorporated this into 8.12 (redis/redis#15296)

    For use cases such as sparse ID membership, existing bitmap representations are memory-inefficient and infeasible at scale. While it's possible to build customized modules as outlined above - integrating roaring bitmap support directly into Valkey simplifies enterprise deployments.

  15. lemire commented on Nov 4, 2026

    @lemire
    Contributor

    @fjmaco @yzqzss My branch includes export/import.

    unstable...lemire:valkey:roaring-bitmaps

  16. madolson commented on Nov 9, 2026

    @madolson
    Member

    Open Major questions discussed in our Monday meeting:

    1. Is this a new native data type or work on the bitops data types. (Preference is aligned with the PR that having it be transparent to users is nice, maybe we should have a native bitmap datatype).
    2. Should this be inside the core (Survey seems yes).

    We'd like to see how this overlaps with the new Redis APIs.

    @lemire Would you be willing to open a PR with your change so it's easier to iterate on? We would also ask if you would be willing to write out a design doc like #5286 and attach it to the PR to discuss the differences between having it as a new type vs existing string encoding. If that isn't something you're interested, please still open a PR and we will have someone use that as a starting point (but would like to capture your work).

  17. lemire commented on Nov 9, 2026

    @lemire
    Contributor

    @madolson Let me see what I can do.

  18. lemire commented on Nov 10, 2026

    @lemire
    Contributor

    @madolson PR created as requested.

    Consider this PR as a formal proposal for discussion.

  19. im-bravo commented on Nov 12, 2026

    @im-bravo
    Author

    @madolson PR created as requested.

    Consider this PR as a formal proposal for discussion.

    Hi, @lemire
    Thanks for the incredible work on PR #5344. The design doc, the native type decision, the fuzzing, and the honest benchmarks all show a lot of care. I know these changes involve real trade-offs around replication and compatibility, and I appreciate the rigor you've brought to it. Looking forward to seeing it land.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    client-changes-neededmajor-decision-pending

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions