Repository navigation
Bump croaring from v4.5.1 to v5.1.1 - #118917
Conversation
Upstream changes of note: * Fixes `croaring_refcount_dec` in `portability.h`, which compared the pointer instead of the value (`val == 0` instead of `*val == 0`) and therefore never reported a dropped-to-zero refcount on the non-atomic code path. * Makes the `Roaring64Map` "portable" serialization actually portable by converting the map size and the high-32-bit keys through the new `croaring_htole*` / `croaring_letoh*` helpers. On little-endian hosts this is a no-op, so the on-disk format of `groupBitmap` states is unchanged. * Hardens `Roaring64Map::readSafe`: it now checks that at least eight bytes are available before reading the map size and advances the cursor using `roaring_bitmap_portable_deserialize_size` instead of the size of the bitmap it just built. * Adds a `roaring64.hh` C++ header, `Roaring64Map::containsRange` and `containsRangeClosed`, `Roaring::mask` / `maskClosed`, range-reading iterator methods, and RISC-V detection in `portability.h`. * Relaxes the return types of `frozenView` and `portableDeserializeFrozen` from `const Roaring` to `Roaring`. No source file was added or removed under `contrib/croaring/src`, so `contrib/croaring-cmake/CMakeLists.txt` needs no change. The public API changes are additive, so no adaptation was needed in `src`. Verified locally by building the `_roaring` and `clickhouse` targets and by comparing bitmap query output between binaries built with v4.5.1 and v5.1.1: serialized `groupBitmap` states are byte-identical, and states written by the v4.5.1 binary deserialize identically under v5.1.1.
|
Workflow [PR], commit [962d7b9] Summary: ✅
AI ReviewSummaryThis PR bumps Findings❌ Blockers
Final VerdictRequest changes. The LLVM Coverage ReportMeasured on commit 962d7b9.
Changed lines: Uncovered code analysis did not run: No coverable C/C++ source files changed (contrib/ is excluded from coverage). Newly covered: +252 lines in 87 files (-192 lines lost coverage) · Details |
| @@ -1 +1 @@ | |||
| Subproject commit 025ae3f7add169bc820dcfd46fa9304f382ec40a | |||
| Subproject commit 342463b31b909737bd6295c69b2f8e0ed9497424 | |||
There was a problem hiding this comment.
This bump pulls in upstream commit 07c3d83 ("fixing support for big endian (IO)"), which changes the bytes produced and consumed by roaring::Roaring64Map::{write,read,readSafe} on big-endian hosts. ClickHouse persists that exact format in at least two places: AggregateFunction(groupBitmap, UInt64) states (src/AggregateFunctions/AggregateFunctionGroupBitmapData.h:140-162) and DeleteBitmap VERSION_R64 bodies (src/Storages/MergeTree/UniqueKey/DeleteBitmap.cpp:314-416).
The incompatibility is concrete: before this bump, an s390x bitmap with map_size = 1 serialized the outer count as host-order bytes 00 00 00 00 00 00 00 01; after the bump, the new reader applies croaring_letoh64 and interprets that same payload as 0x0100000000000000, so pre-upgrade data stops parsing. The reverse break exists on downgrade because the new writer emits little-endian bytes instead. Since the repository documents experimental s390x support, this is a real on-disk/state compatibility change, not just an upstream implementation detail.
Please keep the old encoding for existing ClickHouse formats on big-endian, or add an explicit versioned migration/read path for these Roaring64Map payloads before taking the submodule bump.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes21 object files changed (+125.67 KiB total), 0 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units71 translation units recompiled, 546 s compile time in total, 71 of them have a recent master baseline. |
|
@thevar1able it wasn't false alarm
Also related to #115805 |
When the bitmap argument of `bitmapContains` is constant, keep a `roaring::BulkContext` across rows and call `containsBulk`. The context caches the container found by the previous lookup, so values that share the high 16 bits (sorted or clustered keys) skip the container search. This recovers the regression from the `croaring` v4.5.1 -> v5.1.1 bump (ClickHouse#118917). Upstream commit RoaringBitmap/CRoaring@98509153 ("optimize bin search") replaced the plain `binarySearch` used by `ra_get_index` with a block-based search that is faster for random keys but about 2x slower for predictable ones, which is what `bitmapContains` over ordered data produces. With the bulk context the lookup is faster than before the bump: the `scalar` perf query goes from 57 ms to 42 ms locally. Related: ClickHouse#115805 Related: ClickHouse#118917 Co-Authored-By: Claude Fable 5.1 <[email protected]>

Bumps
croaringfromv4.5.1tov5.1.1(upstreamRoaringBitmap/CRoaring, commit025ae3f7add169bc820dcfd46fa9304f382ec40a→342463b31b909737bd6295c69b2f8e0ed9497424). The submodule points at upstream directly, so there is no fork branch and no patches to carry.The notable upstream fix is in
croaring_refcount_decininclude/roaring/portability.h, which compared the pointer rather than the value (return val == 0;→return *val == 0;) and so never signalled a refcount reaching zero on the non-atomic path; ClickHouse builds take the atomic path, so this was latent here.Roaring64Map::write/read/readSafenow route the map size and the high-32-bit keys through the newcroaring_htole*/croaring_letoh*helpers — a no-op on little-endian, so the persistedgroupBitmapstate format is unchanged on every architecture ClickHouse ships.readSafeadditionally checks that eight bytes are available before reading the map size and advances viaroaring_bitmap_portable_deserialize_size. The rest is additive:cpp/roaring/roaring64.hh,Roaring64Map::containsRange/containsRangeClosed,Roaring::mask/maskClosed,Roaring::serializedSizeInBytesSafe, iteratorread_ranges/read_prev_ranges,ROARING_FLAG_FROZEN_ARTand RISC-V detection inportability.h.frozenViewandportableDeserializeFrozennow return non-constRoaring/Roaring64Map, which is source-compatible since nothing insrcbinds those results to aconst-qualified type.No ClickHouse-side adaptation was needed — the commit touches only the submodule pointer. The
SRCSlist incontrib/croaring-cmake/CMakeLists.txtstill matches the 22.cfiles in the new tree exactly (no.cfile was added, removed or renamed between the two tags), and the only upstreamsrc/CMakeLists.txtchange is a newROARING_SANITIZE_MEMORYoption that ClickHouse does not use. TheOS_FREEBSDbswap64=__bswap64workaround stays, asportability.hstill usesbswap64there. The 30 files undersrc/that include roaring headers —FunctionsBitmap.*,AggregateFunctionGroupBitmapData.h, the text-index posting-list codecs,DeleteBitmap, the Iceberg/DeltaLake deletion vectors and the Puffin format — need no changes.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Bump
croaringfrom v4.5.1 to v5.1.1. Serialized bitmaps are unchanged on little-endian platforms; on big-endian platforms the on-disk layout ofgroupBitmapstates changes to the portable little-endian format.Workflow [PR]
Sync PR [sync-upstream/pr/118917]
Version info
26.9.1.1173-master(included in26.9and later)26.8.11.34,26.7.14.30,26.3.33.137