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 — [pip] PIP-430: Pulsar Broker cache improvements: refactoring eviction and adding a new cache strategy based on expected read count by lhotari · Pull Request #24444 · apache/pulsar

Conversation

@lhotari

@lhotari lhotari commented Jun 23, 2025 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

Motivation

I'd like to propose PIP-430, which addresses performance and
efficiency issues in Pulsar broker's entry cache eviction mechanisms
and introduces a more efficient caching strategy.

The current broker entry cache implementation has several
production-impacting issues. The size-based eviction doesn't guarantee
removal of globally oldest entries, leading to suboptimal cache
utilization. More critically, the timestamp-based eviction iterates
through all ManagedLedgers every 10ms by default, causing high CPU
utilization in brokers with many topics. Mixed read patterns like
tailing, catch-up, and Key_Shared replays break eviction assumptions,
resulting in unnecessary BookKeeper and S3 reads that increase
operational costs.

PIP-430 introduces two main improvements.
First, a centralized eviction mechanism using a global
RangeCacheRemovalQueue that tracks all cached entries in insertion
order. This replaces the expensive per-ledger iteration with a single
periodic task and ensures true oldest-first eviction globally. The
implementation PR for this part is
#24363.
Second, a new "expected read count" cache strategy where entries track
how many active cursors are anticipated to read them. This allows the
cache to intelligently retain entries that have higher utility,
especially in high fan-out catch-up read scenarios and Key_Shared
subscriptions.

The benefits include reduced CPU overhead, improved cache hit rates
through better eviction decisions, and proper handling of diverse read
patterns. The new strategy is configurable via
cacheEvictionByExpectedReadCount (default: true) and maintains full
backward compatibility with no client-facing API changes.

This addresses long-standing performance issues that particularly
affect production deployments with high topic counts or diverse
consumption patterns. The refactored architecture also provides a
solid foundation for future cache optimizations.

The full proposal can be found at: #24444
Rendered PIP document:
https://github.com/lhotari/pulsar/blob/lh-pip-430/pip/pip-430.md

I welcome your feedback and discussion on this proposal. Please share
your thoughts, concerns, or suggestions.

Mailing list discussion: https://lists.apache.org/thread/o1ozbg468kxfd38pxk2ppzsstdnxnok2

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Sorry, something went wrong.

Uh oh!

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

All reactions
@lhotari lhotari added the ready-to-test label Jun 23, 2025
@github-actions github-actions Bot added PIP doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. labels Jun 23, 2025
@lhotari

lhotari commented Jun 23, 2025

Copy link
Copy Markdown
Member Author

Implementation related:

  • First part is implemented in [refactor][ml] Replace cache eviction algorithm with centralized removal queue and job #24363
  • There's a WIP PoC of the second part in [WIP] Add cacheEvictionByExpectedReadCount solution lhotari/pulsar#209
    • This doesn't implement managedLedgerCacheEvictionTimeThresholdMillisMax yet.
All reactions

Sorry, something went wrong.

Uh oh!

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

This was referenced Jun 23, 2025
[Enhancement] Make cursor caching eligibility logic reactive since reads don't get cached until checkCursorsToCacheEntries has been called #23503
Closed
[Enhancement] Improve Pulsar Broker cache defaults to get better out-of-the-box performance #23466
Closed
Shared subscription + Batch messages: consumerFlow trigger reading the same messages from storage #16421
Closed
[refactor][ml] Replace cache eviction algorithm with centralized removal queue and job #24363
Merged
lhotari added 3 commits July 24, 2025 16:52
@lhotari
[pip] PIP-430: Pulsar Broker cache improvements: refactoring eviction…
4b326a4
… and adding a new cache strategy based on expected read count
@lhotari
Add mailing list discussion thread link
16547d5
@lhotari
Add voting thread link
9015330
@lhotari
lhotari force-pushed the lh-pip-430 branch from 951f50b to 9015330 Compare July 24, 2025 13:57
BewareMyPower
BewareMyPower approved these changes Jul 25, 2025
View reviewed changes
@lhotari

lhotari commented Jul 25, 2025

Copy link
Copy Markdown
Member Author

Vote thread https://lists.apache.org/thread/p6jroxhtjpk7hbgqt3hzjtjd2233zmxy

All reactions

Sorry, something went wrong.

Uh oh!

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

codelipenghui
codelipenghui reviewed Jul 26, 2025
View reviewed changes
Comment thread pip/pip-430.md Resolved

Uh oh!

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

@lhotari
lhotari merged commit cf3d7d1 into apache:master Jul 28, 2025
@lhotari

lhotari commented Jul 28, 2025

Copy link
Copy Markdown
Member Author

Vote passed: https://lists.apache.org/thread/4bb3lsztr9j4qvgcdzv6fszdnf6bq7t8

All reactions

Sorry, something went wrong.

Uh oh!

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

@lhotari lhotari mentioned this pull request Jul 28, 2025
lh broker cache expected readcount retention rebase lhotari/pulsar#212
Closed
poorbarcode pushed a commit to poorbarcode/pulsar that referenced this pull request Aug 14, 2025
@lhotari @poorbarcode
[pip] PIP-430: Pulsar Broker cache improvements: refactoring eviction…
1b43ffe
… and adding a new cache strategy based on expected read count (apache#24444)
@coderzc coderzc added this to the 4.1.0 milestone Sep 8, 2025
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
@lhotari @KannarFr
[pip] PIP-430: Pulsar Broker cache improvements: refactoring eviction…
f0941ee
… and adding a new cache strategy based on expected read count (apache#24444)
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
@lhotari @walkinggo
[pip] PIP-430: Pulsar Broker cache improvements: refactoring eviction…
1a69a6f
… and adding a new cache strategy based on expected read count (apache#24444)
@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
@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
[pip] PIP-430: Pulsar Broker cache improvements: refactoring eviction…
c7d18ee
… and adding a new cache strategy based on expected read count (apache#24444)

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

Reviewers

@codelipenghui codelipenghui codelipenghui left review comments
@BewareMyPower BewareMyPower BewareMyPower approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. PIP ready-to-test

Projects

None yet

Milestone

4.1.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@lhotari @codelipenghui @BewareMyPower @coderzc
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.