Skip to content

HBASE-30134: Improve CacheAwareLoadBalancer to consider low cache ratio when calculating imbalance#8197

Open
wchevreuil wants to merge 4 commits intoapache:masterfrom
wchevreuil:HBASE-30134
Open

HBASE-30134: Improve CacheAwareLoadBalancer to consider low cache ratio when calculating imbalance#8197
wchevreuil wants to merge 4 commits intoapache:masterfrom
wchevreuil:HBASE-30134

Conversation

@wchevreuil
Copy link
Copy Markdown
Contributor

No description provided.

wchevreuil added 2 commits May 5, 2026 14:46
…io when calculating imbalance

Change-Id: I0880f137e2e9efe950de021a9e832e240378f9c7
Change-Id: Ie87a60c1a822682786ca6b2bc9ce4b0a86af54ee
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Improves cache-aware balancing by incorporating reported block cache free space and “cold data” region metrics into CacheAwareLoadBalancer’s imbalance calculation, with accompanying protocol/client/server wiring and tests.

Changes:

  • Extend ServerLoad/ServerMetrics to report block cache free bytes and per-region cold data size.
  • Update CacheAwareLoadBalancer cost computation to consider low cache ratios alongside free cache capacity and cold-data adjustments.
  • Add/adjust unit tests and constructors to pass the new metrics through BalancerClusterState.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
hbase-server/src/test/java/org/apache/hadoop/hbase/master/balancer/TestCacheAwareLoadBalancerCostFunctions.java Adds tests and helpers for needsBalance behavior with low cache ratio + free cache space.
hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestRegionsRecoveryChore.java Updates ServerMetrics test stub to implement new cold-data API.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java Populates ServerLoad with cacheFreeSize and regionColdData.
hbase-protocol-shaded/src/main/protobuf/server/ClusterStatus.proto Adds new ServerLoad fields for cacheFreeSize and regionColdData.
hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java Parses/serializes new metrics into ServerMetrics and ServerLoad.
hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetrics.java Adds new ServerMetrics APIs for cacheFreeSize and regionColdDataSize.
hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/TestStoreFileTableSkewCostFunction.java Updates BalancerClusterState ctor usage for new parameter.
hbase-balancer/src/test/java/org/apache/hadoop/hbase/master/balancer/CandidateGeneratorTestUtil.java Updates BalancerClusterState ctor usage for new parameter.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/StochasticLoadBalancer.java Introduces overridable createState() factory for BalancerClusterState.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/CacheAwareLoadBalancer.java Uses cacheFreeSize + cold-data metrics in cache cost heuristics and state creation.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BaseLoadBalancer.java Updates BalancerClusterState ctor usage for new parameter.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerConditionals.java Updates BalancerClusterState ctor usage for new parameter.
hbase-balancer/src/main/java/org/apache/hadoop/hbase/master/balancer/BalancerClusterState.java Stores per-server cache free bytes and exposes observed region cache ratio helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java Outdated
Comment thread hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java Outdated
Comment thread hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetricsBuilder.java Outdated
Comment thread hbase-client/src/main/java/org/apache/hadoop/hbase/ServerMetrics.java Outdated
Comment on lines +1246 to +1247
if (DataTieringManager.getInstance() != null) {
DataTieringManager.getInstance().getRegionColdDataSize()
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, DataTieringManager singleton instance cannot be null once it has been initialised. There's a resetForTestingOnly method, but that's for test purposes only. Besides, even if it was possible to disable DataTieringManager, we wouldn't want to use the stale instance.

Comment on lines +354 to +357
private static List<ServerName>
getServersInInsertionOrder(Map<ServerName, List<RegionInfo>> cluster) {
return new ArrayList<>(cluster.keySet());
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well, we have entire control over the map implementation instance passed from our tests, which is a LinkedHashMap, so no need to worry about this here.

Comment on lines +337 to +339
* Unallocated block cache capacity on this RegionServer, in bytes.
* Used by the master for cache-aware load balancing (optional).
*/
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@wchevreuil wchevreuil requested a review from Copilot May 7, 2026 12:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Change-Id: I2d35abc09cae1c0e9a7d758b90772d4a0c2abb93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants