Skip to content

Document native Roaring bitmaps for Redis 8.12 - #3715

Merged
dwdougherty merged 13 commits into
redis:feature-oss-8.12from
aviggiano:agent/roaring-bitmap-docs
Oct 19, 2026
Merged

dwdougherty merged 13 commits into
redis:feature-oss-8.12from
aviggiano:agent/roaring-bitmap-docs

Conversation

@aviggiano

@aviggiano aviggiano commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Documents native Roaring-compressed bitmaps for Redis 8.12, including representation/conversion rules, string-command compatibility, memory tradeoffs, BITOP behavior, persistence, replication, and the bitmap return value of TYPE.

Includes generated reference pages and railroad diagrams for the internal BITCONVERT and BITROAROP commands, covering replication/AOF behavior, arguments, returns, and ordinary-client restrictions.

Also documents the native integer-array command from redis/redis#15986:

  • A command reference page and railroad diagram for BITRANGEINTARRAY, generated with build/cmd_tools.py from authoritative command metadata. Covers native-only typing, inclusive ranks, uint32 argument bounds, bounded span limits, and end=-1 for all remaining elements. Documents rank and bounded-range validation before key lookup, including standard ERR wording and precedence over WRONGTYPE. The separate BITGETINTARRAY page and diagram are removed to match the consolidated API.
  • Bitmap guide examples and pagination guidance, including concurrent-mutation behavior. Explains why internal replication/AOF commands BITCONVERT and BITROAROP are hidden from ordinary clients and return ERR unknown command when called directly.
  • Complete benchmark methodology and historical results moved out of the Redis source repository. The original report is preserved and explicitly identifies its source revision before the command rename and consolidation; it does not claim current measurements.

Previous validation: all 32 documented public command/reply checks passed across RESP2 and RESP3, with command removal and metadata verified against the rebuilt server. Front matter and SVGs match the repository generator; internal links and changed-page Hugo rendering passed. Internal-command visibility was previously verified with 12 checks across both protocols. Full-site rendering requires the repository's external notebook/example inputs, which are absent from this checkout.

Latest update: synchronized the range-error wording and validation order with redis/redis#15986. The rebuilt server passed all 189 executed Roaring tests and 126 direct command/reply checks across RESP2 and RESP3. The documentation patch applies cleanly and preserves generated front matter, diagrams, shortcodes, and examples. Site rendering was not repeated for this prose-only update.


Note

Low Risk
Documentation-only changes (prose, command metadata, SVGs); no runtime or application code paths are modified.

Overview
Documents Redis 8.12 native Roaring bitmaps in the docs site: dual string vs native bitmap / bitmap-roaring storage, bitmap-default-roaring behavior, type visibility (TYPE now lists bitmap), string-command WRONGTYPE rules, and persistence/replication caveats.

Adds command reference pages and railroad diagrams for BITRANGEINTARRAY (rank-based set-bit offset reads, validation order, span limits, end=-1), plus internal BITCONVERT and BITROAROP (replication/AOF only, hidden from ordinary clients). Expands the bitmap guide with Roaring enablement examples, BITRANGEINTARRAY usage/pagination, and links to a new integer-array benchmark page that preserves historical redis-roaring comparison methodology and pre-consolidation measurements.

Reviewed by Cursor Bugbot for commit 50cfc0f. Bugbot is set up for automated code reviews on this repo. Configure here.

@CLAassistant

CLAassistant commented Jul 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@dwdougherty

dwdougherty commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @aviggiano. Thank you for this PR. Which Redis Open Source release will contain this new feature? I know it's not in 8.10, because it's just about closed. Is it for 8.12?

Your PR target needs to be a release-specific feature branch, not main. Once you answer the above, I will create the appropriate branch and then you can edit your PR.

Also, this repo does not allow slashes (/) in branch names.

@dwdougherty dwdougherty self-assigned this Jul 28, 2026
@dwdougherty dwdougherty added oss Redis Open Source dev labels Jul 28, 2026
@aviggiano

Copy link
Copy Markdown
Contributor Author

Thanks, it's still unclear which release this will be targeted

I'll sync with @sundb and will update the PR

@aviggiano
aviggiano force-pushed the agent/roaring-bitmap-docs branch from c02b80f to 4304fa1 Compare August 7, 2026 17:41
@aviggiano aviggiano changed the title Document native Roaring bitmaps Document native Roaring bitmaps for Redis 8.12 Aug 7, 2026
@aviggiano
aviggiano changed the base branch from main to feature-oss-8.12 August 7, 2026 17:42
@aviggiano

Copy link
Copy Markdown
Contributor Author

