Skip to content

Commit 81e0a39

Browse files
committed
Experiment with also avoiding mmap for fdm and fdx tmp files.
1 parent 0b817a0 commit 81e0a39

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

server/src/main/java/org/elasticsearch/index/store/FsDirectoryFactory.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ static boolean useDelegate(String name, IOContext ioContext) {
233233
}
234234

235235
/**
236-
* Force not using mmap if file is tmp fdt file.
237-
* The tmp fdt file only gets created when flushing stored
236+
* Force not using mmap if file is tmp fdm, fdx and fdt files.
237+
* The tmp fdm, fdx, fdt file only gets created when flushing stored
238238
* fields to disk and index sorting is active.
239239
* <p>
240240
* In Lucene, the <code>SortingStoredFieldsConsumer</code> first
@@ -252,17 +252,17 @@ static boolean useDelegate(String name, IOContext ioContext) {
252252
* <p>
253253
* As part of flushing stored disk when indexing sorting is active,
254254
* three tmp files are created, fdm (metadata), fdx (index) and
255-
* fdt (contains stored field data). The first two files are small and
256-
* mmap-ing that should still be ok even is memory is scarce.
257-
* The fdt file is large and tends to cause more page faults when memory is scarce.
255+
* fdt (contains stored field data). All tmp files avoid using mmmp directory.
258256
*
259257
* @param name The name of the file in Lucene index
260258
* @param extension The extension of the in Lucene index
261259
* @return whether to avoid using delegate if the file is a tmp fdt file.
262260
*/
263261
static boolean avoidDelegateForFdtTempFiles(String name, LuceneFilesExtensions extension) {
264262
// NOTE, for now gated behind feature flag to observe impact of this change in benchmarks only:
265-
return TMP_FDT_NO_MMAP_FEATURE_FLAG.isEnabled() && extension == LuceneFilesExtensions.TMP && name.contains("fdt");
263+
return TMP_FDT_NO_MMAP_FEATURE_FLAG.isEnabled()
264+
&& extension == LuceneFilesExtensions.TMP
265+
&& (name.contains("fdt") || name.contains("fdx") || name.contains("fdm"));
266266
}
267267

268268
MMapDirectory getDelegate() {

server/src/test/java/org/elasticsearch/index/store/FsDirectoryFactoryTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public void testPreload() throws IOException {
7171
assertTrue(FsDirectoryFactory.HybridDirectory.useDelegate("foo.tmp", newIOContext(random())));
7272
assertFalse(FsDirectoryFactory.HybridDirectory.useDelegate("foo.fdt__0.tmp", newIOContext(random())));
7373
assertFalse(FsDirectoryFactory.HybridDirectory.useDelegate("_0.fdt__1.tmp", newIOContext(random())));
74-
assertTrue(FsDirectoryFactory.HybridDirectory.useDelegate("_0.fdm__0.tmp", newIOContext(random())));
75-
assertTrue(FsDirectoryFactory.HybridDirectory.useDelegate("_0.fdx__4.tmp", newIOContext(random())));
74+
assertFalse(FsDirectoryFactory.HybridDirectory.useDelegate("_0.fdm__0.tmp", newIOContext(random())));
75+
assertFalse(FsDirectoryFactory.HybridDirectory.useDelegate("_0.fdx__4.tmp", newIOContext(random())));
7676
MMapDirectory delegate = hybridDirectory.getDelegate();
7777
assertThat(delegate, Matchers.instanceOf(MMapDirectory.class));
7878
var func = fsDirectoryFactory.preLoadFuncMap.get(delegate);

0 commit comments

Comments
 (0)