Apache9 commented on a change in pull request #343: HBASE-22634 : Improve 
performance of BufferedMutator        
URL: https://github.com/apache/hbase/pull/343#discussion_r311535516
 
 

 ##########
 File path: 
hbase-client/src/main/java/org/apache/hadoop/hbase/client/BufferedMutatorImpl.java
 ##########
 @@ -302,11 +348,53 @@ private void doFlush(boolean flushAll) throws 
InterruptedIOException,
         }
         asf = ap.submit(createTask(access));
       }
-      // DON'T do the wait in the try-with-resources. Otherwise, the undealt 
mutations won't
-      // be released.
-      asf.waitUntilDone();
-      if (asf.hasError()) {
-        errors.add(asf.getErrors());
+
+      if (flushAll || writeBufferSize == 0) {
+        // if we have setWriteBufferPeriodicFlushTimeoutMs we may have 
concurrent update
+        List<AsyncRequestFuture> waitList;
+        synchronized(asfList) {
+          waitList = new ArrayList<>(asfList);
+        }
+        // DON'T do the wait in the try-with-resources. Otherwise, the undealt 
mutations won't
+        // be released.
+        for(AsyncRequestFuture toWait:waitList) {
+          toWait.waitUntilDone();
+          if (toWait.hasError()) {
+            errors.add(toWait.getErrors());
+          }
+        }
+        synchronized(asfList) {
+          asfList.removeAll(waitList);
+        }
+        asf.waitUntilDone();
+        if (asf.hasError()) {
+          errors.add(asf.getErrors());
+        }
+      } else {
+        // Do some cleanup in asfList to decrease memory
+        int nbRemoved = 0;
+        while (asfList.size() >= maxThreads*4) {
 
 Review comment:
   Here we get size out of synchornized?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to