GeezerVison is showing github.com — [feat][ml] Configure and track named Pulsar allocators independently by lhotari · Pull Request #26597 · apache/pulsar
Conversation
lhotari
commented
Sep 15, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Builds on #26595, which has merged. This branch has been rebased onto master; the diff now contains only the named-allocator changes.
Motivation
The managed-ledger entry cache needs its own allocator to retain separate allocation statistics, while benefiting from Pulsar's configurable allocator implementation and OOM handling. This also allows cache copies to use the adaptive allocator introduced in #26595. Efficient cache-owned copies are relevant to the BP-62 batch-read work in #25280, where retaining individual entries can retain larger backing buffers.
Modifications
- Introduce a registry that atomically creates one allocator per identifier.
RangeEntryCacheImpl keeps a private ALLOCATOR obtained through PulsarByteBufAllocator.getOrCreate("ml-cache").
- Resolve each setting from
pulsar.allocator.<id>.<setting>, then pulsar.allocator.<setting>, then its built-in default. Supported settings are type, exit_on_oom, and out_of_memory_policy.
- Support
pulsar.allocator.default.* overrides for the default allocator. These overrides do not affect other identifiers. Settings are read when each allocator is first created.
- Preserve separate cache metrics. Generalize the allocation-statistics snapshot for pooled, unpooled, and adaptive allocators, and resolve broker allocator stats through the registry without creating unknown allocators. Adaptive used-memory statistics report
usedDirectMemory(); unavailable allocation counts report -1.
- Use Netty's global leak-detection level. Remove support for
pulsar.allocator.leak_detection; no per-allocator leak-detection setting is introduced.
- Document named configuration and retain the deprecated
pulsar.allocator.pooled fallback introduced in [feat][misc] Support AdaptiveByteBufAllocator with configurable allocator type and metrics #26595.
For example, keep general allocation pooled while enabling adaptive allocation for cache copies:
-Dpulsar.allocator.type=pooled -Dpulsar.allocator.ml-cache.type=adaptive
Verifying this change
- Make sure that the change passes the CI checks.
All 46 scoped tests and quickCheck passed locally:
./gradlew :pulsar-common:test --tests 'org.apache.pulsar.common.allocator.*' \
:managed-ledger:test --tests 'org.apache.bookkeeper.mledger.impl.cache.RangeEntryCacheImplTest' \
:pulsar-broker:test --tests 'org.apache.pulsar.broker.stats.AllocatorStatsGeneratorTest' \
--tests 'org.apache.pulsar.broker.stats.OpenTelemetryManagedLedgerCacheStatsTest' quickCheck
Tests cover concurrent registration, independent heap/direct metrics for all three allocator types, property inheritance and overrides, OOM policies, global leak detection, cache copy ownership, and broker metrics. Shell syntax and whitespace checks also passed.
Does this pull request potentially affect one of the following parts:
- Dependencies (add or upgrade a dependency)
- The public API — adds registry APIs, makes the cache allocator private, moves/generalizes the allocation-statistics helper, and removes the Pulsar leak-detection property constant.
- The schema
- The default values of configurations — named cache allocation uses the selected allocator's standard defaults instead of custom zero heap arenas and caching for all threads; leak detection follows Netty's global setting.
- The threading model
- The binary protocol
- The REST endpoints — allocator stats look up registered identifiers, retaining the response schema.
- The admin CLI options
- The metrics — retain separate cache statistics and support the selected allocator implementation.
- Anything that affects deployment — adds named allocator settings and changes leak-detection configuration to Netty's global property.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Register one allocator per identifier with atomic get-or-create. Named type and OOM settings override unqualified defaults, including overrides for the default allocator. Use Netty global leak detection instead of Pulsar allocator leak settings.
Give the entry cache a private ml-cache allocator from the registry and restore its separate pool metrics. Resolve allocator stats through the registry and share a metric snapshot implementation across JVM and cache reporting for pooled, unpooled, and adaptive allocation.
Validation: 46 scoped allocator, cache, and broker metrics tests; quickCheck; shell syntax checks.
Assisted-by: Codex
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Sep 16, 2026
nodece
pushed a commit
to ascentstream/pulsar
that referenced
this pull request
Oct 13, 2026
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|