GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [improve][broker] Reduce cache retention after reads and apply retention settings at startup by lhotari · Pull Request #26627 · apache/pulsar

Conversation

@lhotari

@lhotari lhotari commented Sep 17, 2026

Copy link
Copy Markdown
Member

Motivation

Recently accessed managed-ledger cache entries currently receive an extra TTL extension by default, even after their expected reads have completed. For consumers keeping up with a topic, this retains already-read entries longer and increases cache occupancy without necessarily serving additional reads.

Disable this recent-access extension by default to reduce that retention. Expected-read retention remains enabled, with up to five TTL extensions for entries with remaining expected reads.

A comparison with 500 producers on separate connections and 20 consumers on one Key_Shared subscription showed the following results. Both configurations used the same broker code, one persistent topic, random keys, unbatched 128-byte messages, unrestricted production with at most 40 outstanding sends per producer, and a 12-million-message receive target. Only the recent-access extension setting differed.

Metric Recent-access extension enabled (true) Disabled (false), two runs
Steady throughput 125,579 msg/s 132,915–134,536 msg/s (+5.8–7.1%)
Mean cached entries 244,426 133,314–135,096 (~45% fewer)
Mean accounted cache size 49.16 MB 26.80–27.17 MB (~45% lower)

Steady throughput uses topic counters after 20 seconds of warmup, includes only intervals with all 500 producers connected, and ends before producers disconnect. Cache size is the cache's accounting of stored data, not total heap usage. Allocation reductions were not consistent. These short runs demonstrate the benefit for this workload; they do not establish the same improvement for multiple subscriptions or lagging consumers.

The broker also accepts two cache retention settings without passing them to the managed-ledger factory during initialization. Dynamic update listeners do not apply initial values, so startup configuration can silently leave the factory's defaults in effect. Correct startup propagation is necessary for the new broker default and for explicit operator settings to take effect.

Modifications

  • Default managedLedgerCacheEvictionExtendTTLOfRecentlyAccessed to false in ServiceConfiguration, broker.conf, and standalone.conf, and update their configuration documentation.
  • Pass managedLedgerCacheEvictionExtendTTLOfRecentlyAccessed and managedLedgerCacheEvictionExtendTTLOfEntriesWithRemainingExpectedReadsMaxTimes to ManagedLedgerFactoryConfig during initialization.
  • Preserve the existing expected-read retention limit of five extensions and dynamic configuration updates. The standalone managed-ledger factory default is unchanged; the broker supplies its configured policy.

Deployments that benefit from retaining recently read entries, such as repeated reads across subscriptions or redelivery, can explicitly set managedLedgerCacheEvictionExtendTTLOfRecentlyAccessed=true to retain the previous policy. Existing configuration files that explicitly set true continue to do so.

Verifying this change

Parameterized tests capture the factory configuration during initialization and verify the new broker default, explicit enable/disable overrides, and expected-read extension limits. The startup propagation regression test fails without the factory assignments.

  • ./gradlew :pulsar-broker:test --tests '*ManagedLedgerClientFactoryTest' -PtestRetryCount=0
  • ./gradlew spotlessCheck checkstyleMain checkstyleTest

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

Broker startup honors both retention settings, and recent-access TTL extension is disabled by default.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lhotari added 2 commits September 17, 2026 13:49
@lhotari
[fix][broker] Apply cache TTL extension settings at startup
08d8705
@lhotari
[improve][broker] Disable recent-access cache TTL extension by default
420645d
@lhotari
lhotari requested review from Technoboy-, dao-jun, merlimat and nodece September 17, 2026 10:52
merlimat
merlimat approved these changes Sep 17, 2026
View reviewed changes
@merlimat
merlimat merged commit bed06a0 into apache:master Sep 17, 2026
44 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@lhotari lhotari mentioned this pull request Sep 17, 2026
[improve][ml] Allow inline read completion and preserve replication order #26620
Merged
4 of 11 tasks
dao-jun pushed a commit to ascentstream/pulsar that referenced this pull request Sep 20, 2026
@lhotari @dao-jun
[improve][broker] Reduce cache retention after reads and apply retent…
5433a35
…ion settings at startup (apache#26627)

(cherry picked from commit bed06a0)
dao-jun pushed a commit to ascentstream/pulsar that referenced this pull request Sep 20, 2026
@lhotari @dao-jun
[improve][broker] Reduce cache retention after reads and apply retent…
ab7a08a
…ion settings at startup (apache#26627)

(cherry picked from commit bed06a0)
dao-jun pushed a commit to ascentstream/pulsar that referenced this pull request Sep 20, 2026
@lhotari @dao-jun
[improve][broker] Reduce cache retention after reads and apply retent…
d88d711
…ion settings at startup (apache#26627)

(cherry picked from commit bed06a0)
dao-jun added a commit to ascentstream/pulsar that referenced this pull request Sep 21, 2026
@dao-jun
Merge branch-as-4.0 into dev/pick_batchread_and_cache
4eb9471
Brings in the base's cursor reset/GC series (checkpoint ledger sweep,
batch-index-ack dirty flagging, failed-flush GC race hardening) and the
persistentUnackedRangesMaxEntrySize startup validation. The only textual
conflict was the add/add on ManagedLedgerClientFactoryTest — resolved by
keeping both sides' tests (apache#26627's cache-extension settings plumbing
tests plus the base's checkpoint maxEntrySize validation tests).
ManagedCursorTest 214/214 and the merged factory test 6/6 green on the
merged tree.
@lhotari lhotari added this to the 5.0.0 milestone Sep 23, 2026
@lhotari lhotari added the release/4.2.5 label Sep 23, 2026
lhotari added a commit that referenced this pull request Sep 23, 2026
@lhotari
[improve][broker] Reduce cache retention after reads and apply retent…
80df050
…ion settings at startup (#26627)

(cherry picked from commit bed06a0)
@lhotari lhotari added the cherry-picked/branch-4.2 label Sep 23, 2026
@dao-jun dao-jun mentioned this pull request Oct 4, 2026
[feat][ml] Port batch read and managed-ledger cache improvements (PIP-430) on BK 4.17.4.1 ascentstream/pulsar#105
Closed
Radiancebobo pushed a commit to Radiancebobo/pulsar that referenced this pull request Oct 8, 2026
@lhotari hechengbo
[improve][broker] Reduce cache retention after reads and apply retent…
35aec6d
…ion settings at startup (apache#26627)
@nodece nodece mentioned this pull request Oct 13, 2026
[feat][ml] Port batch read and managed-ledger cache improvements (PIP-430) on BK 4.17.4.1 (ml-only subset) ascentstream/pulsar#106
Closed
nodece pushed a commit to ascentstream/pulsar that referenced this pull request Oct 13, 2026
@lhotari @nodece
[improve][broker] Reduce cache retention after reads and apply retent…
5e7350b
…ion settings at startup (apache#26627)

(cherry picked from commit bed06a0)
(cherry picked from commit d88d711)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@merlimat merlimat merlimat approved these changes
@nodece nodece Awaiting requested review from nodece
@dao-jun dao-jun Awaiting requested review from dao-jun
@Technoboy- Technoboy- Awaiting requested review from Technoboy-

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cherry-picked/branch-4.2 release/4.2.5

Projects

None yet

Milestone

5.0.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lhotari @merlimat
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.