Skip to content

perf(vindex): size native batches by active indexes - #709

Merged
JingsongLi merged 5 commits into
apache:mainfrom
jerry-024:fix/vindex-native-batch-concurrency
Aug 17, 2026
Merged

perf(vindex): size native batches by active indexes#709
JingsongLi merged 5 commits into
apache:mainfrom
jerry-024:fix/vindex-native-batch-concurrency

Conversation

@jerry-024

@jerry-024 jerry-024 commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Purpose

global-index.thread-num controls index job fan-out and OSS range-read permits. It also reduced the native batch chunk size even when a query had only one active Vindex entry, making the chunk size depend on the configured maximum instead of actual index parallelism.

This PR decouples native batch sizing from range-read concurrency and enforces the 64 MiB native working-set budget process-wide through an admission-controlled memory pool, so larger per-query chunks cannot multiply memory across concurrent queries.

Brief change log

  • Derive Vindex batch parallelism as min(planned index entries, global-index.thread-num), with a minimum of one, and use it to size native batch chunks in both the global-index batch and primary-key vector search paths.
  • Add a process-wide 64 MiB native batch memory pool: each batch chunk reserves its actual working set (filter bytes + queries x per-query bytes) before running and releases it afterwards, so concurrent batch queries interleave per chunk instead of oversubscribing memory. Single-query chunks bypass the pool.
  • Keep global-index.thread-num as the index job and range-read permit limit, including the existing 32-range cap per read batch.
  • Uncontended chunk size and latency are unchanged; under concurrency, chunks from different queries interleave, which may delay individual requests while improving fairness and overall memory behavior.
  • Add coverage for single-entry and multi-entry sizing, the 32-range read boundary, chunk reservations tracking the actual chunk size, and pool admission (a fitting reservation passes immediately; an oversized one waits until bytes are released).

Tests

  • cargo +1.97.0 test -p paimon
  • cargo +1.97.0 clippy -p paimon --lib --tests -- -D warnings
  • cargo +1.97.0 fmt --all -- --check

API and Format

No public API or storage format changes.

Documentation

No documentation changes are required because this does not add or change a user-facing option.

@jerry-024 jerry-024 changed the title perf(vindex): decouple native batch chunk concurrency perf(vindex): size native batches by active indexes Aug 14, 2026
@JingsongLi

Copy link
Copy Markdown
Contributor

When a request to NativeBatchMemoryPool::acquire exceeds the fixed 64 MiB capacity, it waits indefinitely for permits that can never be obtained. This issue—which can be triggered by large filters or a single native batch—poses a risk of production deadlocks. It is recommended that requests exceeding the capacity either exclusively occupy the entire pool or fail immediately, rather than waiting indefinitely.

@JingsongLi JingsongLi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1

@JingsongLi
JingsongLi merged commit 403a2b2 into apache:main Aug 17, 2026
13 checks passed
jerry-024 added a commit to jerry-024/paimon-rust that referenced this pull request Aug 17, 2026
…ead-concurrency

* upstream/main:
  perf(vindex): size native batches by active indexes (apache#709)

# Conflicts:
#	crates/paimon/src/table/vector_search_builder.rs
#	crates/paimon/src/vindex/range_reader.rs
#	crates/paimon/src/vindex/reader.rs
jerry-024 added a commit to jerry-024/paimon-rust that referenced this pull request Aug 17, 2026
* main:
  perf(vindex): size native batches by active indexes (apache#709)
  fix(data-evolution): require row tracking and row IDs (apache#718)
  feat(go): add table write bindings (apache#658)
  fix(scan): preserve Data Evolution file order in row-id groups (apache#717)
  fix(file_index): align file index format with Java V1 (apache#719)
  fix: configure OpenDAL writer chunk size (apache#713)
  fix(python): release GIL during catalog I/O (apache#716)
  feat(write): add fixed-bucket write primitives for postpone tables (apache#659)
  feat: rust examples for creating and querying Paimon tables (apache#648)
  fix(table): reject row ranges for format tables at read construction (apache#700)
  perf(arrow): prune IN predicates with row-group stats (apache#705)
  feat(io): support in-memory local cache (apache#710)
  fix(dlf): refresh expiring credentials (apache#714)
  fix(datafusion): normalize index_type in global index procedures (apache#715)
  fix(auth): fail closed on query-auth tables outside the read boundary (apache#691)

# Conflicts:
#	crates/paimon/src/table/vector_search_builder.rs
#	crates/paimon/src/vindex/reader.rs
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.

2 participants