aloyszhang opened a new pull request #14488:
URL: https://github.com/apache/pulsar/pull/14488


   ### Motivation
   
   Current the 
[[cacheEvictionTask](https://github.com/apache/pulsar/blob/4532c15ea705d7b88274025beb1c4913e5069d64/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java#L255)](https://github.com/apache/pulsar/blob/4532c15ea705d7b88274025beb1c4913e5069d64/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerFactoryImpl.java#L255)
 will be executed periodically, the period is calculated by 
   
   ```java
     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 
next round.
   
   We can do some optimize 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)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to