Skip to content

build(arrow)!: upgrade to 26.0.1 and require C++20 - #598

Open
SteNicholas wants to merge 1 commit into
apache:mainfrom
SteNicholas:PAIMON-596
Open

SteNicholas wants to merge 1 commit into
apache:mainfrom
SteNicholas:PAIMON-596

Conversation

@SteNicholas

@SteNicholas SteNicholas commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Purpose

Linked issue: close #596

Upgrade bundled Arrow and Parquet from 17.0.0 to 26.0.1 in Paimon C++ to unblock the upstream Parquet geospatial APIs needed by #580.

  • Pin the Arrow 26.0.1 archive by SHA-256 and disable bundled mimalloc. Backport upstream Arrow's force-inlined arrow::Status destructor (apache/arrow#50749) and null-free dictionary-encoded BYTE_ARRAY decode fast path (apache/arrow#55897).
  • Require C++20 and CMake 3.26 for source builds, retire GCC 8 CI, strip C++ standard flags from C builds, and build bundled Boost 1.66 in C++17 mode for Lucene++.
  • Keep installed public headers C++17-compatible by removing Arrow includes and the bundled <paimon/arrow/abi.h> header, forward-declaring Arrow C Data structs, and defining ReadContext::HasReadSchema() out of line.
  • Port the Parquet reader and writer patches to Arrow 26 and register compute kernels in static builds. Preserve byte-based page sizing, configurable page indexes, standard column statistics, and page-filtered prefetch, and skip empty row groups across FileReaderWrapper and GetRecordBatchReader.
  • Support short asynchronous reads in ArrowInputStreamAdapter, expose base ReadAt overloads, and keep shared files and memory pools alive through completion.
  • Preserve null-first sorting with per-key NullPlacement::AtStart, use Arrow's checked timestamp parser, and report the file URI on ORC schema metadata errors.

Tests

  • GCC 14 Release installed-package smoke test compiling as C++17 against umbrella paimon/api.h and paimon/schema/schema.h, verifying Paimon headers do not define ARROW_C_DATA_INTERFACE, <arrow/c/abi.h> statistics macros remain visible, and ArrowSchema ownership round-trips through ReadContext.
  • ArrowStreamAdapterTest covering short and exact async reads, EOF and out-of-range errors, ReadManyAsync, ReadAt(..., allow_short_read), StorageReadBytes accounting, and file/pool lifetimes on both successful and failed async reads.
  • Parquet tests covering empty row groups (Create, PrepareForReading, PrepareForReadingLazy + deferred SeekToRow, raw GetRecordBatchReader, and all-empty files), multi-refill dictionary-encoded batches (REQUIRED non-null, OPTIONAL zero-null, mixed-null, and all-null), large_utf8() page-filtered reads, byte-sized pages, page-index toggles, absent size statistics/histograms, writer peak-memory bounds, and Variant round trips.
  • ORC tests covering field metadata round trips and file URIs in malformed Arrow schema metadata errors; cast tests covering non-UTF-8 string/binary conversions and Arrow 26's nanosecond timestamp bounds; integration coverage for explicit full compaction after schema evolution.

API and Format

  • Breaking build/header change: source builds now require C++20 and CMake 3.26+.
  • Public headers no longer include Arrow headers or ship <paimon/arrow/abi.h>; Arrow C Data structs are forward-declared and ReadContext::HasReadSchema() is defined out of line. Consumers needing full C Data struct definitions should include <arrow/c/abi.h> from their Arrow provider (which works from C++17 without linking Arrow C++).
  • Parquet writes explicitly preserve byte-based page sizing (max_rows_per_page(INT64_MAX)), configurable page indexes, and standard column statistics with SizeStatisticsLevel::None to match Arrow 17 output.

Documentation

Yes. Updated README.md, AGENTS.md, CONTRIBUTING.md, docs/code-style.md, and docs/source/building.rst for C++20 / CMake 3.26 source-build requirements; docs/source/build_system.rst for C++17 consumer integration and <arrow/c/abi.h> migration; and docs/source/user_guide/data_types.rst for Arrow 26's accepted TIMESTAMP(9) string range (1677-09-21 00:12:44 through 2262-04-11 23:47:16.854775807).

