lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dor...@apache.org
Subject svn commit: r576786 - in /lucene/java/trunk/contrib/benchmark: ./ src/java/org/apache/lucene/benchmark/byTask/tasks/ src/test/org/apache/lucene/benchmark/byTask/
Date Tue, 18 Sep 2007 09:05:11 GMT
Author: doronc
Date: Tue Sep 18 02:05:06 2007
New Revision: 576786

URL: http://svn.apache.org/viewvc?rev=576786&view=rev
Log:
LUCENE-941: benchmark: infinite loop for alg: {[AddDoc(4000)]: 4} : *

Modified:
    lucene/java/trunk/contrib/benchmark/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
    lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java

Modified: lucene/java/trunk/contrib/benchmark/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/CHANGES.txt?rev=576786&r1=576785&r2=576786&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/benchmark/CHANGES.txt Tue Sep 18 02:05:06 2007
@@ -4,8 +4,8 @@
 
 $Id:$
 
-8/15/07
-  LUCENE-
+9/18/07
+  LUCENE-941: infinite loop for alg: {[AddDoc(4000)]: 4} : *
 
 8/9/07
   LUCENE-971: Change enwiki tasks to a doc maker (extending

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java?rev=576786&r1=576785&r2=576786&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemEraseTask.java
Tue Sep 18 02:05:06 2007
@@ -28,7 +28,7 @@
  * Index is erased.
  * Directory is erased.
  */
-public class ResetSystemEraseTask extends PerfTask {
+public class ResetSystemEraseTask extends ResetSystemSoftTask {
 
   public ResetSystemEraseTask(PerfRunData runData) {
     super(runData);
@@ -39,12 +39,4 @@
     return 0;
   }
   
-  /*
-   * (non-Javadoc)
-   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#shouldNotRecordStats()
-   */
-  protected boolean shouldNotRecordStats() {
-    return true;
-  }
-
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java?rev=576786&r1=576785&r2=576786&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/ResetSystemSoftTask.java
Tue Sep 18 02:05:06 2007
@@ -28,7 +28,7 @@
  * Index is NOT erased.
  * Directory is NOT erased.
  */
-public class ResetSystemSoftTask extends PerfTask {
+public class ResetSystemSoftTask extends ResetInputsTask {
 
   public ResetSystemSoftTask(PerfRunData runData) {
     super(runData);
@@ -37,14 +37,6 @@
   public int doLogic() throws Exception {
     getRunData().reinit(false);
     return 0;
-  }
-
-  /*
-   * (non-Javadoc)
-   * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#shouldNotRecordStats()
-   */
-  protected boolean shouldNotRecordStats() {
-    return true;
   }
 
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java?rev=576786&r1=576785&r2=576786&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
Tue Sep 18 02:05:06 2007
@@ -35,7 +35,9 @@
   private boolean letChildReport = true;
   private int rate = 0;
   private boolean perMin = false; // rate, if set, is, by default, be sec.
-  private String seqName; 
+  private String seqName;
+  private boolean exhausted = false;
+  private boolean resetExhausted = false;
   
   public TaskSequence (PerfRunData runData, String name, TaskSequence parent, boolean parallel)
{
     super(runData);
@@ -90,6 +92,7 @@
    * @see org.apache.lucene.benchmark.byTask.tasks.PerfTask#doLogic()
    */
   public int doLogic() throws Exception {
+    resetExhausted = false;
     return ( parallel ? doParallelTasks() : doSerialTasks());
   }
 
@@ -99,7 +102,6 @@
     }
     
     int count = 0;
-    boolean exhausted = false;
     
     final int numTasks = tasks.size();
     final PerfTask[] tasksArray = new PerfTask[numTasks];
@@ -110,6 +112,7 @@
       for(int l=0;l<numTasks;l++)
         try {
           count += tasksArray[l].runAndMaybeStats(letChildReport);
+          updateExhausted(tasksArray[l]);
         } catch (NoMoreDataException e) {
           exhausted = true;
         }
@@ -121,7 +124,6 @@
     long delayStep = (perMin ? 60000 : 1000) /rate;
     long nextStartTime = System.currentTimeMillis();
     int count = 0;
-    boolean exhausted = false;
     for (int k=0; (repetitions==REPEAT_EXHAUST && !exhausted) || k<repetitions;
k++) {
       for (Iterator it = tasks.iterator(); it.hasNext();) {
         PerfTask task = (PerfTask) it.next();
@@ -133,6 +135,7 @@
         nextStartTime += delayStep; // this aims at avarage rate. 
         try {
           count += task.runAndMaybeStats(letChildReport);
+          updateExhausted(task);
         } catch (NoMoreDataException e) {
           exhausted = true;
         }
@@ -141,6 +144,25 @@
     return count;
   }
 
+  // update state regarding exhaustion.
+  private void updateExhausted(PerfTask task) {
+    if (task instanceof ResetInputsTask) {
+      exhausted = false;
+      resetExhausted = true;
+    } else {
+      if (task instanceof TaskSequence) {
+        TaskSequence t = (TaskSequence) task;
+        if (t.resetExhausted) {
+          exhausted = false;
+          resetExhausted = true;
+          t.resetExhausted = false;
+        } else {
+          exhausted |= t.exhausted;
+        }
+      }
+    }
+  }
+
   private int doParallelTasks() throws Exception {
     final int count [] = {0};
     Thread t[] = new Thread [repetitions * tasks.size()];
@@ -154,11 +176,14 @@
             int n;
             try {
               n = task.runAndMaybeStats(letChildReport);
+              updateExhausted(task);
+              synchronized (count) {
+                count[0] += n;
+              }
+            } catch (NoMoreDataException e) {
+              exhausted = true;
             } catch (Exception e) {
               throw new RuntimeException(e);
-            }
-            synchronized (count) {
-              count[0] += n;
             }
           }
         };

Modified: lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java?rev=576786&r1=576785&r2=576786&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/test/org/apache/lucene/benchmark/byTask/TestPerfTasksLogic.java
Tue Sep 18 02:05:06 2007
@@ -282,6 +282,39 @@
     assertEquals(totalTokenCount1, totalTokenCount2);
   }
   
+  /**
+   * Test that " {[AddDoc(4000)]: 4} : * " works corrcetly (for LUCENE-941)
+   */
+  public void testParallelExhausted() throws Exception {
+    // 1. alg definition (required in every "logic" test)
+    String algLines[] = {
+        "# ----- properties ",
+        "doc.maker="+Reuters20DocMaker.class.getName(),
+        "doc.add.log.step=3",
+        "doc.term.vector=false",
+        "doc.maker.forever=false",
+        "directory=RAMDirectory",
+        "doc.stored=false",
+        "doc.tokenized=false",
+        "debug.level=1",
+        "# ----- alg ",
+        "CreateIndex",
+        "{ [ AddDoc]: 4} : * ",
+        "ResetInputs ",
+        "{ [ AddDoc]: 4} : * ",
+        "CloseIndex",
+    };
+    
+    // 2. execute the algorithm  (required in every "logic" test)
+    Benchmark benchmark = execBenchmark(algLines);
+
+    // 3. test number of docs in the index
+    IndexReader ir = IndexReader.open(benchmark.getRunData().getDirectory());
+    int ndocsExpected = 2 * 20; // Reuters20DocMaker exhausts after 20 docs.
+    assertEquals("wrong number of docs in the index!", ndocsExpected, ir.numDocs());
+    ir.close();
+  }
+
   // create the benchmark and execute it. 
   public static Benchmark execBenchmark(String[] algLines) throws Exception {
     String algText = algLinesToText(algLines);
@@ -320,6 +353,10 @@
       }
       nDocs++;
       return super.getNextDocData();
+    }
+    public synchronized void resetInputs() {
+      super.resetInputs();
+      nDocs = 0;
     }
   }
 }



Mime
View raw message