You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Gargi-jais11 (via GitHub)" <gi...@apache.org> on 2025/05/27 09:23:58 UTC

[PR] HDDS-13055. [DiskBalancer] Add micro benchmark to test container choosing efficiency [ozone]

Gargi-jais11 opened a new pull request, #8512:
URL: https://github.com/apache/ozone/pull/8512

   ## What changes were proposed in this pull request?
   This JIRA tracks the addition of a micro-benchmark test to evaluate the performance and efficiency of container selection logic in DiskBalancer.
   There is no any code changes in this PR.
   
   Test Scenario: Test the container choosing efficiency.
   SetUp:
   Set up a cluster with one DN with 20 volume, and total 100 containers.
   Then run the diskbalancer command to test the container choosing efficiency. 
   Expected Behaviour: 
   Containers should be effectively chosen for balancing. No empty containers, open containers, containers under replication and container balancing containers should not be chosen.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-13055
   
   ## How was this patch tested?
   
   Ran performance test.
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Add micro benchmark to test container choosing efficiency [ozone]

Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2911835344

   This is the performance result.
   
   ```
   Performance results for ContainerChoosingPolicy
   Total operations: 1000000
   Container Chosen operations: 997001
   Container Not Chosen operations: 2999
   Failed operations: 0
   Total time (ms): 605816
   Average time per operation (ns): 605816.981669
   Operations per second: 1650.663534133762
   
   Performance results for ContainerChoosingPolicy
   Total operations: 1000000
   Container Chosen operations: 997240
   Container Not Chosen operations: 2760
   Failed operations: 0
   Total time (ms): 757996
   Average time per operation (ns): 757996.525241
   Operations per second: 1319.2672613928628
   
   Performance results for ContainerChoosingPolicy
   Total operations: 1000000
   Container Chosen operations: 997314
   Container Not Chosen operations: 2686
   Failed operations: 0
   Total time (ms): 816210
   Average time per operation (ns): 816210.112668
   Operations per second: 1225.1747245954034
   ```


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2968822330

   Thanks @Gargi-jais11 for the contribution and @symious for the review. 


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Add micro benchmark to test container choosing efficiency [ozone]

Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2911821368

   ```
   public class TestContainerChoosingPolicyPerformance {
   
     private static final int NUM_VOLUMES = 20;
     private static final int NUM_CONTAINERS = 1000000;
     private static final int NUM_THREADS = 100;
     private static final int NUM_ITERATIONS = 10000;
   
     private static final OzoneConfiguration CONF = new OzoneConfiguration();
   
     @TempDir
     private Path baseDir;
   
     private List<HddsVolume> volumes;
     private Collection<Container<?>> containers;
     private OzoneContainer ozoneContainer;
     private ContainerChoosingPolicy containerChoosingPolicy;
     private ExecutorService executor;
     private ContainerController containerController;
   
     // Simulate containers currently being balanced (in progress)
     private Set<Long> inProgressContainerIDs = ConcurrentHashMap.newKeySet();
   
     @BeforeEach
     public void setup() throws Exception {
       containers = new ArrayList<>();
       createVolumes(); //create 20 volumes
       createContainers(); //create 1 million containers with 1000 open rest closed
       ozoneContainer = mock(OzoneContainer.class);
       containerController = mock(ContainerController.class);
       when(ozoneContainer.getController()).thenReturn(containerController);
   
       // Mock containerController to return containers for a given volume
       for (HddsVolume volume : volumes) {
         List<Container<?>> volumeContainers = new ArrayList<>();
         for (Container<?> container : containers) {
           if (container.getContainerData().getVolume().equals(volume)) {
             volumeContainers.add(container);
           }
         }
         when(containerController.getContainers(volume)).thenReturn(volumeContainers.iterator());
       }
   
       containerChoosingPolicy = new DefaultContainerChoosingPolicy();
       executor = Executors.newFixedThreadPool(NUM_THREADS);
     }
   
     // @AfterEach
     public void cleanUp() {
       volumes.forEach(HddsVolume::shutdown);
   
       // Shutdown executor service
       if (executor != null && !executor.isShutdown()) {
         executor.shutdownNow();
       }
   
       // Clear containers and in-progress container IDs
       if (containers != null) {
         containers.clear();
       }
       inProgressContainerIDs.clear();
     }
   
     @Test
     public void testConcurrentVolumeChoosing() throws Exception {
       for (int i = 0; i < 3; i++) {
         setup();
         testPolicyPerformance("ContainerChoosingPolicy", containerChoosingPolicy);
         cleanUp();
       }
     }
   
     /*
      * SuccessCount: Number of successful container choices from the policy.
      * FailureCount: Failures due to any exceptions thrown during container choice.
      */
     private void testPolicyPerformance(String policyName, ContainerChoosingPolicy policy) throws Exception {
       CountDownLatch latch = new CountDownLatch(NUM_THREADS);
       AtomicInteger containerChosenCount = new AtomicInteger(0);
       AtomicInteger containerNotChosenCount = new AtomicInteger(0);
       AtomicInteger failureCount = new AtomicInteger(0);
       AtomicLong totalTimeNanos = new AtomicLong(0);
   
       Random rand = new Random();
   
       for (int i = 0; i < NUM_THREADS; i++) {
         executor.submit(() -> {
           try {
             long threadStart = System.nanoTime();
             int containerChosen = 0;
             int containerNotChosen = 0;
             int failures = 0;
   
             for (int j = 0; j < NUM_ITERATIONS; j++) {
               try {
                 // Choose a random volume
                 HddsVolume volume = volumes.get(rand.nextInt(NUM_VOLUMES));
                 ContainerData c = policy.chooseContainer(ozoneContainer, volume, inProgressContainerIDs);
                 if (c == null) {
                   containerNotChosen++;
                   inProgressContainerIDs.add(c.getContainerID());
                 } else {
                   containerChosen++;
                 }
               } catch (Exception e) {
                 failures++;
               }
             }
   
             long threadEnd = System.nanoTime();
             totalTimeNanos.addAndGet(threadEnd - threadStart);
             containerChosenCount.addAndGet(containerChosen);
             containerNotChosenCount.addAndGet(containerNotChosen);
             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);
       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("Total time (ms): " + totalTimeNanos.get() / 1_000_000);
       System.out.println("Average time per operation (ns): " + avgTimePerOp);
       System.out.println("Operations per second: " + opsPerSec);
     }
   
     public void createVolumes() throws IOException {
       // Create volumes with mocked space usage
       volumes = new ArrayList<>();
       for (int i = 0; i < NUM_VOLUMES; i++) {
         String volumePath = baseDir.resolve("disk" + i).toString();
         SpaceUsageSource source = MockSpaceUsageSource.fixed(1000000000, 1000000000 - i * 50000);
         SpaceUsageCheckFactory factory = MockSpaceUsageCheckFactory.of(
             source, Duration.ZERO, SpaceUsagePersistence.None.INSTANCE);
         HddsVolume volume = new HddsVolume.Builder(volumePath)
             .conf(CONF)
             .usageCheckFactory(factory)
             .build();
         volumes.add(volume);
       }
     }
   
     public void createContainers() {
       List<Long> closedContainerIDs = new ArrayList<>();
       Random random = new Random();
   
       for (int i = 0; i < NUM_CONTAINERS; i++) {
         boolean isOpen = i < 1000; // First 1000 containers are open
         int volumeIndex = i % NUM_VOLUMES; // Distribute containers across volumes
         HddsVolume volume = volumes.get(volumeIndex);
   
         KeyValueContainerData containerData = new KeyValueContainerData(
             i, ContainerLayoutVersion.FILE_PER_BLOCK , ContainerTestHelper.CONTAINER_MAX_SIZE,
             UUID.randomUUID().toString(), UUID.randomUUID().toString());
   
         containerData.setState(isOpen ? ContainerDataProto.State.OPEN : ContainerDataProto.State.CLOSED);
         containerData.setVolume(volume);
   
         KeyValueContainer container = new KeyValueContainer(containerData, CONF);
   
         containers.add(container);
   
         // Collect IDs of closed containers
         if (!isOpen) {
           closedContainerIDs.add((long) i);
         }
       }
   
       // Randomly select 1000 closed containers to be in-progress
       Collections.shuffle(closedContainerIDs, random);
       inProgressContainerIDs.addAll(closedContainerIDs.subList(0, 1000));
     }
   }
   ```


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2947960566

   Without optimization
   
   Created 100000 containers in 2066 ms
   Performance results for ContainerChoosingPolicy
   Total volumes: 20
   Total containers: 100000
   Total threads: 10
   Total operations: 100000
   Container Chosen operations: 100000
   Container Not Chosen operations: 0
   Failed operations: 0
   Total time (ms): 1163929
   Average time per operation (ns): 1.1639291495E7
   Operations per second: 85.91588245981977
   
   
   With optimization
   
   Created 100000 containers in 2142 ms
   Performance results for ContainerChoosingPolicy
   Total volumes: 20
   Total containers: 100000
   Total threads: 10
   Total operations: 100000
   Container Chosen operations: 99983
   Container Not Chosen operations: 17
   Failed operations: 0
   Total time (ms): 1593
   Average time per operation (ns): 15932.3675
   Operations per second: 62765.31093072012
   
   
   
   Created 100000 containers in 2235 ms
   Performance results for ContainerChoosingPolicy
   Total volumes: 20
   Total containers: 100000
   Total threads: 10
   Total operations: 1000000
   Container Chosen operations: 999803
   Container Not Chosen operations: 197
   Failed operations: 0
   Total time (ms): 4607
   Average time per operation (ns): 4607.252501
   Operations per second: 217049.0980867558
   
   
   Created 500000 containers in 9831 ms
   Performance results for ContainerChoosingPolicy
   Total volumes: 20
   Total containers: 500000
   Total threads: 10
   Total operations: 1000000
   Container Chosen operations: 999962
   Container Not Chosen operations: 38
   Failed operations: 0
   Total time (ms): 5890
   Average time per operation (ns): 5890.142792
   Operations per second: 169775.1710464815
   
   
   Created 1000000 containers in 19750 ms
   Performance results for ContainerChoosingPolicy
   Total volumes: 20
   Total containers: 1000000
   Total threads: 10
   Total operations: 1000000
   Container Chosen operations: 999983
   Container Not Chosen operations: 17
   Failed operations: 0
   Total time (ms): 7550
   Average time per operation (ns): 7550.438456
   Operations per second: 132442.6396993335
   
   Created 2000000 containers in 40490 ms
   Performance results for ContainerChoosingPolicy
   Total volumes: 20
   Total containers: 2000000
   Total threads: 10
   Total operations: 1000000
   Container Chosen operations: 999996
   Container Not Chosen operations: 4
   Failed operations: 0
   Total time (ms): 6536
   Average time per operation (ns): 6536.22117
   Operations per second: 152993.59889928572
   


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2947960891

   Hi @symious, could you take a look?  


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "symious (via GitHub)" <gi...@apache.org>.
symious commented on code in PR #8512:
URL: https://github.com/apache/ozone/pull/8512#discussion_r2131434659


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultContainerChoosingPolicy.java:
##########
@@ -33,18 +38,33 @@ public class DefaultContainerChoosingPolicy implements ContainerChoosingPolicy {
   public static final Logger LOG = LoggerFactory.getLogger(
       DefaultContainerChoosingPolicy.class);
 
+  private final ThreadLocal<Cache<HddsVolume, Iterator<Container<?>>>> containerIteratorCache =

Review Comment:
   Can change to static here.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on code in PR #8512:
URL: https://github.com/apache/ozone/pull/8512#discussion_r2131441366


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultContainerChoosingPolicy.java:
##########
@@ -33,18 +38,33 @@ public class DefaultContainerChoosingPolicy implements ContainerChoosingPolicy {
   public static final Logger LOG = LoggerFactory.getLogger(
       DefaultContainerChoosingPolicy.class);
 
+  private final ThreadLocal<Cache<HddsVolume, Iterator<Container<?>>>> containerIteratorCache =

Review Comment:
   Can we get any benefit by change it to static? 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Add micro benchmark to test container choosing efficiency [ozone]

Posted by "Gargi-jais11 (via GitHub)" <gi...@apache.org>.
Gargi-jais11 commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2911828413

   > ```
   > public class TestContainerChoosingPolicyPerformance {
   > 
   >   private static final int NUM_VOLUMES = 20;
   >   private static final int NUM_CONTAINERS = 1000000;
   >   private static final int NUM_THREADS = 100;
   >   private static final int NUM_ITERATIONS = 10000;
   > 
   >   private static final OzoneConfiguration CONF = new OzoneConfiguration();
   > 
   >   @TempDir
   >   private Path baseDir;
   > 
   >   private List<HddsVolume> volumes;
   >   private Collection<Container<?>> containers;
   >   private OzoneContainer ozoneContainer;
   >   private ContainerChoosingPolicy containerChoosingPolicy;
   >   private ExecutorService executor;
   >   private ContainerController containerController;
   > 
   >   // Simulate containers currently being balanced (in progress)
   >   private Set<Long> inProgressContainerIDs = ConcurrentHashMap.newKeySet();
   > 
   >   @BeforeEach
   >   public void setup() throws Exception {
   >     containers = new ArrayList<>();
   >     createVolumes(); //create 20 volumes
   >     createContainers(); //create 1 million containers with 1000 open rest closed
   >     ozoneContainer = mock(OzoneContainer.class);
   >     containerController = mock(ContainerController.class);
   >     when(ozoneContainer.getController()).thenReturn(containerController);
   > 
   >     // Mock containerController to return containers for a given volume
   >     for (HddsVolume volume : volumes) {
   >       List<Container<?>> volumeContainers = new ArrayList<>();
   >       for (Container<?> container : containers) {
   >         if (container.getContainerData().getVolume().equals(volume)) {
   >           volumeContainers.add(container);
   >         }
   >       }
   >       when(containerController.getContainers(volume)).thenReturn(volumeContainers.iterator());
   >     }
   > 
   >     containerChoosingPolicy = new DefaultContainerChoosingPolicy();
   >     executor = Executors.newFixedThreadPool(NUM_THREADS);
   >   }
   > 
   >   // @AfterEach
   >   public void cleanUp() {
   >     volumes.forEach(HddsVolume::shutdown);
   > 
   >     // Shutdown executor service
   >     if (executor != null && !executor.isShutdown()) {
   >       executor.shutdownNow();
   >     }
   > 
   >     // Clear containers and in-progress container IDs
   >     if (containers != null) {
   >       containers.clear();
   >     }
   >     inProgressContainerIDs.clear();
   >   }
   > 
   >   @Test
   >   public void testConcurrentVolumeChoosing() throws Exception {
   >     for (int i = 0; i < 3; i++) {
   >       setup();
   >       testPolicyPerformance("ContainerChoosingPolicy", containerChoosingPolicy);
   >       cleanUp();
   >     }
   >   }
   > 
   >   /*
   >    * SuccessCount: Number of successful container choices from the policy.
   >    * FailureCount: Failures due to any exceptions thrown during container choice.
   >    */
   >   private void testPolicyPerformance(String policyName, ContainerChoosingPolicy policy) throws Exception {
   >     CountDownLatch latch = new CountDownLatch(NUM_THREADS);
   >     AtomicInteger containerChosenCount = new AtomicInteger(0);
   >     AtomicInteger containerNotChosenCount = new AtomicInteger(0);
   >     AtomicInteger failureCount = new AtomicInteger(0);
   >     AtomicLong totalTimeNanos = new AtomicLong(0);
   > 
   >     Random rand = new Random();
   > 
   >     for (int i = 0; i < NUM_THREADS; i++) {
   >       executor.submit(() -> {
   >         try {
   >           long threadStart = System.nanoTime();
   >           int containerChosen = 0;
   >           int containerNotChosen = 0;
   >           int failures = 0;
   > 
   >           for (int j = 0; j < NUM_ITERATIONS; j++) {
   >             try {
   >               // Choose a random volume
   >               HddsVolume volume = volumes.get(rand.nextInt(NUM_VOLUMES));
   >               ContainerData c = policy.chooseContainer(ozoneContainer, volume, inProgressContainerIDs);
   >               if (c == null) {
   >                 containerNotChosen++;
   >                 inProgressContainerIDs.add(c.getContainerID());
   >               } else {
   >                 containerChosen++;
   >               }
   >             } catch (Exception e) {
   >               failures++;
   >             }
   >           }
   > 
   >           long threadEnd = System.nanoTime();
   >           totalTimeNanos.addAndGet(threadEnd - threadStart);
   >           containerChosenCount.addAndGet(containerChosen);
   >           containerNotChosenCount.addAndGet(containerNotChosen);
   >           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);
   >     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("Total time (ms): " + totalTimeNanos.get() / 1_000_000);
   >     System.out.println("Average time per operation (ns): " + avgTimePerOp);
   >     System.out.println("Operations per second: " + opsPerSec);
   >   }
   > 
   >   public void createVolumes() throws IOException {
   >     // Create volumes with mocked space usage
   >     volumes = new ArrayList<>();
   >     for (int i = 0; i < NUM_VOLUMES; i++) {
   >       String volumePath = baseDir.resolve("disk" + i).toString();
   >       SpaceUsageSource source = MockSpaceUsageSource.fixed(1000000000, 1000000000 - i * 50000);
   >       SpaceUsageCheckFactory factory = MockSpaceUsageCheckFactory.of(
   >           source, Duration.ZERO, SpaceUsagePersistence.None.INSTANCE);
   >       HddsVolume volume = new HddsVolume.Builder(volumePath)
   >           .conf(CONF)
   >           .usageCheckFactory(factory)
   >           .build();
   >       volumes.add(volume);
   >     }
   >   }
   > 
   >   public void createContainers() {
   >     List<Long> closedContainerIDs = new ArrayList<>();
   >     Random random = new Random();
   > 
   >     for (int i = 0; i < NUM_CONTAINERS; i++) {
   >       boolean isOpen = i < 1000; // First 1000 containers are open
   >       int volumeIndex = i % NUM_VOLUMES; // Distribute containers across volumes
   >       HddsVolume volume = volumes.get(volumeIndex);
   > 
   >       KeyValueContainerData containerData = new KeyValueContainerData(
   >           i, ContainerLayoutVersion.FILE_PER_BLOCK , ContainerTestHelper.CONTAINER_MAX_SIZE,
   >           UUID.randomUUID().toString(), UUID.randomUUID().toString());
   > 
   >       containerData.setState(isOpen ? ContainerDataProto.State.OPEN : ContainerDataProto.State.CLOSED);
   >       containerData.setVolume(volume);
   > 
   >       KeyValueContainer container = new KeyValueContainer(containerData, CONF);
   > 
   >       containers.add(container);
   > 
   >       // Collect IDs of closed containers
   >       if (!isOpen) {
   >         closedContainerIDs.add((long) i);
   >       }
   >     }
   > 
   >     // Randomly select 1000 closed containers to be in-progress
   >     Collections.shuffle(closedContainerIDs, random);
   >     inProgressContainerIDs.addAll(closedContainerIDs.subList(0, 1000));
   >   }
   > }
   > ```
   
   This is the Micro benchmark performance test for container choosing policy in diskBalancer.


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi merged PR #8512:
URL: https://github.com/apache/ozone/pull/8512


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Add micro benchmark to test container choosing efficiency [ozone]

Posted by "ChenSammi (via GitHub)" <gi...@apache.org>.
ChenSammi commented on PR #8512:
URL: https://github.com/apache/ozone/pull/8512#issuecomment-2915567126

   @Gargi-jais11 , please commit TestContainerChoosingPolicyPerformance with a smaller NUM_CONTAINERS. 
   
   About the TestContainerChoosingPolicyPerformance,
   1.  Don't mock the containerController.getContainers(volume) call
   2. inProgressContainerIDs.add incorrect place. 


-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org


Re: [PR] HDDS-13055. [DiskBalancer] Optimize DefaultContainerChoosingPolicy performance [ozone]

Posted by "symious (via GitHub)" <gi...@apache.org>.
symious commented on code in PR #8512:
URL: https://github.com/apache/ozone/pull/8512#discussion_r2131794230


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/diskbalancer/policy/DefaultContainerChoosingPolicy.java:
##########
@@ -33,18 +38,33 @@ public class DefaultContainerChoosingPolicy implements ContainerChoosingPolicy {
   public static final Logger LOG = LoggerFactory.getLogger(
       DefaultContainerChoosingPolicy.class);
 
+  private final ThreadLocal<Cache<HddsVolume, Iterator<Container<?>>>> containerIteratorCache =

Review Comment:
   Better use static for ThreadLocal variables to make sure it's single instance.



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org