Generative AI tooling

Generated-by: Google Antigravity

@SteNicholas
SteNicholas force-pushed the PAIMON-596 branch 6 times, most recently from 1e5d99e to 9fcce87 Compare November 26, 2026 02:28
@lucasfang

Copy link
Copy Markdown
Member

I suggest removing paimon/arrow/abi.h and keeping only forward declarations in the public API headers. Users who need the complete definitions can explicitly include their Arrow ABI header.

Our copy shares the ARROW_C_DATA_INTERFACE guard with upstream Arrow. If included first, it can suppress newer definitions, such as Arrow 26’s ARROW_STATISTICS_KEY_* macros, making them unavailable to users.

ReadContext::HasReadSchema() would need to move to the implementation file because it accesses an ArrowSchema field.

Comment thread .github/workflows/gcc8_test.yaml Resolved
Comment thread test/inte/pk_compaction_inte_test.cpp Resolved
Comment thread test/inte/pk_compaction_inte_test.cpp Resolved
@lxy-9602

Copy link
Copy Markdown
Member

Thanks for upgrading the Arrow version! @zjw1111 is running some read/write performance regressions now—let’s wait for his results.

Comment thread cmake_modules/arrow.diff Resolved
Comment thread cmake_modules/arrow.diff Resolved
@SteNicholas SteNicholas changed the title build(arrow): upgrade to 26.0.1 and require C++20 build(arrow)!: upgrade to 26.0.1 and require C++20 Nov 30, 2026
@SteNicholas

SteNicholas commented Nov 30, 2026 •

Copy link
Copy Markdown
Member Author

@lucasfang I removed paimon/arrow/abi.h and left forward declarations in the public headers. ReadContext::HasReadSchema() is now defined out of line. The C++17 smoke test includes the Paimon header before <arrow/c/abi.h> and checks that Arrow's statistics macros are available.

@lxy-9602 and @zjw1111 I updated the benchmark section with the paired runs and the follow-up with longer warm-up. The uncompressed write result changed direction between runs, and the full scan remained 7.6% slower in the follow-up. The local Release builds use different fmt versions, so a matched comparison is still needed. The performance question remains open pending the independent results.

@SteNicholas
SteNicholas force-pushed the PAIMON-596 branch 2 times, most recently from 37e2a42 to cadde72 Compare November 30, 2026 09:49
@zjw1111

zjw1111 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Arrow 17 vs. 26 performance

I compared Arrow 17.0.0 and 26.0.1 with Clang 17. On the 11-string-column table, direct Parquet scans took 4.86%–16.25% longer with Arrow 26, depending on batch size and decoding threads. Through Paimon TableRead, a full-column scan of the same table at 10,000 rows per batch took 11.76% longer with Arrow 26 when the column types were unchanged. In Paimon schema-evolution reads, the extra time spent in data-column casts amounted to 4.3%–9.3% of the Arrow 17 scan time for the projections and conversions below.

For append writes, elapsed time changed by −1.8% to +0.6% across the three table shapes. All three stages of the default Zstd spill path were within 1%.

Percentages below show the change in elapsed time relative to Arrow 17. Negative values mean Arrow 26 was faster. Repeated measurements are summarized by the median paired change.

Direct Parquet reads on the 11-string-column table

Both Arrow releases scanned the same four warm-cache Parquet files through GetRecordBatchReader: 132.75M rows, 223 row groups, 11 string data columns and two integer benchmark columns. Only 737 of the 1.46B string values were null. Arrow 26 took longer in all 27 paired scans (three pairs per configuration). The table shows the median paired change in elapsed time. With 0 threads, decoding runs on the calling thread. With 1 or 3, column reads use the Arrow CPU thread pool.

Rows per batch 0 threads 1 thread 3 threads
1,024 +5.97% +4.98% +4.86%
4,096 +13.75% +13.04% +11.58%
10,000 +16.07% +16.25% +13.51%

At 10,000 rows per batch and 0 threads, three profiled full scans had median elapsed times of 30.49 s on Arrow 17 and 35.44 s on Arrow 26. Stack sampling placed the extra time in dictionary-encoded string decoding: estimated CPU time in that call path, including its callees, rose from 20.44 s to 25.67 s. Zstd decompression took about 2.3 s on both releases, and kernel CPU time was 0.14–0.15 s.

