Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the Engine specific files from INDEX_STORE_HYBRID_NIO_EXTENSIONS list to make sure engine files are getting mmapped #1054

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fixing the Engine specific files from INDEX_STORE_HYBRID_NIO_EXTENSIO…
…NS list to make sure engine files are getting mmaped.

Signed-off-by: Navneet Verma <navneev@amazon.com>
  • Loading branch information
navneet1v committed Aug 23, 2023
commit 507bee324a7b10c7bcd73c3ee380afb7811f468e
17 changes: 9 additions & 8 deletions src/main/java/org/opensearch/knn/plugin/KNNPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static java.util.Collections.singletonList;
import static org.opensearch.knn.common.KNNConstants.KNN_THREAD_POOL_PREFIX;
Expand Down Expand Up @@ -348,17 +347,19 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
*/
@Override
public Settings additionalSettings() {
// We add engine specific extensions to the core list for HybridFS store type. We read existing values
// and append ours because in core setting will be replaced by override.
// We are removing the engine specific file extensions from INDEX_STORE_HYBRID_NIO_EXTENSIONS settings. This
// is to ensure that the engine specific files are getting mmaped for best performance. We read existing values
// and remove ours because in core setting will be replaced by override.
// Values are set as cluster defaults and are used at index creation time. Index specific overrides will take priority over values
// that are set here.
final List<String> engineSettings = Arrays.stream(KNNEngine.values())
.flatMap(engine -> engine.mmapFileExtensions().stream())
.collect(Collectors.toList());
final List<String> combinedSettings = Stream.concat(
IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getDefault(Settings.EMPTY).stream(),
engineSettings.stream()
).collect(Collectors.toList());
return Settings.builder().putList(IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getKey(), combinedSettings).build();

List<String> finalSettings = IndexModule.INDEX_STORE_HYBRID_NIO_EXTENSIONS.getDefault(Settings.EMPTY)
.stream()
.filter(str -> !engineSettings.contains(str))
.collect(Collectors.toList());
return Settings.builder().putList(IndexModule.INDEX_STORE_HYBRID_NIO_EXTENSIONS.getKey(), finalSettings).build();
}
}