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] PIP-192 Moved the common broker load data feature(weightedMaxEMA) to BrokerLoadData #19154

Merged
merged 3 commits into from
Jan 18, 2023

Conversation

heesung-sn
Copy link
Contributor

@heesung-sn heesung-sn commented Jan 6, 2023

Master Issue: #16691

Motivation

We will start raising PRs to implement PIP-192, #16691

Modifications

This PR moved the common broker load data feature(weightedMaxEMA) to BrokerLoadData.

As weightedMaxEMA is available in the BrokerLoadData by this change, this PR

  • removed brokerAvgResourceUsageWithWeight in LeastResourceUsageWithWeight -- we don't need to separately compute and store weightedMaxEMA in LeastResourceUsageWithWeight and TransferShedder.

  • refactored BrokerLoadData to precompute the load data features.

  • updated the unit tests.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • Updated unit tests.

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

If the box was checked, please highlight the changes

  • 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
  • Anything that affects deployment

Documentation

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

We will have separate PRs to update the Doc later.

Matching PR in forked repository

PR in forked repository: heesung-sn#20

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 6, 2023
@Demogorgon314 Demogorgon314 self-requested a review January 7, 2023 04:08
final double maxUsageWithWeight =
updateAndGetMaxResourceUsageWithWeight(broker, brokerLoadData, conf, debugMode);

final var maxUsageWithWeight = brokerLoadData.getWeightedMaxEMA();
Copy link
Member

Choose a reason for hiding this comment

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

The weightedMaxEMA can be null. Should we handle the null case here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for this comment.

I changed this weightedMaxEMA to 'double` and set the default value to 1.0.

Ideally, the downstream logics using this BrokerLoadData should not worry if it is updated or not.

Let's ensure we publish BrokerLoadData to the service unit channel only when it has been updated at least once.

Also, accordingly, I cleaned up BrokerLoadData.

final double directMemoryWeight, final double bandwidthInWeight,
final double bandwidthOutWeight) {
return LocalBrokerData.max(cpu.percentUsage() * cpuWeight, memory.percentUsage() * memoryWeight,
directMemory.percentUsage() * directMemoryWeight, bandwidthIn.percentUsage() * bandwidthInWeight,
bandwidthOut.percentUsage() * bandwidthOutWeight) / 100;
}


private void updateWeightedMaxEMA(ServiceConfiguration conf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does EMA mean? Is it better to add a description for "EMA"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an exponential moving average. Updated the comment for the weightedMaxEMA variable.

Comment on lines -104 to -113
if (debugMode) {
log.info(
"Broker {} get max resource usage with weight: {}, history resource percentage: {}%, CPU weight: "
+ "{}, MEMORY weight: {}, DIRECT MEMORY weight: {}, BANDWIDTH IN weight: {}, BANDWIDTH "
+ "OUT weight: {} ",
broker, historyUsage, historyPercentage, conf.getLoadBalancerCPUResourceWeight(),
conf.getLoadBalancerMemoryResourceWeight(), conf.getLoadBalancerDirectMemoryResourceWeight(),
conf.getLoadBalancerBandwithInResourceWeight(),
conf.getLoadBalancerBandwithOutResourceWeight());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the debug log be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. I think we can keep this.

Added BrokerLoadData.toString() and added the debug log.

else if (debugMode) {
            log.info("Broker {} load data:{{}}", broker, brokerLoadData.toString(conf));
        }

@codecov-commenter
Copy link

codecov-commenter commented Jan 18, 2023

Codecov Report

Merging #19154 (5da0aa0) into master (4028ad3) will decrease coverage by 6.42%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19154      +/-   ##
============================================
- Coverage     47.45%   41.04%   -6.42%     
- Complexity    10760    15887    +5127     
============================================
  Files           713     1625     +912     
  Lines         69672   132324   +62652     
  Branches       7482    14564    +7082     
============================================
+ Hits          33063    54312   +21249     
- Misses        32895    72092   +39197     
- Partials       3714     5920    +2206     
Flag Coverage Δ
unittests 41.04% <0.00%> (-6.42%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...er/loadbalance/extensions/data/BrokerLoadData.java 0.00% <0.00%> (ø)
...ensions/strategy/LeastResourceUsageWithWeight.java 0.00% <0.00%> (ø)
...ava/org/apache/pulsar/broker/admin/v1/Brokers.java 0.00% <0.00%> (-100.00%) ⬇️
...va/org/apache/pulsar/broker/admin/v1/Clusters.java 0.00% <0.00%> (-100.00%) ⬇️
.../org/apache/pulsar/broker/admin/v1/Properties.java 0.00% <0.00%> (-100.00%) ⬇️
.../apache/pulsar/broker/admin/v2/ResourceGroups.java 0.00% <0.00%> (-100.00%) ⬇️
...ar/common/naming/PartitionedManagedLedgerInfo.java 0.00% <0.00%> (-100.00%) ⬇️
...naming/RangeEquallyDivideBundleSplitAlgorithm.java 0.00% <0.00%> (-100.00%) ⬇️
...e/pulsar/broker/admin/impl/ResourceQuotasBase.java 0.00% <0.00%> (-96.43%) ⬇️
...he/pulsar/broker/service/AnalyzeBacklogResult.java 0.00% <0.00%> (-92.31%) ⬇️
... and 1133 more

@codelipenghui codelipenghui merged commit 9e7a5c7 into apache:master Jan 18, 2023
@heesung-sn heesung-sn deleted the pip-192-feature-store branch April 2, 2024 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs ready-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants