Skip to content

Commit

Permalink
Add setting controlling QC policy history size
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Alfonsi committed Dec 11, 2024
1 parent 06b91fa commit fd91441
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ public void apply(Settings value, Settings current, Settings previous) {
IndicesQueryCache.INDICES_CACHE_QUERY_SIZE_SETTING,
IndicesQueryCache.INDICES_CACHE_QUERY_COUNT_SETTING,
IndicesQueryCache.INDICES_QUERIES_CACHE_ALL_SEGMENTS_SETTING,
IndicesQueryCache.INDICES_QUERY_CACHE_HISTORY_SIZE,
IndicesService.CLUSTER_DEFAULT_INDEX_REFRESH_INTERVAL_SETTING,
IndicesService.CLUSTER_MINIMUM_INDEX_REFRESH_INTERVAL_SETTING,
IndicesService.INDICES_ID_FIELD_DATA_ENABLED_SETTING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
import org.opensearch.index.warmer.ShardIndexWarmerService;
import org.opensearch.index.warmer.WarmerStats;
import org.opensearch.indices.IndexingMemoryController;
import org.opensearch.indices.IndicesQueryCache;
import org.opensearch.indices.IndicesService;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.cluster.IndicesClusterStateService;
Expand Down Expand Up @@ -472,7 +473,8 @@ public boolean shouldCache(Query query) {
}
};
} else {
cachingPolicy = new UsageTrackingQueryCachingPolicy();
int cachingPolicyHistorySize = IndicesQueryCache.INDICES_QUERY_CACHE_HISTORY_SIZE.get(settings);
cachingPolicy = new UsageTrackingQueryCachingPolicy(cachingPolicyHistorySize);
}
indexShardOperationPermits = new IndexShardOperationPermits(shardId, threadPool);
readerWrapper = indexReaderWrapper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ public class IndicesQueryCache implements QueryCache, OpenSearchQueryCache {
Property.NodeScope
);

// Passed to the policy controlling access to the query cache. Plug this into TieredQueryCache too.
public static final Setting<Integer> INDICES_QUERY_CACHE_HISTORY_SIZE = Setting.intSetting(
"indices.queries.cache.history_size",
256,
1,
10_000,
Property.NodeScope
);

private final LRUQueryCache cache;
private final ShardCoreKeyMap shardKeyMap = new ShardCoreKeyMap();
private final Map<ShardId, Stats> shardStats = new ConcurrentHashMap<>();
Expand Down

0 comments on commit fd91441

Please sign in to comment.