You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/01/30 15:41:35 UTC

svn commit: r1656031 - in /lucene/dev/branches/branch_5x/lucene/core/src: java/org/apache/lucene/index/ test/org/apache/lucene/index/

Author: mikemccand
Date: Fri Jan 30 14:41:35 2015
New Revision: 1656031

URL: http://svn.apache.org/r1656031
Log:
LUCENE-6209: IndexWriter now logs (to infoStream) how much time flushing threads were stalled because of > 2X IW's RAM buffer in flush backlog

Modified:
    lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
    lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterStallControl.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java?rev=1656031&r1=1656030&r2=1656031&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java Fri Jan 30 14:41:35 2015
@@ -76,7 +76,7 @@ final class DocumentsWriterFlushControl
 
   DocumentsWriterFlushControl(DocumentsWriter documentsWriter, LiveIndexWriterConfig config, BufferedUpdatesStream bufferedUpdatesStream) {
     this.infoStream = config.getInfoStream();
-    this.stallControl = new DocumentsWriterStallControl();
+    this.stallControl = new DocumentsWriterStallControl(config);
     this.perThreadPool = documentsWriter.perThreadPool;
     this.flushPolicy = documentsWriter.flushPolicy;
     this.config = config;

Modified: lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterStallControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterStallControl.java?rev=1656031&r1=1656030&r2=1656031&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterStallControl.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterStallControl.java Fri Jan 30 14:41:35 2015
@@ -20,6 +20,7 @@ import java.util.IdentityHashMap;
 import java.util.Map;
 
 import org.apache.lucene.index.DocumentsWriterPerThreadPool.ThreadState;
+import org.apache.lucene.util.InfoStream;
 import org.apache.lucene.util.ThreadInterruptedException;
 
 /**
@@ -43,6 +44,11 @@ final class DocumentsWriterStallControl
   private int numWaiting; // only with assert
   private boolean wasStalled; // only with assert
   private final Map<Thread, Boolean> waiting = new IdentityHashMap<>(); // only with assert
+  private final InfoStream infoStream;
+
+  DocumentsWriterStallControl(LiveIndexWriterConfig iwc) {
+    infoStream = iwc.getInfoStream();
+  }
   
   /**
    * Update the stalled flag status. This method will set the stalled flag to
@@ -85,8 +91,13 @@ final class DocumentsWriterStallControl
     return stalled;
   }
   
-  
+  long stallStartNS;
+
   private void incWaiters() {
+    stallStartNS = System.nanoTime();
+    if (infoStream.isEnabled("DW") && numWaiting == 0) {
+      infoStream.message("DW", "now stalling flushes");
+    }
     numWaiting++;
     assert waiting.put(Thread.currentThread(), Boolean.TRUE) == null;
     assert numWaiting > 0;
@@ -96,6 +107,10 @@ final class DocumentsWriterStallControl
     numWaiting--;
     assert waiting.remove(Thread.currentThread()) != null;
     assert numWaiting >= 0;
+    if (infoStream.isEnabled("DW") && numWaiting == 0) {
+      long stallEndNS = System.nanoTime();
+      infoStream.message("DW", "done stalling flushes for " + ((stallEndNS - stallStartNS)/1000000.0) + " ms");
+    }
   }
   
   synchronized boolean hasBlocked() { // for tests

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java?rev=1656031&r1=1656030&r2=1656031&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java Fri Jan 30 14:41:35 2015
@@ -33,7 +33,7 @@ import org.apache.lucene.util.ThreadInte
 public class TestDocumentsWriterStallControl extends LuceneTestCase {
   
   public void testSimpleStall() throws InterruptedException {
-    DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();
+    DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl(newIndexWriterConfig());
    
     ctrl.updateStalled(false);
     Thread[] waitThreads = waitThreads(atLeast(1), ctrl);
@@ -55,7 +55,7 @@ public class TestDocumentsWriterStallCon
   }
   
   public void testRandom() throws InterruptedException {
-    final DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();
+    final DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl(newIndexWriterConfig());
     ctrl.updateStalled(false);
     
     Thread[] stallThreads = new Thread[atLeast(3)];
@@ -96,7 +96,7 @@ public class TestDocumentsWriterStallCon
   }
   
   public void testAccquireReleaseRace() throws InterruptedException {
-    final DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl();
+    final DocumentsWriterStallControl ctrl = new DocumentsWriterStallControl(newIndexWriterConfig());
     ctrl.updateStalled(false);
     final AtomicBoolean stop = new AtomicBoolean(false);
     final AtomicBoolean checkPoint = new AtomicBoolean(true);