apache / apache/paimon-cpp

[Feature] Improve scan performance in hot read paths

オープン
#240 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
enhancement
主要言語
C++
スター
65
フォーク
25
平均マージ
2日 12時間
マージ済み PR(30日)
80

説明

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/paimon-cpp/issues) and found nothing similar.

### Motivation

Recent profiling of highly concurrent scans has revealed several performance bottlenecks caused by
repeated operations on Arrow-returned `shared_ptr` objects in hot read loops.

Two significant cases have been identified:

1. Manifest readers repeatedly call `StructArray::fields()` while processing individual rows. This
copies `shared_ptr` objects and, with GCC 8.3's libstdc++, can introduce substantial lock
contention through `_Sp_locker`, `pthread_mutex_lock`, and futex waits when multiple workers read
manifests concurrently.

2. Avro decoding calls `ArrayBuilder::type()` for every integer and timestamp value. Because this
method returns `std::shared_ptr` by value, concurrent scans repeatedly modify reference
counts on shared Arrow primitive data types, causing cache-line contention. Profiling showed
`ArrayBuilder::type()` and shared-pointer release operations accounting for a large proportion of
samples after the manifest bottleneck was removed.

This issue tracks the broader effort to identify and eliminate similar shared-pointer operations
from scan hot paths. The goal is to cache immutable Arrow metadata at an appropriate batch, reader,
or builder lifetime, while ensuring caches are invalidated whenever the corresponding Arrow object
tree is replaced.

The expected outcome is lower synchronization and reference-counting overhead under concurrent
scans, allowing CPU time to return to actual decoding, memory copying, and buffer management.

### Solution

_No response_

### Anything else?

_No response_

### Are you willing to submit a PR?

- [x] I'm willing to submit a PR!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、並行スキャンパスにおける manifest reader の StructArray::fields() 呼び出しと Avro decoder の ArrayBuilder::type() 呼び出しをプロファイリングします。不変の Arrow メタデータに適した batch、reader、または builder のライフタイムを特定し、対応する Arrow オブジェクトツリーが置き換えられたときにキャッシュが無効化されることを確認します。完了の条件は、並行スキャン時の shared-pointer の同期と参照カウントにかかるオーバーヘッドが削減されていることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
cpp
領域
performance
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。