Ver Fonte

Enable madvise by default for all builds (#110159)

This feature flag has been enabled by default for snapshot builds for
some time, no significant bumps or changes in rally. 

This commit will enable it by default, even in release builds.
Benjamin Trent há 1 ano atrás
pai
commit
4a77e06233

+ 2 - 30
server/src/main/java/org/elasticsearch/index/store/FsDirectoryFactory.java

@@ -21,7 +21,6 @@ import org.apache.lucene.store.NativeFSLockFactory;
 import org.apache.lucene.store.SimpleFSLockFactory;
 import org.elasticsearch.common.settings.Setting;
 import org.elasticsearch.common.settings.Setting.Property;
-import org.elasticsearch.common.util.FeatureFlag;
 import org.elasticsearch.core.IOUtils;
 import org.elasticsearch.index.IndexModule;
 import org.elasticsearch.index.IndexSettings;
@@ -36,8 +35,6 @@ import java.util.Set;
 
 public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
 
-    private static final FeatureFlag MADV_RANDOM_FEATURE_FLAG = new FeatureFlag("madv_random");
-
     public static final Setting<LockFactory> INDEX_LOCK_FACTOR_SETTING = new Setting<>("index.store.fs.fs_lock", "native", (s) -> {
         return switch (s) {
             case "native" -> NativeFSLockFactory.INSTANCE;
@@ -69,20 +66,12 @@ public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
                 // Use Lucene defaults
                 final FSDirectory primaryDirectory = FSDirectory.open(location, lockFactory);
                 if (primaryDirectory instanceof MMapDirectory mMapDirectory) {
-                    Directory dir = new HybridDirectory(lockFactory, setPreload(mMapDirectory, lockFactory, preLoadExtensions));
-                    if (MADV_RANDOM_FEATURE_FLAG.isEnabled() == false) {
-                        dir = disableRandomAdvice(dir);
-                    }
-                    return dir;
+                    return new HybridDirectory(lockFactory, setPreload(mMapDirectory, lockFactory, preLoadExtensions));
                 } else {
                     return primaryDirectory;
                 }
             case MMAPFS:
-                Directory dir = setPreload(new MMapDirectory(location, lockFactory), lockFactory, preLoadExtensions);
-                if (MADV_RANDOM_FEATURE_FLAG.isEnabled() == false) {
-                    dir = disableRandomAdvice(dir);
-                }
-                return dir;
+                return setPreload(new MMapDirectory(location, lockFactory), lockFactory, preLoadExtensions);
             case SIMPLEFS:
             case NIOFS:
                 return new NIOFSDirectory(location, lockFactory);
@@ -104,23 +93,6 @@ public class FsDirectoryFactory implements IndexStorePlugin.DirectoryFactory {
         return mMapDirectory;
     }
 
-    /**
-     * Return a {@link FilterDirectory} around the provided {@link Directory} that forcefully disables {@link IOContext#RANDOM random
-     * access}.
-     */
-    static Directory disableRandomAdvice(Directory dir) {
-        return new FilterDirectory(dir) {
-            @Override
-            public IndexInput openInput(String name, IOContext context) throws IOException {
-                if (context.randomAccess) {
-                    context = IOContext.READ;
-                }
-                assert context.randomAccess == false;
-                return super.openInput(name, context);
-            }
-        };
-    }
-
     /**
      * Returns true iff the directory is a hybrid fs directory
      */

+ 0 - 26
server/src/test/java/org/elasticsearch/index/store/FsDirectoryFactoryTests.java

@@ -8,12 +8,9 @@
 package org.elasticsearch.index.store;
 
 import org.apache.lucene.store.AlreadyClosedException;
-import org.apache.lucene.store.ByteBuffersDirectory;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FilterDirectory;
 import org.apache.lucene.store.IOContext;
-import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.store.IndexOutput;
 import org.apache.lucene.store.MMapDirectory;
 import org.apache.lucene.store.NIOFSDirectory;
 import org.apache.lucene.store.NoLockFactory;
@@ -69,29 +66,6 @@ public class FsDirectoryFactoryTests extends ESTestCase {
         }
     }
 
-    public void testDisableRandomAdvice() throws IOException {
-        Directory dir = new FilterDirectory(new ByteBuffersDirectory()) {
-            @Override
-            public IndexInput openInput(String name, IOContext context) throws IOException {
-                assertFalse(context.randomAccess);
-                return super.openInput(name, context);
-            }
-        };
-        Directory noRandomAccessDir = FsDirectoryFactory.disableRandomAdvice(dir);
-        try (IndexOutput out = noRandomAccessDir.createOutput("foo", IOContext.DEFAULT)) {
-            out.writeInt(42);
-        }
-        // Test the tester
-        expectThrows(AssertionError.class, () -> dir.openInput("foo", IOContext.RANDOM));
-
-        // The wrapped directory shouldn't fail regardless of the IOContext
-        for (IOContext context : Arrays.asList(IOContext.READ, IOContext.DEFAULT, IOContext.READONCE, IOContext.RANDOM)) {
-            try (IndexInput in = noRandomAccessDir.openInput("foo", context)) {
-                assertEquals(42, in.readInt());
-            }
-        }
-    }
-
     private Directory newDirectory(Settings settings) throws IOException {
         IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("foo", settings);
         Path tempDir = createTempDir().resolve(idxSettings.getUUID()).resolve("0");