Skip to content

feat(util): add Mumbling bitmap reader - #1126

Open
xndai wants to merge 6 commits into
apache:mainfrom
xndai:xndai/iceberg-cpp/B1
Open

xndai wants to merge 6 commits into
apache:mainfrom
xndai:xndai/iceberg-cpp/B1

Conversation

@xndai

@xndai xndai commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1125. Part of #1107.

Adds an internal reader for the Mumbling bitmap format (a draft spec, apache/iceberg#16518), which v4 manifest deletion vectors use (manifest_info.dv, tracking.deleted_positions and tracking.replaced_positions). Because the spec is a draft, the header is util/mumbling_bitmap_internal.h and isn't installed.

MumblingBitmapView::Make() wraps the serialized bytes without copying them. In scan planning those bytes belong to the root manifest entry, which outlives the planning of its leaf manifest. Make() checks the header, the PFOR-encoded descriptor array (Appendix A), the descriptor types, and the container sizes against the buffer, so Contains() never reads out of bounds. Like the Java reader, it doesn't validate container contents. Sparse-container lookups use SSE2 on x86-64 and a portable SWAR search elsewhere; no compiler flags are added.

Tests cover the spec examples, malformed input (including the vectors from Java's TestMumblingBitmap), and the Java-generated fixtures from apache/iceberg-go#1750. mumbling_bitmap_benchmark (built with -DICEBERG_BUILD_BENCHMARKS=ON) measures decoding and lookups.

Benchmark against the Java reader on the same input bytes (Release; gcc-14 with Google Benchmark, JDK 17 with JMH; Xeon Platinum 8175M):

Operation C++ Java
Decode 8,192 PFOR-encoded descriptors 0.35–3.1 µs 1.3–12.4 µs
Make, 100,000 random positions 13.3 µs 29.2 µs
Make, all 2,097,152 positions 9.4 µs 14.2 µs
Contains, 4,096 probes, 100,000 random positions 23.7 µs 83.5 µs
Contains, 4,096 probes, all positions 14.6 µs 24.1 µs

Test:

  • New unit tests in util_test (mumbling_bitmap_internal_test.cc) cover
    the spec examples, Java-generated fixtures and malformed input.
  • The full test suite passes on both the SSE2 and the portable lookup
    path, and the new tests pass under ASan and UBSan.
  • New microbenchmarks in src/iceberg/benchmark
    (mumbling_bitmap_benchmark, built with -DICEBERG_BUILD_BENCHMARKS=ON).

@xndai
xndai force-pushed the xndai/iceberg-cpp/B1 branch from ce1a7d1 to b11c29a Compare November 14, 2026 19:36
Comment thread src/iceberg/benchmark/CMakeLists.txt Resolved
Comment thread src/iceberg/CMakeLists.txt Resolved

// SSE2 is part of the x86-64 baseline, so it needs no extra compiler flags.
// Define ICEBERG_MUMBLING_SSE2=0 to force the portable scalar code.
#if !defined(ICEBERG_MUMBLING_SSE2) && (defined(__SSE2__) || defined(_M_X64)) && \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we leverage https://github.com/xtensor-stack/xsimd or https://github.com/google/highway to make it more portable? Since I don't expect we will have more SIMD code in the near future, I'm fine to keep it simple for now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think that would be a discussion to have. They are big dependency to pull in and I feel we can defer this decision to later when we have more SIMD code. We could probably extract a SIMD kernel library later and then see what can be benefited from re-using some of the existing library.

// Compare 32 bytes at once when they are all inside the buffer (every
// container except those in the last 31 bytes of the bitmap).
if (containers_data_.size() - offset >= kDenseLength) {
#if ICEBERG_MUMBLING_SSE2

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you want to add a NEON equivalent?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't have a NEON equivalent for now. Will need to setup new hardware for testing. Can we track that as a separate follow up? Probably at some point, we just going to extend the intrinsics to ARM.

Add an internal reader for the Mumbling bitmap format, which v4
manifest deletion vectors use (manifest_info.dv,
tracking.deleted_positions and tracking.replaced_positions). The spec
is still a draft, so the header is internal and not installed.

MumblingBitmapView wraps the serialized bytes without copying them and
supports Contains() and Cardinality(). Make() validates everything that
memory safety depends on, so lookups never read out of bounds.

Test:
- New unit tests in util_test (mumbling_bitmap_internal_test.cc) cover
  the spec examples, Java-generated fixtures and malformed input.
- The full test suite passes on both the SSE2 and the portable lookup
  path, and the new tests pass under ASan and UBSan.
- New microbenchmarks in src/iceberg/benchmark
  (mumbling_bitmap_benchmark, built with -DICEBERG_BUILD_BENCHMARKS=ON).
Use KeepRunning() loops and an explicit main() in the benchmark (as in
benchmark_smoke.cc), std::cmp_less for signed/unsigned comparisons,
and std::array instead of a C array in the test.
Decode once before the timing loop in BM_PforDecode and BM_Make and
call SkipWithError on failure, so a decode error can't show up as a
speedup.
State that data and out must not overlap, and list the structural and
range errors DecodePforBytes returns. Padding bits are ignored.
@xndai
xndai force-pushed the xndai/iceberg-cpp/B1 branch from a4d65f0 to 5425423 Compare November 25, 2026 23:10

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

Add a Mumbling bitmap reader for v4 manifest deletion vectors

2 participants