lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dor...@apache.org
Subject svn commit: r614956 - in /lucene/java/trunk/contrib/benchmark: ./ conf/ src/java/org/apache/lucene/benchmark/byTask/ src/java/org/apache/lucene/benchmark/byTask/tasks/ src/java/org/apache/lucene/benchmark/byTask/utils/ src/test/org/apache/lucene/benchm...
Date Thu, 24 Jan 2008 18:47:03 GMT
Author: doronc
Date: Thu Jan 24 10:46:57 2008
New Revision: 614956

URL: http://svn.apache.org/viewvc?rev=614956&view=rev
Log:
LUCENE-1136: add ability to not count sub-task doLogic increment to contri/benchmark

Modified:
    lucene/java/trunk/contrib/benchmark/CHANGES.txt
    lucene/java/trunk/contrib/benchmark/conf/micro-standard.alg
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/TaskSequence.java
    lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.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=614956&r1=614955&r2=614956&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/CHANGES.txt (original)
+++ lucene/java/trunk/contrib/benchmark/CHANGES.txt Thu Jan 24 10:46:57 2008
@@ -4,7 +4,9 @@
 
 $Id:$
 
-
+1/24/2008
+  LUCENE-1136: add ability to not count sub-task doLogic increment
+  
 1/23/2008
   LUCENE-1129: ReadTask properly uses the traversalSize value
   LUCENE-1128: Added support for benchmarking the highlighter

Modified: lucene/java/trunk/contrib/benchmark/conf/micro-standard.alg
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/conf/micro-standard.alg?rev=614956&r1=614955&r2=614956&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/conf/micro-standard.alg (original)
+++ lucene/java/trunk/contrib/benchmark/conf/micro-standard.alg Thu Jan 24 10:46:57 2008
@@ -50,10 +50,10 @@
     ResetSystemErase
 
     { "Populate"
-        CreateIndex
+        -CreateIndex
         { "MAddDocs" AddDoc > : 2000
-        Optimize
-        CloseIndex
+        -Optimize
+        -CloseIndex
     }
 
     OpenReader  

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html?rev=614956&r1=614955&r2=614956&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/package.html
Thu Jan 24 10:46:57 2008
@@ -290,6 +290,15 @@
  waiting before starting next add, if otherwise rate would exceed 200 adds/min.
  </li>
  <li>
+ <b>Disable Counting</b>: Each task executed contributes to the records count.
+ This count is reflected in reports under recs/s and under recsPerRun.
+ Most tasks count 1, some count 0, and some count more.
+ (See <a href="#recsCounting">Results record counting clarified</a> for more
details.)
+ It is possible to disable counting for a task by preceding it with <font color="#FF0066">-</font>.
+ <br>Example -  <font color="#FF0066"> -CreateIndex </font> - would count
0 while
+ the default behavior for CreateIndex is to count 1.
+ </li>
+ <li>
  <b>Command names</b>: Each class "AnyNameTask" in the
  package org.apache.lucene.benchmark.byTask.tasks,
  that extends PerfTask, is supported as command "AnyName" that can be

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java?rev=614956&r1=614955&r2=614956&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/PerfTask.java
Thu Jan 24 10:46:57 2008
@@ -41,6 +41,7 @@
   private String name;
   private int depth = 0;
   private int maxDepthLogStart = 0;
+  private boolean disableCounting = false;
   protected String params = null;
   
   protected static final String NEW_LINE = System.getProperty("line.separator");
@@ -81,6 +82,7 @@
     if (!reportStats || shouldNotRecordStats()) {
       setup();
       int count = doLogic();
+      count = disableCounting ? 0 : count;
       tearDown();
       return count;
     }
@@ -88,6 +90,7 @@
     Points pnts = runData.getPoints();
     TaskStats ts = pnts.markTaskStart(this,runData.getConfig().getRoundNumber());
     int count = doLogic();
+    count = disableCounting ? 0 : count;
     pnts.markTaskEnd(ts, count);
     tearDown();
     return count;
@@ -153,6 +156,9 @@
   public String toString() {
     String padd = getPadding();
     StringBuffer sb = new StringBuffer(padd);
+    if (disableCounting) {
+      sb.append('-');
+    }
     sb.append(getName());
     return sb.toString();
   }
@@ -225,6 +231,20 @@
    */
   public String getParams() {
     return params;
+  }
+
+  /**
+   * Return true if counting is disabled for this task.
+   */
+  public boolean isDisableCounting() {
+    return disableCounting;
+  }
+
+  /**
+   * See {@link #isDisableCounting()}
+   */
+  public void setDisableCounting(boolean disableCounting) {
+    this.disableCounting = disableCounting;
   }
 
 }

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=614956&r1=614955&r2=614956&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
Thu Jan 24 10:46:57 2008
@@ -40,9 +40,11 @@
   private boolean resetExhausted = false;
   private PerfTask[] tasksArray;
   private boolean anyExhaustibleTasks;
