You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[NEW] How about support Roaring Bitmaps in valkeyΒ #1480
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.
Reacted by Zvi Schneider, Harkrishn Patro, Asaf Porat Stoler, Paul De Audney, Cody Neiman, adrianeui, Philippe Maia, Mark Salpeter, [Brian] VΓ΅ Minh TrΓ, ZY and 5 more
Reacted by im-bravo, Paul De Audney, Cody Neiman, adrianeui, Philippe Maia, [Brian] VΓ΅ Minh TrΓ, Dhruvil and Chengri a Qi
@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.
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.)
Reacted by Artyom Pervukhin, Mohan Rajendran and Chengri a Qi
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.
Open Major questions discussed in our Monday meeting:
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).
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).
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.
Activity
im-bravo commentedon Mar 10, 2025
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
arthurkiller commentedon Mar 10, 2025
croaring is under Apache license and redis-roaring is MIT, you can use them with valkey freely
arthurkiller commentedon Mar 10, 2025
and if you look a little deeply into roaring implementation, you will find roaring can adaptively choose
bitmap_enginebased on your data scalefjmaco commentedon Aug 25, 2026
https://github.com/fjmaco/valkey-roaring
yzqzss commentedon Aug 25, 2026
https://github.com/aviggiano/redis-roaring is essentially a Redis distribution that includes the
redis-roaringmodule. 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-builderfjmaco commentedon Aug 25, 2026
@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.
Add a Roaring encoding for bitmaps
lemire commentedon Oct 16, 2026
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.)
lemire commentedon Oct 16, 2026
(I meant that I do not seek credit.)
madolson commentedon Oct 27, 2026
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.
yzqzss commentedon Oct 27, 2026
@fjmaco This is indeed a good feature.
lbuesching commentedon Oct 30, 2026
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.
lemire commentedon Nov 4, 2026
@fjmaco @yzqzss My branch includes export/import.
unstable...lemire:valkey:roaring-bitmaps
madolson commentedon Nov 9, 2026
Open Major questions discussed in our Monday meeting:
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).
lemire commentedon Nov 9, 2026
@madolson Let me see what I can do.
lemire commentedon Nov 10, 2026
@madolson PR created as requested.
Consider this PR as a formal proposal for discussion.
im-bravo commentedon Nov 12, 2026
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.