You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2013/08/10 16:29:22 UTC

svn commit: r1512729 - in /lucene/dev/branches/branch_4x: ./ lucene/ lucene/core/ lucene/core/src/java/org/apache/lucene/store/ lucene/test-framework/ lucene/test-framework/src/java/org/apache/lucene/util/

Author: rmuir
Date: Sat Aug 10 14:29:22 2013
New Revision: 1512729

URL: http://svn.apache.org/r1512729
Log:
LUCENE-5161: set sane default readChunkSizes, make the setter work, and test the chunking

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/lucene/   (props changed)
    lucene/dev/branches/branch_4x/lucene/CHANGES.txt
    lucene/dev/branches/branch_4x/lucene/core/   (props changed)
    lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
    lucene/dev/branches/branch_4x/lucene/test-framework/   (props changed)
    lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java

Modified: lucene/dev/branches/branch_4x/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/CHANGES.txt?rev=1512729&r1=1512728&r2=1512729&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/lucene/CHANGES.txt Sat Aug 10 14:29:22 2013
@@ -67,6 +67,10 @@ Bug Fixes
   could happen in rare cases where something happens to the file between the time we start the
   read loop (where we check the length) and when we actually do the read. (gsingers, yonik, Robert Muir, Uwe Schindler)
 
+* LUCENE-5161: Fix default chunk sizes in FSDirectory.java to not be unnecessarily large,
+  and fix setReadChunkSize to always work regardless of whether the machine is 32bit
+  or 64bit.  (Uwe Schindler, Robert Muir)
+
 API Changes
 
 * LUCENE-5094: Add ramBytesUsed() to MultiDocValues.OrdinalMap.

Modified: lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java?rev=1512729&r1=1512728&r2=1512729&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java (original)
+++ lucene/dev/branches/branch_4x/lucene/core/src/java/org/apache/lucene/store/FSDirectory.java Sat Aug 10 14:29:22 2013
@@ -112,12 +112,9 @@ import org.apache.lucene.util.Constants;
 public abstract class FSDirectory extends Directory {
 
   /**
-   * Default read chunk size.  This is a conditional default: on 32bit JVMs, it defaults to 100 MB.  On 64bit JVMs, it's
-   * <code>Integer.MAX_VALUE</code>.
-   *
-   * @see #setReadChunkSize
+   * Default read chunk size: 2*{@link BufferedIndexInput#MERGE_BUFFER_SIZE}.
    */
-  public static final int DEFAULT_READ_CHUNK_SIZE = Constants.JRE_IS_64BIT ? Integer.MAX_VALUE : 100 * 1024 * 1024;
+  public static final int DEFAULT_READ_CHUNK_SIZE = BufferedIndexInput.MERGE_BUFFER_SIZE * 2;
 
   protected final File directory; // The underlying filesystem directory
   protected final Set<String> staleFiles = synchronizedSet(new HashSet<String>()); // Files written, but not yet sync'ed
@@ -366,20 +363,13 @@ public abstract class FSDirectory extend
    * already-opened {@link IndexInput}s.  You should call
    * this before attempting to open an index on the
    * directory.</p>
-   *
-   * <p> <b>NOTE</b>: This value should be as large as
-   * possible to reduce any possible performance impact.  If
-   * you still encounter an incorrect OutOfMemoryError,
-   * trying lowering the chunk size.</p>
    */
   public final void setReadChunkSize(int chunkSize) {
     // LUCENE-1566
     if (chunkSize <= 0) {
       throw new IllegalArgumentException("chunkSize must be positive");
     }
-    if (!Constants.JRE_IS_64BIT) {
-      this.chunkSize = chunkSize;
-    }
+    this.chunkSize = chunkSize;
   }
 
   /**

Modified: lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java?rev=1512729&r1=1512728&r2=1512729&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java (original)
+++ lucene/dev/branches/branch_4x/lucene/test-framework/src/java/org/apache/lucene/util/LuceneTestCase.java Sat Aug 10 14:29:22 2013
@@ -20,6 +20,7 @@ package org.apache.lucene.util;
 import java.io.*;
 import java.lang.annotation.*;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.*;
 import java.util.concurrent.*;
@@ -1150,8 +1151,9 @@ public abstract class LuceneTestCase ext
     try {
       d = CommandLineUtil.newFSDirectory(clazz, file);
     } catch (Exception e) {
-      d = FSDirectory.open(file);
+      Rethrow.rethrow(e);
     }
+    d.setReadChunkSize(_TestUtil.nextInt(random(), 8, 32678));
     return d;
   }