Two local changes to the Arrow 26 decoder tested that attribution. Forcing ArrowBinaryHelper::AppendValue inline saved 2.06–2.94 s per scan. In a separate paired comparison, adding a dedicated loop for dictionary batches without nulls reduced the median from 32.77 s (inlining alone) to 29.30 s. The experimental decoder and stock Arrow 26 produced identical full-table SHA-256 digests. These timings apply to this table and read configuration.

Cast performance

The table-read benchmark measures how much of a full scan is spent converting columns. The microbenchmark measures the change in time per conversion relative to the same cast on Arrow 17.

Paimon TableRead on older files after a schema change

Both Paimon builds (Arrow 17 at fc919101, Arrow 26 at 9fcce875) read the same four files described above through TableScan and TableRead, using 10,000 rows per batch, Paimon prefetch disabled, and the default three Parquet decoding threads. The evolved schema read an eight-digit numeric string as DOUBLE. The five-column case also read four string flags as INT.

Projection and conversion Full scan, s (17 / 26) Data-column casts, s (17 / 26) Cast share of 26 scan Extra cast time on 26
All 13 columns, original types 14.24 / 15.98 0 / 0 0% 0 s
All 13 columns, one string → DOUBLE 18.41 / 20.79 3.35 / 4.14 19.6% +0.79 s
All 13 columns, one string → DOUBLE and four strings → INT 24.03 / 26.88 8.93 / 10.08 37.2% +1.15 s
ID and one string, original types 3.92 / 4.44 0 / 0 0% 0 s
ID and one string → DOUBLE 7.53 / 8.74 3.32 / 4.01 45.6% +0.70 s

With the original types, Arrow 26 made zero data-column casts. With schema evolution, the additional cast time accounted for 4.3% of the Arrow 17 full-column scan time for one conversion and 4.8% for five conversions. Projecting only the ID and the column converted to DOUBLE raised that figure to 9.3%, since all 132.75M strings still had to be parsed.

Full-scan times are medians of three runs with uninstrumented builds. Separate paired runs timed the cast calls on the TableRead caller thread. Cast shares use the instrumented scan time, and the last column is the median paired difference in cast time.

Arrow Compute array cast microbenchmarks

Of 12 safe array casts tested through CastingUtils::Cast, six showed elapsed-time differences above 5% in the same direction across all six paired runs:

Conversion Elapsed time change Process CPU time change
int32 → int64 −19.6% −19.6%
int32 → UTF-8 +6.0% +6.0%
UTF-8 → int32 +10.4% +10.5%
UTF-8 → float64 +17.9% +17.9%
UTF-8 → timestamp[ms] +9.5% +9.5%
decimal128(20,2) → decimal128(24,4) +9.5% +9.5%

The remaining six conversions had median changes between −2.7% and +3.8%. Numeric parsing used signed integer strings, including for the float64 target. Timestamp strings had millisecond precision and no time zone. The decimal result measures Arrow Compute rescaling; Paimon’s DecimalToDecimalCastExecutor uses a separate implementation.

Paimon append writes

Each version used FileStoreWrite to append the same input rows to a bucket=-1 table. Each write produced four Zstd-compressed Parquet files of 232–282 MiB each. Elapsed time includes the final commit.

Data columns Rows written Change in append time (Arrow 26 vs. 17)
4 3.04M −0.3%
11 132.75M +0.6%
1,177 190K −1.8%

Arrow IPC and Paimon spill

Each measurement covered three local spill files of 1,048,576 rows each, with warm-cache reads. The two versions produced identical file sizes for each codec and returned identical record batches, including nulls.

IPC compression SpillWriter write IPC batch read SpillReader key/value iteration
Uncompressed −1.82% +0.08% −0.83%
LZ4 +1.13% +4.73% +0.05%
Zstd level 1 (Paimon default) +0.26% −0.55% +0.06%

LZ4 batch decoding showed the largest IPC difference. With the same codec, iterating all key/value rows through Paimon’s SpillReader differed by only 0.05%.

Both builds used Clang 17.0.6 in Release mode with Arrow SIMD disabled. Benchmarks ran serially on the same host with CPU, memory, and disk I/O monitoring.

