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

[Tiered caching] Integrating IndicesRequestCache with CacheService controlled by a feature flag #12533

Merged
merged 9 commits into from
Mar 11, 2024
Prev Previous commit
Next Next commit
Updating changelog and renaming feature flag setting
Signed-off-by: Sagar Upadhyaya <sagar.upadhyaya.121@gmail.com>
  • Loading branch information
sgup432 committed Mar 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 1f85b278bb6a1ab35317672d11522e3e8bd22e6e
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Add toString methods to MultiSearchRequest, MultiGetRequest and CreateIndexRequest ([#12163](https://github.com/opensearch-project/OpenSearch/pull/12163))
- Support for returning scores in matched queries ([#11626](https://github.com/opensearch-project/OpenSearch/pull/11626))
- Add shard id property to SearchLookup for use in field types provided by plugins ([#1063](https://github.com/opensearch-project/OpenSearch/pull/1063))
- [Tiered caching] Integrating IndicesRequestCache with CacheService controlled by a feature flag ([#12533](https://github.com/opensearch-project/OpenSearch/pull/12533))
- [Tiered caching] Make IndicesRequestCache implementation configurable [EXPERIMENTAL] ([#12533](https://github.com/opensearch-project/OpenSearch/pull/12533))
- Add kuromoji_completion analyzer and filter ([#4835](https://github.com/opensearch-project/OpenSearch/issues/4835))

### Dependencies
4 changes: 4 additions & 0 deletions distribution/src/config/opensearch.yml
Original file line number Diff line number Diff line change
@@ -121,3 +121,7 @@ ${path.logs}
# Once there is no observed impact on performance, this feature flag can be removed.
#
#opensearch.experimental.optimization.datetime_formatter_caching.enabled: false
#
# Gates the functionality of enabling Opensearch to use pluggable caches with respective store names via setting.
#
#opensearch.experimental.feature.pluggable.caching.enabled: false
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {

@Override
protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.TIERED_CACHING, "true").build();
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.PLUGGABLE_CACHE, "true").build();
}

@Override
Original file line number Diff line number Diff line change
@@ -84,7 +84,7 @@ public static Collection<Object[]> parameters() {

@Override
protected Settings featureFlagSettings() {
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.TIERED_CACHING, "true").build();
return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.PLUGGABLE_CACHE, "true").build();
}

@Override
Original file line number Diff line number Diff line change
@@ -732,7 +732,7 @@ public void apply(Settings value, Settings current, Settings previous) {
TelemetrySettings.TRACER_FEATURE_ENABLED_SETTING,
TelemetrySettings.METRICS_FEATURE_ENABLED_SETTING
),
List.of(FeatureFlags.TIERED_CACHING),
List.of(FeatureFlags.PLUGGABLE_CACHE),
List.of(CacheSettings.getConcreteSettingForCacheType(CacheType.INDICES_REQUEST_CACHE))
);
}
Original file line number Diff line number Diff line change
@@ -37,6 +37,6 @@ protected FeatureFlagSettings(
FeatureFlags.WRITEABLE_REMOTE_INDEX_SETTING,
FeatureFlags.DOC_ID_FUZZY_SET_SETTING,
FeatureFlags.REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING,
FeatureFlags.TIERED_CACHING_SETTING
FeatureFlags.PLUGGABLE_CACHE_SETTING
);
}
Original file line number Diff line number Diff line change
@@ -65,9 +65,10 @@ public class FeatureFlags {
public static final String DOC_ID_FUZZY_SET = "opensearch.experimental.optimize_doc_id_lookup.fuzzy_set.enabled";

/**
* Gates the functionality of tiered caching
* Gates the functionality of pluggable cache.
* Enables OpenSearch to use pluggable caches with respective store names via setting.
*/
public static final String TIERED_CACHING = "opensearch.experimental.feature.tiered.caching.enabled";
public static final String PLUGGABLE_CACHE = "opensearch.experimental.feature.pluggable.caching.enabled";

/**
* Should store the settings from opensearch.yml.
@@ -134,5 +135,5 @@ public static boolean isEnabled(Setting<Boolean> featureFlag) {

public static final Setting<Boolean> DOC_ID_FUZZY_SET_SETTING = Setting.boolSetting(DOC_ID_FUZZY_SET, false, Property.NodeScope);

public static final Setting<Boolean> TIERED_CACHING_SETTING = Setting.boolSetting(TIERED_CACHING, false, Property.NodeScope);
public static final Setting<Boolean> PLUGGABLE_CACHE_SETTING = Setting.boolSetting(PLUGGABLE_CACHE, false, Property.NodeScope);
}
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@
long sizeInBytes = size.getBytes();
ToLongBiFunction<Key, BytesReference> weigher = (k, v) -> k.ramBytesUsed() + v.ramBytesUsed();
this.cacheEntityLookup = cacheEntityFunction;
if (FeatureFlags.TIERED_CACHING_SETTING.get(settings)) {
if (FeatureFlags.PLUGGABLE_CACHE_SETTING.get(settings)) {
this.cache = cacheService.createCache(
new CacheConfig.Builder<Key, BytesReference>().setSettings(settings)
.setWeigher((k, v) -> k.ramBytesUsed() + v.ramBytesUsed())
@@ -147,7 +147,7 @@
.setWeigher(weigher)
.setRemovalListener(this);
if (expire != null) {
builder.setExpireAfterAccess(expire);

Check warning on line 150 in server/src/main/java/org/opensearch/indices/IndicesRequestCache.java

Codecov / codecov/patch

server/src/main/java/org/opensearch/indices/IndicesRequestCache.java#L150

Added line #L150 was not covered by tests
}
this.cache = builder.build();
}
Original file line number Diff line number Diff line change
@@ -144,7 +144,7 @@ public void testBasicOperationsCacheWithFeatureFlag() throws Exception {
IndexShard indexShard = createIndex("test").getShard(0);
CacheService cacheService = new CacheModule(new ArrayList<>(), Settings.EMPTY).getCacheService();
IndicesRequestCache cache = new IndicesRequestCache(
Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.TIERED_CACHING, "true").build(),
Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.PLUGGABLE_CACHE, "true").build(),
(shardId -> Optional.of(new IndicesService.IndexShardCacheEntity(indexShard))),
cacheService
);
Loading