Skip to content

[improve][ml] Share immutable publish positions with cached entries - #26526

Merged
lhotari merged 2 commits into
apache:masterfrom
lhotari:lh-perfopt-improve-publish-position-sharing
Sep 10, 2026
Merged

lhotari merged 2 commits into
apache:masterfrom
lhotari:lh-perfopt-improve-publish-position-sharing

Conversation

@lhotari

@lhotari lhotari commented Sep 10, 2026

Copy link
Copy Markdown
Member

Motivation

Cached publish completion creates a position for the cache entry and then another identical immutable position for the last-confirmed state and add callback.

Modifications

Create the completion position before cache insertion and pass it to the existing EntryImpl.create overload taking Position. Reuse the immutable instance for the cache and completion state; preserve uncached, shadow-ledger and rollover paths. Include a pooled-entry position-sharing benchmark and Netty-thread executor.

Verifying this change

Historical pooled-entry JMH reduced cached-path allocation from 64 to 32 B, with CPU effectively flat; uncached allocation remained 32 B. The targeted position allocation disappeared in the full profile, but aggregate broker allocation/CPU were flat. No aggregate gain is claimed. Run the benchmark fork with -Djmh.executor=CUSTOM -Djmh.executor.class=org.apache.pulsar.client.impl.FastThreadLocalBenchmarkExecutor; its runtime guard verifies appropriate threads. No new performance experiments were run for extraction.

Local extraction validation passed: spotlessCheck checkstyleMain checkstyleTest, benchmark compilation, and 19 scoped tests with no failures or skips: org.apache.bookkeeper.mledger.impl.EntryImplTest (10), org.apache.bookkeeper.mledger.impl.ManagedLedgerTest (8), org.apache.bookkeeper.mledger.impl.ShadowManagedLedgerImplTest (1). Retries were disabled; Gradle ran with --max-workers=2 --no-parallel.

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Create the completion position before cache insertion and pass it to the existing EntryImpl.create overload taking Position. Reuse the immutable instance for the cache and completion state; preserve uncached, shadow-ledger and rollover paths. Include a pooled-entry position-sharing benchmark and Netty-thread executor.

Assisted-by: Codex
@lhotari
lhotari merged commit 7bcae18 into apache:master Sep 10, 2026
43 checks passed
@lhotari lhotari added this to the 5.0.0-M2 milestone Sep 12, 2026
dao-jun pushed a commit to ascentstream/pulsar that referenced this pull request Sep 20, 2026
dao-jun pushed a commit to ascentstream/pulsar that referenced this pull request Sep 20, 2026
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Oct 13, 2026
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