@zjw1111

zjw1111 commented Dec 2, 2026

Copy link
Copy Markdown
Collaborator

Could we include the upstream arrow::Status destructor fix in our Arrow 26.0.1 patch set as part of this upgrade? The fix landed on Arrow main, but 26.0.1 still has the old destructor. With GCC 11.4 (-O2), we saw out-of-line destructor calls on the successful Status path during Parquet decoding. Upstream Arrow PR #50749

We compared stock 26.0.1 with the same build plus just that patch, reading the same Parquet files on a single core. Across six paired runs, the patch reduced median scan time by 27.8% for a 600k-row group with 11 string columns and by 13.8% for a full scan of TPC-H lineitem (24M rows, all 16 columns). Both workloads improved in all six runs. On the string-heavy row group, perf attributed 17.6% of user-space cycles to Status::~Status() in the stock build. This makes the backport worthwhile for GCC builds.

Bundled Arrow and Parquet 17.0.0 lacked the upstream geospatial APIs
needed by apache#580. Issue apache#596 calls for an Arrow upgrade and C++20 source
builds while preserving C++17 compatibility for installed consumers.

- Upgrade bundled Arrow and Parquet to 26.0.1, pin the archive by
  SHA-256 and disable bundled mimalloc. Backport the force-inlined
  arrow::Status destructor and null-free dictionary decode fast path.
- Require C++20 and CMake 3.26 for source builds. Retire GCC 8 CI and
  build bundled Boost in C++17 for Lucene++.
- Remove Arrow includes and the bundled ABI header from the public API.
  Forward-declare C Data structs in public headers and define
  ReadContext::HasReadSchema() out of line.
- Port the Parquet patches and register compute kernels in static
  builds. Preserve byte-based page sizing, configurable page indexes
  and standard column statistics.
- Skip empty row groups and retain page-filtered prefetch. Honor short
  asynchronous reads and keep shared files open through completion.
- Preserve null-first sorting with per-key null placement, use Arrow's
  checked timestamp parser and report the URI on ORC schema errors.
- Run the C++17 install smoke test in CI and cover async reads, empty
  row groups, dictionary decoding, Parquet options and ORC errors.
  Document build requirements, C++17 integration and timestamp bounds.
@SteNicholas

SteNicholas commented Dec 2, 2026 •

Copy link
Copy Markdown
Member Author

@zjw1111 @lxy-9602 Thanks for the detailed profiling and upstream Arrow fixes! I updated PAIMON-596 (e5c53852) to address both findings:

  1. Backported apache/arrow#50749 into cmake_modules/arrow.diff (cpp/src/arrow/status.{h,cc}) to force-inline arrow::Status::~Status() and keep the !state_->is_constant check inside DeleteState(), addressing the GCC Parquet decode overhead.
  2. Backported apache/arrow#55897 into cmake_modules/arrow.diff (cpp/src/parquet/decoder.cc) to restore the dedicated null_count == 0 index-buffer fast path in DictByteArrayDecoderImpl::DecodeArrowDense, addressing the Clang 17 dictionary-encoded string scan slowdown, and extended ParquetFileBatchReaderTest.TestNextBatchWithDictionary to cover 2,500-row (> 2× kBufferSize) dictionary batches across REQUIRED non-null, OPTIONAL zero-null, mixed-null, and all-null columns.
  3. Also tightened FileReaderWrapper::PrepareForReading/PrepareForReadingLazy to prune empty row groups consistently for direct callers, exposed base RandomAccessFile::ReadAt overloads in ArrowInputStreamAdapter, and verified the Parquet, ORC, core, realtime, and C++17 install_smoke tests locally.