+  private boolean collapsable = false; // to not collapse external sequence named in alg.
 
   
   public TaskSequence (PerfRunData runData, String name, TaskSequence parent, boolean parallel)
{
     super(runData);
+    collapsable = (name == null);
     name = (name!=null ? name : (parallel ? "Par" : "Seq"));
     setName(name);
     setSequenceName();
@@ -337,6 +339,13 @@
       res.tasks.add(((PerfTask)tasks.get(i)).clone());
     }
     return res;
+  }
+
+  /**
+   * Return true if can be collapsed in case it is outermost sequence
+   */
+  public boolean isCollapsable() {
+    return collapsable;
   }
   
 }

Modified: lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java?rev=614956&r1=614955&r2=614956&view=diff
==============================================================================
--- lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java
(original)
+++ lucene/java/trunk/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/utils/Algorithm.java
Thu Jan 24 10:46:57 2008
@@ -51,7 +51,9 @@
     stok.ordinaryChar('/');
     stok.ordinaryChar('(');
     stok.ordinaryChar(')');
+    stok.ordinaryChar('-');
     boolean colonOk = false; 
+    boolean isDisableCountNextTask = false; // only for primitive tasks
     currSequence.setDepth(0);
     String taskPackage = PerfTask.class.getPackage().getName() + ".";
     
@@ -65,6 +67,8 @@
           String s = stok.sval;
           Constructor cnstr = Class.forName(taskPackage+s+"Task").getConstructor(paramClass);
           PerfTask task = (PerfTask) cnstr.newInstance(paramObj);
+          task.setDisableCounting(isDisableCountNextTask);
+          isDisableCountNextTask = false;
           currSequence.addTask(task);
           if (task instanceof RepSumByPrefTask) {
             stok.nextToken();
@@ -120,7 +124,8 @@
               if ((char)stok.ttype == '*') {
                 ((TaskSequence)prevTask).setRepetitions(TaskSequence.REPEAT_EXHAUST);
               } else {
-                if (stok.ttype!=StreamTokenizer.TT_NUMBER) throw new Exception("expected
repetitions number: - "+stok.toString());
+                if (stok.ttype!=StreamTokenizer.TT_NUMBER) 
+                  throw new Exception("expected repetitions number: - "+stok.toString());
                 ((TaskSequence)prevTask).setRepetitions((int)stok.nval);
               }
               // check for rate specification (ops/min)
@@ -184,6 +189,10 @@
               currSequence = currSequence.getParent();
               break;
           
+            case '-' :
+              isDisableCountNextTask = true;
+              break;
+              
           } //switch(c)
           break;
           
@@ -196,7 +205,7 @@
     }
     
     // remove redundant top level enclosing sequences
