Skip to content

perf: avoid shared pointer contention in manifest and Avro decode - #239

Merged
lxy-9602 merged 2 commits into
apache:mainfrom
gripleaf:fix-sharedptr-contention
Aug 24, 2026
Merged

perf: avoid shared pointer contention in manifest and Avro decode#239
lxy-9602 merged 2 commits into
apache:mainfrom
gripleaf:fix-sharedptr-contention

Conversation

@gripleaf

@gripleaf gripleaf commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Purpose

Linked issue: #240

Reduce shared pointer contention in concurrent manifest reads and Avro decoding hot loops.

This change:

  • Caches StructArray::fields() once per batch in ManifestFile::ReadBucketEntries() and
    ObjectsFile<T>::Read(), avoiding repeated copies of shared_ptr<Array> for every row.
  • Caches immutable Arrow builder metadata in AvroDirectDecoder::DecodeContext, including:
    • Arrow type ID.
    • Timestamp time unit.
  • Uses the cached metadata for integer and timestamp decoding instead of calling
    ArrayBuilder::type() for every value.
  • Clears cached builder metadata when SetReadSchema() replaces the builder tree, preventing stale
    entries if builder addresses are reused.
  • Adds Int16 decoding and builder metadata lifecycle coverage.

Tests

  • Built paimon-avro-format-test successfully.
  • Ran the complete Avro unit test suite: 68 tests passed.
  • Ran pre-commit run --files for all changed files: passed.
  • Ran git diff --check: passed.
  • paimon-core-test could not be fully linked because of an unrelated existing Parquet/Arrow API
    mismatch in page_filtered_row_group_reader.cpp: the current Arrow GetColumn overload expects
    const std::vector<int>&, while the existing source passes
    std::shared_ptr<std::unordered_set<int>>.

API and Format

No public API, storage format, or protocol changes.

Documentation

No new user-facing feature or documentation change.

Generative AI tooling

Generated-by: OpenAI Codex (GPT-5)

@gripleaf

Copy link
Copy Markdown
Contributor Author

StructArray shared_ptr lock contention:
image

Avro decoding hot loops:
image

@lxy-9602 lxy-9602 left a comment

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.

LGTM. @zjw1111 , PTAL.

@lxy-9602

Copy link
Copy Markdown
Member

Could you please create a corresponding issue for this PR? For example, if there have recently been several PRs focused on improving scan performance, it would be helpful to open a dedicated issue describing that effort. Thank you!

@zjw1111 zjw1111 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1

@lxy-9602
lxy-9602 merged commit d602c2c into apache:main Aug 24, 2026
16 checks passed
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.

3 participants