[Feature] Improve scan performance in hot read paths
- Lenguaje dominante
- C++
- Estrellas
- 65
- Forks
- 25
- Merge medio
- 2 d 12 h
- PR fusionados (30 d)
- 80
Descripción
### 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!
Guía de contribución
Línea de trabajo
Comienza perfilando las llamadas a StructArray::fields() del lector de manifiestos y las llamadas a ArrayBuilder::type() del decodificador Avro en rutas de escaneo concurrentes. Identifica la duración de vida adecuada del batch, reader o builder para los metadatos inmutables de Arrow y, después, verifica que las cachés se invaliden cuando se reemplace el árbol de objetos de Arrow correspondiente. La tarea estará completada cuando se reduzca la sobrecarga de sincronización de shared pointers y del conteo de referencias durante los escaneos concurrentes.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- cpp
- Área
- performance
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Activo
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 35/100