HuaHuaY pushed a commit to apache/arrow that referenced this pull request Dec 3, 2026
…-encoded BYTE_ARRAY batches (#55897)

### Rationale for this change

While testing the Paimon C++ upgrade from Arrow 17 to 26, we found that
scanning dictionary-encoded string columns slowed down at larger batch
sizes. [Performance results in
apache/paimon-cpp#598](apache/paimon-cpp#598 (comment))
The dense Parquet decoder already treats a null-free batch as a single
valid run, but tracks both the remaining run length and a cursor into
the index buffer. For these batches, every index read can be consumed
immediately.

### What changes are included in this PR?

Handle `null_count == 0` inside
`DictByteArrayDecoderImpl::DecodeArrowDense`. Fill the existing
1,024-index buffer and append all indices returned by each read. Batches
with nulls continue to use `VisitBitRuns`, retaining unused indices
across null runs. Both paths share the index refill, dictionary bounds
check, and value append logic.

### Are these changes tested?

Existing `DictEncoding.CheckDecodeArrowUsingDenseBuilder` coverage
checks the output values and decoded count for 10,000 values with zero,
mixed, and all nulls across Binary, LargeBinary, BinaryView and their
string counterparts. `DictEncoding.CheckDecodeArrowNonNullDenseBuilder`
exercises the explicit non-null entry point across multiple index-buffer
refills. Both validate the resulting arrays. The existing tests cover
this change.

### Are there any user-facing changes?

Reading null-free batches of dictionary-encoded Parquet strings or
binary values into dense Arrow arrays can be faster.

The table compares the original and optimized loops in Clang 17 Release
builds. Each result is the median across runs.

| Benchmark | Batch size | Runs per build | Before | After | Change |
| --- | ---: | ---: | ---: | ---: | --- |
| Single-threaded Parquet scan of the four files in #55896 | 10,000 rows
| 3 | 33.34 s | 28.55 s | 14.37% less time |
| Binary dictionary decode | 65,536 values | 7 | 189.68 MiB/s | 222.38
MiB/s | 17.24% higher throughput |
| BinaryView dictionary decode | 65,536 values | 7 | 165.09 MiB/s |
180.14 MiB/s | 9.11% higher throughput |

### Was AI used for this PR?

OpenAI Codex wrote the implementation and PR description. The
contributor reviewed the code before submission.

**PR code and description written by:**

- [x] Human
- [x] AI

**Reviewed before submission by:**

- [x] Human
- [x] AI
- [ ] Not reviewed

* GitHub Issue: Closes #55896
HuaHuaY pushed a commit to apache/arrow that referenced this pull request Dec 4, 2026
…pend loop (#55940)

### Rationale for this change

When Parquet decodes BYTE_ARRAY values into ordinary Arrow string or
binary arrays, Clang and GCC Release builds can emit a call to
`AppendValue` for every non-null value. This shows up in both dictionary
and PLAIN decoding, even when the entire batch fits in the current
output chunk.

### What changes are included in this PR?

Move finishing the current chunk and reserving space in the next one
into a single `ARROW_NOINLINE` helper. Both compilers then inline the
common append path into the decode loop and call the helper only when
the next value would exceed the 32-bit offset limit.

### Are these changes tested?

Local boundary checks exercised both dictionary and PLAIN decoding with
a value that exactly filled the current chunk, an empty string and a
null at the limit, and a subsequent value that started a new chunk. The
baseline and patched readers also produced matching SHA-256 digests over
the decoded full-table output.

### Are there any user-facing changes?

Single-threaded Parquet reads were faster on a string-heavy table. The
timings below are median wall times for three full scans of the same
four warm-cache files on Linux x86-64 (132,752,584 rows, 10,000 rows per
batch). The baseline was `fbf6c9f846`. The GCC baseline measurement
affected by CPU contention was repeated with the same CPU affinity.

| Release compiler | Before | After | Reduction in scan time |
| --- | ---: | ---: | ---: |
| Clang 17.0.6 | 33.27 s | 29.56 s | 11.2% |
| GCC 11.4.0 | 40.36 s | 29.24 s | 27.6% |

The original upgrade benchmark compared Arrow 17.0.0 and 26.0.1 on the
same four Parquet files. [Paimon C++ benchmark
results](apache/paimon-cpp#598 (comment))

### Was AI used for this PR?

In accordance to the [AI generation
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
please disclose below whether and how AI was used in this PR.

**PR code and description written by:**

- [x] Human
- [x] AI

**Reviewed before submission by:**

- [x] Human
- [x] AI
- [ ] Not reviewed

* GitHub Issue: Closes #55939

Drafted with assistance from OpenAI Codex.

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.

[Feature] Upgrade to Arrow 26.0.1 with C++20 builds and a C++17-compatible public API

4 participants