-    while (sequence.getRepetitions()==1 && sequence.getRate()==0) {
+    while (sequence.isCollapsable() && sequence.getRepetitions()==1 && sequence.getRate()==0)
{
       ArrayList t = sequence.getTasks();
       if (t!=null && t.size()==1) {
         PerfTask p = (PerfTask) t.get(0);
@@ -225,7 +234,7 @@
    * @throws Exception 
    */
   public void execute() throws Exception {
-    sequence.doLogic();
+    sequence.runAndMaybeStats(true);
   }
 
   /**

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=614956&r1=614955&r2=614956&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
Thu Jan 24 10:46:57 2008
@@ -24,6 +24,7 @@
 import java.util.List;
 import java.util.Iterator;
 
+import org.apache.lucene.benchmark.byTask.Benchmark;
 import org.apache.lucene.benchmark.byTask.feeds.DocData;
 import org.apache.lucene.benchmark.byTask.feeds.NoMoreDataException;
 import org.apache.lucene.benchmark.byTask.feeds.ReutersDocMaker;
@@ -194,6 +195,7 @@
     try {
       Benchmark benchmark = execBenchmark(algLines);
       assertTrue("CountingHighlighterTest should have thrown an exception", false);
+      assertNotNull(benchmark); // (avoid compile warning on unused variable)
     } catch (Exception e) {
       assertTrue(true);
     }
@@ -311,7 +313,6 @@
       "doc.maker=org.apache.lucene.benchmark.byTask.feeds.LineDocMaker",
       "docs.file=" + lineFile.getAbsolutePath().replace('\\', '/'),
       "doc.maker.forever=false",
-      "doc.maker.forever=false",
       "doc.reuse.fields=false",
       "autocommit=false",
       "ram.flush.mb=4",
@@ -404,7 +405,7 @@
         "directory=RAMDirectory",
         "doc.stored=false",
         "doc.tokenized=false",
-        "debug.level=1",
+        "task.max.depth.log=1",
         "# ----- alg ",
         "CreateIndex",
         "{ [ AddDoc]: 4} : * ",
@@ -482,7 +483,7 @@
         "directory=RAMDirectory",
         "doc.stored=false",
         "doc.tokenized=false",
-        "debug.level=1",
+        "task.max.depth.log=1",
         "# ----- alg ",
         "{ \"Rounds\"",
         "  ResetSystemErase",
@@ -501,7 +502,7 @@
     assertEquals("wrong number of docs in the index!", ndocsExpected, ir.numDocs());
     ir.close();
   }
-
+  
   /**
    * Test that we can close IndexWriter with argument "false".
    */
@@ -658,7 +659,7 @@
     Benchmark benchmark = execBenchmark(algLines);
     final IndexWriter writer = benchmark.getRunData().getIndexWriter();
     assertEquals(2, writer.getMaxBufferedDocs());
-    assertEquals(writer.DISABLE_AUTO_FLUSH, (int) writer.getRAMBufferSizeMB());
+    assertEquals(IndexWriter.DISABLE_AUTO_FLUSH, (int) writer.getRAMBufferSizeMB());
     assertEquals(3, writer.getMergeFactor());
     assertEquals(false, writer.getUseCompoundFile());
   }
@@ -708,4 +709,63 @@
         cfsCount++;
     assertEquals(3, cfsCount);
   }
+  
+  /**
+   * Test disabling task count (LUCENE-1136).
+   */
+  public void testDisableCounting() throws Exception {
+    doTestDisableCounting(true);
+    doTestDisableCounting(false);
+  }
+
+  private void doTestDisableCounting(boolean disable) throws Exception {
+    // 1. alg definition (required in every "logic" test)
+    String algLines[] = disableCountingLines(disable);
+    
+    // 2. execute the algorithm  (required in every "logic" test)
+    Benchmark benchmark = execBenchmark(algLines);
+
+    // 3. test counters
+    int n = disable ? 0 : 1;
+    int nChecked = 0;
+    for (Iterator ts = benchmark.getRunData().getPoints().taskStats().iterator(); ts.hasNext();)
{
+      TaskStats stats = (TaskStats) ts.next();
+      String taskName = stats.getTask().getName();
+      if (taskName.equals("Rounds")) {
+        assertEquals("Wrong total count!",20+2*n,stats.getCount());
+        nChecked++;
+      } else if (taskName.equals("CreateIndex")) {
+        assertEquals("Wrong count for CreateIndex!",n,stats.getCount());
+        nChecked++;
+      } else if (taskName.equals("CloseIndex")) {
+        assertEquals("Wrong count for CloseIndex!",n,stats.getCount());
+        nChecked++;
+      }
+    }
+    assertEquals("Missing some tasks to check!",3,nChecked);
+  }
+
+  private static String[] disableCountingLines (boolean disable) {
+    String dis = disable ? "-" : "";
+    return new String[] {
+        "# ----- properties ",
+        "doc.maker="+Reuters20DocMaker.class.getName(),
+        "doc.add.log.step=30",
+        "doc.term.vector=false",
+        "doc.maker.forever=false",
+        "directory=RAMDirectory",
+        "doc.stored=false",
+        "doc.tokenized=false",
+        "task.max.depth.log=1",
+        "# ----- alg ",
+        "{ \"Rounds\"",
+        "  ResetSystemErase",
+        "  "+dis+"CreateIndex",            // optionally disable counting here
+        "  { \"AddDocs\"  AddDoc > : * ",
+        "  "+dis+"  CloseIndex",             // optionally disable counting here (with extra
blanks)
+        "}",
+        "RepSumByName",
+    };
+  }
+  
 }



Mime
View raw message