Skip to content

Conversation

@Gargi-jais11
Copy link
Contributor

What changes were proposed in this pull request?

This PR handles the below case to be fixed:

one volume under threshold and no volumes beyond threshold

Disk1, 30, 100
Disk2, 30, 100
Disk3, 20, 10080 / 300 = 26.7%

Disk1: 30%
Disk2: 30%
Disk3: 20%
Threshold: 10
Disk utilization range (16.7, 36.7)
Out range volume list: NULL

Threshold: 5
Disk utilization range (21.7, 31.7)
Out range volume list: Disk3 

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-14213

How was this patch tested?

Added a new unit Test TestDefaultVolumeChoosingPolicy which covers below test scenarios:

  • One Volume Beyond Threshold, No VolumesUnderThreshold
  • Volumes with two Above And one BelowThreshold
  • All Volumes Within Threshold
  • One Volume Under Threshold No Volumes Above
  • Extreme Imbalance
  • SmallThresholdModerateImbalance
  • Volumes At Threshold Boundaries
  • Multiple volumes above threshold, one below
  • Best destination has low utilization but insufficient space

@Gargi-jais11 Gargi-jais11 marked this pull request as ready for review January 5, 2026 11:37
@Gargi-jais11
Copy link
Contributor Author

@ChenSammi and @szetszwo Please review the patch.

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@Gargi-jais11 , thanks for working on this!

Please see the comments inlined.

@Gargi-jais11
Copy link
Contributor Author

I have completed a comprehensive performance analysis comparing the Old Policy (O(N)Log(N)) vs. the New Policy (O(N^2)) across different cluster sizes (20, 100, and 200 volumes).
Results:
The change drastically improves balancing effectiveness in constrained environments without introducing any performance regression at scale.

Before optimisation:

Created 20 volumes in 16 ms
Performance results for DefaultVolumeChoosingPolicy
Total volumes: 20
Total threads: 10
Threshold(%): 10.0
Total operations: 100000
Volume Pair Chosen operations: 1252
Volume Pair Not Chosen operations: 98748
Failed operations: 0
Total time (ms): 1897
Average time per operation (ns): 18978.46474
Operations per second: 52691.30109836271

Created 100 volumes in 58 ms
Performance results for DefaultVolumeChoosingPolicy
Total volumes: 100
Total threads: 50
Threshold(%): 10.0
Total operations: 500000
Volume Pair Chosen operations: 25249
Volume Pair Not Chosen operations: 474751
Failed operations: 0
Total time (ms): 167566
Average time per operation (ns): 335133.097966
Operations per second: 2983.889105758967

Created 200 volumes in 75 ms
Performance results for DefaultVolumeChoosingPolicy
Total volumes: 200
Total threads: 50
Threshold(%): 10.0
Total operations: 500000
Volume Pair Chosen operations: 53555
Volume Pair Not Chosen operations: 446445
Failed operations: 0
Total time (ms): 360269
Average time per operation (ns): 720539.560926
Operations per second: 1387.8488485973648

After optimisation:

Created 20 volumes in 16 ms
Performance results for DefaultVolumeChoosingPolicy
Total volumes: 20
Total threads: 10
Threshold(%): 10.0
Total operations: 100000
Volume Pair Chosen operations: 6168
Volume Pair Not Chosen operations: 93832
Failed operations: 0
Total time (ms): 1958
Average time per operation (ns): 19583.56348
Operations per second: 51063.229683467194

Created 100 volumes in 59 ms
Performance results for DefaultVolumeChoosingPolicy
Total volumes: 100
Total threads: 50
Threshold(%): 10.0
Total operations: 500000
Volume Pair Chosen operations: 19065
Volume Pair Not Chosen operations: 480935
Failed operations: 0
Total time (ms): 169903
Average time per operation (ns): 339807.85983
Operations per second: 2942.839522606342

Created 200 volumes in 102 ms
Performance results for DefaultVolumeChoosingPolicy
Total volumes: 200
Total threads: 50
Threshold(%): 10.0
Total operations: 500000
Volume Pair Chosen operations: 49133
Volume Pair Not Chosen operations: 450867
Failed operations: 0
Total time (ms): 319351
Average time per operation (ns): 638703.620642
Operations per second: 1565.6714126574684

Copy link
Contributor

@szetszwo szetszwo left a comment

Choose a reason for hiding this comment

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

@Gargi-jais11 , thanks for the update!

+1 the change looks good.

@Gargi-jais11 Gargi-jais11 requested a review from ChenSammi January 7, 2026 05:26
@Gargi-jais11 Gargi-jais11 requested a review from ChenSammi January 7, 2026 05:58
@ChenSammi
Copy link
Contributor

Thanks @Gargi-jais11 , and @szetszwo for review.

@ChenSammi ChenSammi merged commit 4232d21 into apache:HDDS-5713 Jan 7, 2026
44 checks passed
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.

3 participants