Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improve][broker] refactor ManagedLedger cacheEvictionTask implement #14488

Merged
merged 4 commits into from
Jul 29, 2022

Conversation

aloyszhang
Copy link
Contributor

@aloyszhang aloyszhang commented Feb 28, 2022

Motivation

Current the cacheEvictionTask


will be executed periodically, the period is calculated by

  double evictionFrequency = Math.max(Math.min(config.getCacheEvictionFrequency(), 1000.0), 0.001);
  long waitTimeMillis = (long) (1000 / evictionFrequency);

And this task will be executed once and then sleep waitTimeMillis before the next round.

We can do some optimizes for this logic.

Modifications

  1. Set the cache eviction task interval directly by addint a new configuration managedLedgerCacheEvictionIntervalMs
  2. use a ScheduledExecutorService to execute the cache eviction task every managedLedgerCacheEvictionIntervalMs

Verifying this change

This change is already covered by existing tests, such as (please describe tests).

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

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): ( no)
  • The public API: (no)
  • The schema: (no )
  • The default values of configurations: ( no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • no-need-doc

    (Please explain why)

@github-actions
Copy link

@aloyszhang:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions
Copy link

@aloyszhang:Thanks for providing doc info!

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Feb 28, 2022
@codelipenghui codelipenghui added this to the 2.11.0 milestone Feb 28, 2022
@codelipenghui
Copy link
Contributor

Hi @aloyszhang Do we have an email discussion for the new configuration? Please add the discussion link to the PR description, so that we can push forward this PR.

@aloyszhang
Copy link
Contributor Author

aloyszhang commented Mar 16, 2022

@codelipenghui , Sorry for being late, I have sent the discussion email right now.

Discuss thread: https://lists.apache.org/thread/wryzorp7jt6511jt25cv7mss4lz3r1bt

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@github-actions
Copy link

github-actions bot commented May 8, 2022

The pr had no activity for 30 days, mark with Stale label.

@github-actions
Copy link

github-actions bot commented Jun 7, 2022

The pr had no activity for 30 days, mark with Stale label.

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@github-actions github-actions bot removed the Stale label Jun 16, 2022
@codelipenghui codelipenghui added this to the 2.12.0 milestone Jul 26, 2022
@lhotari
Copy link
Member

lhotari commented Jul 26, 2022

It would be good to fix #16054 before changing the cache.

@codelipenghui codelipenghui modified the milestones: 2.12.0, 2.11.0 Jul 26, 2022
@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang
Copy link
Contributor Author

It would be good to fix #16054 before changing the cache.

@lhotari This pull request just refactors the eviction from an eviction and sleep loop to a regularly scheduled task and does not change any logic of the eviction task. IMO, this PR does not relate to #16054

Copy link
Member

@mattisonchao mattisonchao left a comment

Choose a reason for hiding this comment

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

LGTM, I left some little questions. I hope you can answer.

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@Technoboy- Technoboy- added type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages area/broker and removed lifecycle/stale labels Jul 29, 2022
@Technoboy- Technoboy- changed the title refactor ManagedLedger cacheEvictionTask implement [improve][broker] refactor ManagedLedger cacheEvictionTask implement Jul 29, 2022
@Technoboy- Technoboy- merged commit 3619edc into apache:master Jul 29, 2022
@michaeljmarshall
Copy link
Member

michaeljmarshall commented Aug 9, 2022

Was this discussed on the mailing list? I did a quick search and couldn't find a thread on the topic. It's especially important to give this PR visibility because it changed the names of configuration in a breaking way.

We can do some optimizes for this logic.

@aloyszhang - did you benchmark this change? I thought the previous implementation was intentionally designed to decrease GC overhead.

@lhotari
Copy link
Member

lhotari commented Aug 25, 2022

It would be good to fix #16054 before changing the cache.

@lhotari This pull request just refactors the eviction from an eviction and sleep loop to a regularly scheduled task and does not change any logic of the eviction task. IMO, this PR does not relate to #16054

@aloyszhang I was just trying to get the most critical problem of the broker cache (#16054) fixed before we do any other changes. I have now pushed a fix in #17273 . Please review since it should make a difference for heavy users of Pulsar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.9.4 release/2.10.3 type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.