ChenSammi commented on code in PR #9858:
URL: https://github.com/apache/ozone/pull/9858#discussion_r2910575341
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/node/TestDiskBalancerPolicyPerformance.java:
##########
@@ -181,90 +177,165 @@ private void testPolicyPerformance(String policyName,
ContainerChoosingPolicy po
for (int i = 0; i < NUM_THREADS; i++) {
executor.submit(() -> {
try {
- long threadStart = System.nanoTime();
- int containerChosen = 0;
- int containerNotChosen = 0;
+ int containerCandidateChosen = 0;
+ int containerCandidateNotChosen = 0;
int failures = 0;
- // Choose a random volume
- HddsVolume srcVolume = volumes.get(rand.nextInt(NUM_VOLUMES));
- HddsVolume destVolume;
-
- do {
- destVolume = volumes.get(rand.nextInt(NUM_VOLUMES));
- } while (srcVolume.equals(destVolume));
for (int j = 0; j < NUM_ITERATIONS; j++) {
+ // Block all volumes except the highest-util (source) - no
destination has space
+ if (rand.nextDouble() < 0.05 && volumes.size() >= 2) {
+ List<HddsVolume> sorted = new ArrayList<>(volumes);
+ sorted.sort(Comparator.comparingDouble(v ->
+ v.getCurrentUsage().getUsedSpace() / (double) Math.max(1,
v.getCurrentUsage().getCapacity())));
+ for (int k = 0; k < sorted.size() - 1; k++) {
+ HddsVolume v = sorted.get(k);
+ long avail = v.getCurrentUsage().getAvailable();
+ if (avail > 0) {
+ v.incCommittedBytes(avail);
+ }
+ }
+ }
+
+ long threadStart = System.nanoTime();
try {
- ContainerData c = policy.chooseContainer(ozoneContainer,
srcVolume,
- destVolume, inProgressContainerIDs, THRESHOLD, volumeSet,
null);
- if (c == null) {
- containerNotChosen++;
+ ContainerCandidate candidate =
pol.chooseVolumesAndContainer(ozoneContainer,
+ volumeSet, deltaMap, inProgressContainerIDs, THRESHOLD);
+
+ if (candidate == null) {
+ containerCandidateNotChosen++;
} else {
- containerChosen++;
+ containerCandidateChosen++;
+ ContainerID chosenId =
ContainerID.valueOf(candidate.getContainerData().getContainerID());
if (inProgressContainerIDs.size() < MAX_IN_PROGRESS) {
-
inProgressContainerIDs.add(ContainerID.valueOf(c.getContainerID()));
+ inProgressContainerIDs.add(chosenId);
}
+ deltaMap.compute(candidate.getSourceVolume(), (k, v) -> (v ==
null ? 0L : v)
+ - candidate.getContainerData().getBytesUsed());
}
} catch (Exception e) {
failures++;
+ } finally {
+ totalTimeNanos.addAndGet(System.nanoTime() - threadStart);
}
}
- long threadEnd = System.nanoTime();
- totalTimeNanos.addAndGet(threadEnd - threadStart);
- containerChosenCount.addAndGet(containerChosen);
- containerNotChosenCount.addAndGet(containerNotChosen);
+ pairChosenCount.addAndGet(containerCandidateChosen);
+ pairNotChosenCount.addAndGet(containerCandidateNotChosen);
failureCount.addAndGet(failures);
} finally {
latch.countDown();
}
});
}
- // Wait max 5 minutes for test completion
assertTrue(latch.await(5, TimeUnit.MINUTES), "Test timed out");
long totalOperations = (long) NUM_THREADS * NUM_ITERATIONS;
- double avgTimePerOp = (double) totalTimeNanos.get() / totalOperations;
- double opsPerSec = totalOperations / (totalTimeNanos.get() /
1_000_000_000.0);
-
- System.out.println("Performance results for " + policyName);
+ int selections = pairChosenCount.get();
+ int noSelection = pairNotChosenCount.get();
+ System.out.println("Performance results for " + testName);
System.out.println("Total volumes: " + NUM_VOLUMES);
System.out.println("Total containers: " + NUM_CONTAINERS);
System.out.println("Total threads: " + NUM_THREADS);
System.out.println("Total operations: " + totalOperations);
- System.out.println("Container Chosen operations: " +
containerChosenCount.get());
- System.out.println("Container Not Chosen operations: " +
containerNotChosenCount.get());
- System.out.println("Failed operations: " + failureCount.get());
+ System.out.println("Container Candidate Chosen (src+dest+container): " +
selections);
Review Comment:
@Gargi-jais11 , could you share the outputs of three
testDiskBalancerPolicyPerformance runs?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]