Yes, this is for 8.12. I’ve retargeted the PR to feature-oss-8.12 and updated the copy. The existing head branch predates the slash restriction; renaming it would close this PR, so I kept it to update the existing PR.

@dwdougherty

Copy link
Copy Markdown
Collaborator

Thank you, @aviggiano. We actually fixed the branch naming issue just recently, so you should be good. Let me know when this PR is ready for review (it's still a draft).

@aviggiano
aviggiano marked this pull request as ready for review August 23, 2026 15:25

@dwdougherty dwdougherty left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aviggiano. Just one comment. Otherwise, these docs look good. Are they ready to be merged to the 8.12 feature branch?

Also, would you mind pointing me to the redis/redis PR? I want to take a look.

defined on the String type which is treated like a bit vector.
Since strings are binary safe blobs and their maximum length is 512 MB,
they are suitable to set up to 2^32 different bits.
Starting with Redis Open Source 8.12, Redis can store bitmaps in two

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Starting with Redis Open Source 8.12, Redis can store bitmaps in two
Starting with Redis 8.12, Redis can store bitmaps in two

@aviggiano

Copy link
Copy Markdown
Contributor Author

Hi @aviggiano. Just one comment. Otherwise, these docs look good. Are they ready to be merged to the 8.12 feature branch?

Also, would you mind pointing me to the redis/redis PR? I want to take a look.

pending approval from @sundb on redis/redis#15331

@dwdougherty

Copy link
Copy Markdown
Collaborator

Okay. I thought I saw Yaacov say that there were no API changes, but maybe he only meant for milestone 1. I'll hold off on this until I see that the redis/redis PR is merged. I'll then add the new command page.

sundb added a commit to redis/redis that referenced this pull request Oct 14, 2026
Fixes #15296

## Native Roaring bitmaps

Adds a native **Roaring bitmap** representation for Redis bitmaps,
backed by vendored **CRoaring v4.7.2** (`deps/croaring`, built with SIMD
disabled and symbols hidden for portability). A string bitmap costs one
byte per 8 bit positions up to its highest offset, regardless of how
many bits are set; sparse or large bitmaps are instead stored
compressed, cutting memory dramatically while preserving exact bit
semantics.

### Type & object model
- New object type `OBJ_BITMAP` with encoding
`OBJ_ENCODING_BITMAP_ROARING`. `TYPE` → `bitmap`, `OBJECT ENCODING` →
`bitmap-roaring`.
- Object header: `encoding` widened 4→5 bits to fit the new encoding
value; to keep `redisObject` the same width, `refcount` drops 23→22
bits, lowering the maximum non-shared refcount from 8388605 to 4194301
(still far above any real per-object refcount).

### Enabling it — `bitmap-default-roaring`
- New boolean config (default **no**, runtime-modifiable). When **off**,
bitmap writes keep creating plain strings. Native bitmaps remain
supported and can enter the keyspace through `BITOP` with a Roaring
source, `RESTORE`, replication, or loading an RDB/AOF containing them.
- When **on**, bit-writes that create or extend a bitmap produce a
native Roaring bitmap, an existing string bitmap converts in place on
the next bit-write (TTL and module metadata preserved), and `BITOP`
destinations are Roaring. Automatic creation/conversion is disabled on
replicas and when a write's propagation excludes either AOF or replicas
— notably `RM_Call()` without `!`, selective `RM_Call()` flags, and
scripts using `redis.set_repl()`; such writes keep plain strings on
every node.

### Command surface & string boundary
- Bit commands operate on both representations transparently: `SETBIT`,
`GETBIT`, `BITCOUNT`, `BITPOS`, `BITOP`, `BITFIELD`, `BITFIELD_RO`.
- A native Roaring bitmap is a **distinct type**: plain string commands
(`GET`, `GETRANGE`, `APPEND`, `SETRANGE`, `STRLEN`, …) return
`WRONGTYPE`. `DEBUG BITMAP-RAW` exposes the materialized bytes.
- Bit offsets follow the historical string rule on both representations:
capped at `proto-max-bulk-len` × 8. Internal representability is bounded
at 2^60−1 logical bytes (`BITROAR_MAX_BYTES`). `BITOP NOT` over a
Roaring source bounds missing-chunk allocation with a budget derived
from `proto-max-bulk-len` (minimum 65,536 chunks of 8 KiB). Replication
and AOF replay bypass this budget to apply accepted operations; dense
string sources are exempt.

### Persistence
- Adds `RDB_TYPE_BITMAP` (33) under the existing RDB version 16
introduced for 8.12 (this PR does not bump it). This relies on shipping
in 8.12: 8.12 milestone builds without this PR reject type 33 cleanly,
and if the PR slips past 8.12, `RDB_VERSION` must be bumped. The
RDB/DUMP payload is the logical byte length followed by the CRoaring64
portable serialization — compact, not a dense byte expansion. Loading
enforces the representability bound and validates the blob.

### Replication & AOF — deterministic by construction
- Representation decisions are never re-derived from a replica's or
AOF-loader's own config. The transition travels in the stream as the
internal `BITCONVERT <key>` and `BITROAROP` commands (hidden from
`COMMAND`, internal-client gated, `since 8.12.0`; `ACL CAT` and `ACL
DRYRUN` are not yet filtered and still list them):
- `SETBIT`/`BITFIELD` creating or converting a bitmap replay as
`BITCONVERT` followed by the original command, grouped in
`MULTI`/`EXEC`;
- a `BITOP` whose destination is Roaring only by configuration replays
as internal `BITROAROP`, which stores the native result directly and
preserves notification and callback ordering;
  - operations on already-Roaring operands propagate verbatim.
- `BITCONVERT` applies the same in-place transition the primary
performed: TTL and module metadata retained, no value payload in the
stream.

### Notifications, modules, cluster
- `NOTIFY_BITMAP` (class `b`) keyspace events; conversion is an
observable in-place type change: `type_changed` (class `c`) then the
command's own event when it changes the logical value — never
`overwritten`. A conversion that leaves the logical value unchanged
still emits `type_changed`, counts as a write, and is propagated. A
newly created native key emits `new` (class `n`) rather than
`type_changed`.
- Modules observe the transition via the type-changed callback;
`REDISMODULE_KEYTYPE_BITMAP` added.
- Works under Cluster, including atomic slot migration
(`tests/unit/cluster/bitmap.tcl`, `atomic-slot-migration.tcl` coverage).

### Memory accounting & active defrag
- Full memory accounting; all CRoaring allocations route through
`zmalloc`. Active defrag walks the Roaring64 ART and its ARRAY, BITSET,
and RUN containers (via a small vendor patch exposing `roaring64`
internals), and fork-child memory is dismissed correctly. INFO keysizes
gains a `distrib_bitmaps_sizes` histogram of **logical** byte length,
not memory: a sparse Roaring bitmap can be orders of magnitude smaller
than its bucket, unlike `distrib_<collection>_sizes`, which reports
allocation size. Bitmap allocation sizes are tracked internally but, as
for strings, not reported by INFO.

### Documentation
- End-user documentation is tracked in redis/docs#3715, targeting Redis
8.12.

---------

Signed-off-by: Antonio Viggiano <[email protected]>
Co-authored-by: debing.sun <[email protected]>
@dwdougherty

dwdougherty commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @aviggiano. In this PR, two other commands were added: BITCONVERT and BITROAROP. Do we need to add command pages for those as well?

I'll have to redo the commands you added in this commit. New commands need to be added using our skill/tools so that the front matter is correctly specified and railroad diagrams are generated. I'll make a commit with these changes today.

Another interesting bit. I've been trying to use BITCONVERT/BITROAROP using nightly builds, but the commands don't exist. I can see the commit, so they should be there. Confounding.

@aviggiano

Copy link
Copy Markdown
Contributor Author

hey @dwdougherty

thanks for replying

Responding to your questions

Do we need to add command pages for those as well?

I think so. Will do

I'll have to redo the commands you added in this commit.

Will do

Another interesting bit. I've been trying to use BITCONVERT/BITROAROP using nightly builds, but the commands don't exist. I can see the commit, so they should be there. Confounding.

let me see what is wrong, it should be there

@dwdougherty

Copy link
Copy Markdown
Collaborator

\0/ nice! Thank you for re-working the two command pages.

@dwdougherty

dwdougherty commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Debing says they don't show up because they have the INTERNAL flag set in the JSON files. I think this is a recent change, because we have other internal commands that do work and have been documented. Debing is going to confirm with Yaacov.

@dwdougherty

Copy link
Copy Markdown
Collaborator

Hi @aviggiano. Are these docs ready to be merged to my feature branch?

@aviggiano

Copy link
Copy Markdown
Contributor Author

Finishing review fixes in redis/redis#15986. I’ll sync the docs, then confirm.

@aviggiano

Copy link
Copy Markdown
Contributor Author

Yes, ready for the 8.12 feature branch.

Updated warning syntax for Roaring bitmap creation instructions.
@dwdougherty

Copy link
Copy Markdown
Collaborator

Thank you again, @aviggiano, for handling the docs for your new feature!

@dwdougherty
dwdougherty merged commit c3d6c5b into redis:feature-oss-8.12 Oct 19, 2026
4 checks passed
dwdougherty added a commit that referenced this pull request Nov 23, 2026
* DEV: (feat/cmds) docs for CMS enhancements in 8.12 (#3953)

* DEV: (feat/cmds) docs for blessed keys in 8.12 (#4012)

* Document aof_cmd_duration in INFO persistence (#4006)

Co-authored-by: Cursor <[email protected]>

* DEV: docs for HNSW compression in 8.12 (#4106)

* DEV: docs for HNSW compression in 8.12

* Apply review suggestion

Clarified that disk-based vector indexes ignore both COMPRESSION and TRAINING_THRESHOLD.

* DEV: (feat) docs for streams observability metrics MVP in 8.12 (#4140)

* DEV: (feat) docs for streams observability metrics MVP in 8.12

* Update content/develop/data-types/streams/_index.md

Co-authored-by: mich-elle-luna <[email protected]>

---------

Co-authored-by: mich-elle-luna <[email protected]>

* DEV: (cmds) JSON: auto-create deep paths in 8.12 (#4257)

* DEV: (cmds) JSON: auto-create deep paths in 8.12

* Apply review comments.

Co-authored-by: andy-stark-redis <[email protected]>

---------

Co-authored-by: andy-stark-redis <[email protected]>

* DEV: (cmds) docs for new INFO command streams section (#4274)

* DEV: (cmds) docs for new INFO command streams section

* Apply review comments.

Co-authored-by: andy-stark-redis <[email protected]>

---------

Co-authored-by: andy-stark-redis <[email protected]>

* OP: add docs for named TLS in 8.12 (#4289)

* Document native Roaring bitmaps for Redis 8.12 (#3715)

* Document native Roaring bitmaps

* Keep Roaring details in bitmap guide

* Target Roaring bitmap docs to Redis 8.12

* Clarify native bitmap replication docs

Signed-off-by: Antonio Viggiano <[email protected]>

* Document native bitmap integer arrays and benchmark methodology

* Clarify bitmap rank argument validation order

* Regenerate bitmap command references and clarify internal replay

* Document internal bitmap replay commands

* Document consolidated bitmap integer-array command

* Clarify the consolidated bitmap integer-array command

* Document bitmap range validation before key lookup

* Change warning format in bitmaps documentation

Updated warning syntax for Roaring bitmap creation instructions.

---------

Signed-off-by: Antonio Viggiano <[email protected]>
Co-authored-by: David Dougherty <[email protected]>

* DEV: update modules API page for 8.12 release (#4306)

* DEV: update modules API page for 8.12 release

* Apply batched suggestions from code review

Co-authored-by: mich-elle-luna <[email protected]>

---------

Co-authored-by: mich-elle-luna <[email protected]>

* Document BITRANGEINTARRAY offset ranges, ZEROS, and pagination (#4304)

* Document negative bitmap ranks and the shared range limit

* Document bitmap range validation after key lookup

* Document uncapped bitmap enumeration and range truncation

* Document conditional string reads for BITRANGEINTARRAY

* Document bitmap value selection, offset ranges, and LIMIT pagination

* Align BITRANGEINTARRAY docs with merged ZEROS syntax

* DEV: (cmds) docs for set member expiration in 8.12 (#4337)

* DEV: (cmds) docs for set member expiration in 8.12

* Apply changes from review.

* Apply changes from upstream merge commit

* DEV: add redis-8-12-commands.md page (#4421)

* DEV: add 8.12 what's new page (#4422)

* OP: update OSS version management page for 8.12 (#4423)

* DEV: update data/commands_core.json from 8.12 GA build (#4436)

* Remove 8.12 release notes; point to redis/redis repo

* Document atomic sorted-set moves and BYSCORE batch claims (#4522)

* Document sorted-set move batches and destination conditions

* Document positive COUNT validation for sorted-set moves

* Document the ZMOVEMEMBER MEMBERS block

* Clarify final BZMOVE behavior after core merge

* Add new sorted set cmds to summary page

* Update module API page

* Update what's new for features added in 8.12-rc3

* Add compat. info to new sorted set commands

* Modify ACL categories for two bless commands

* Update config page to point to 8.12 config

---------

Signed-off-by: Antonio Viggiano <[email protected]>
Co-authored-by: yinon-bit <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: mich-elle-luna <[email protected]>
Co-authored-by: andy-stark-redis <[email protected]>
Co-authored-by: Antonio Viggiano <[email protected]>
Co-authored-by: fcenedes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev oss Redis Open Source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants