Conversation
Introduce a LRU cache to avoid searches that occur frequently from the enrich processor. Relates to elastic#48988
|
Pinging @elastic/es-core-features (Team:Core/Features) |
danhermann
left a comment
There was a problem hiding this comment.
LGTM. Minor comments below but nothing blocking.
| return String.valueOf(maxConcurrentRequests * maxLookupsPerRequest); | ||
| }, val -> Setting.parseInt(val, 1, Integer.MAX_VALUE, QUEUE_CAPACITY_SETTING_NAME), Setting.Property.NodeScope); | ||
|
|
||
| public static final Setting<Long> CACHE_SIZE = Setting.longSetting("enrich.cache_size", 1000, 0, Setting.Property.NodeScope); |
There was a problem hiding this comment.
Were you planning to add documentation for this new setting?
There was a problem hiding this comment.
Good point, I will add docs for this.
There was a problem hiding this comment.
Maybe other enrich settings should be documented as well along side the cache size setting. I will do this in a follow up and ping James when he is back. I will revert the mentioned commit for now.
There was a problem hiding this comment.
Thanks for the ping @martijnvg. I'll be happy to take a look!
| EnrichProcessorFactory(Client client, ScriptService scriptService, EnrichCache enrichCache) { | ||
| this.client = client; | ||
| this.scriptService = scriptService; | ||
| this.enrichCache = enrichCache; |
There was a problem hiding this comment.
Maybe require non-null here since the cache is used unconditionally in createSearchRunner?
jbaiera
left a comment
There was a problem hiding this comment.
LGTM as well, just a little I noticed
| return executingPolicies.equals(response.executingPolicies) && | ||
| coordinatorStats.equals(response.coordinatorStats); | ||
| coordinatorStats.equals(response.coordinatorStats) && | ||
| cacheStats.equals(response.cacheStats); |
There was a problem hiding this comment.
cacheStats could be end up null in mixed clusters
There was a problem hiding this comment.
Good spot, I will fix this.
| public static class TransportAction extends HandledTransportAction<SearchRequest, SearchResponse> { | ||
|
|
||
| private final Coordinator coordinator; | ||
| private final EnrichCache enrichCache; |
There was a problem hiding this comment.
Are we making use of this anywhere in the proxy action?
There was a problem hiding this comment.
No, I initially did caching from here, but then moved it to the processor. The reason that in case something is cached then invoking coordinator action can be skipped as well.
|
@martijnvg can you have a look at mjmbischoff@08950c3 / pull from https://github.com/mjmbischoff/elasticsearch/tree/enrich_cache |
|
@mjmbischoff Thanks for noticing this! Using |
|
@mjmbischoff I overlooked something, |
This reverts commit 8c328a4.
|
@martijnvg Yeah my bad I overlooked that the second call was async. We could keep the get on the normal thread, and then do a However, we can do one better by not having
This does have the side effect that exceptions are now cached, so when we 'consume' the exception I'm currently invalidating the cache entry so subsequent look-ups can try again. -> I guess we could do something fancy here, speeding things up when it's a permanent failure. This results in the cache interaction being non-blocking and only a single search request is performed when cache look-ups for the same value happen in parallel. I've updated my branch reflecting these changes |
|
Thanks @mjmbischoff, I think that should work and is a good improvement. I will merge this PR, can you open a followup pr with these changes? |
Backporting elastic#76800 to 7.x branch. Introduce a LRU cache to avoid searches that occur frequently from the enrich processor. Relates to elastic#48988
Will do, opened #77259 |
Introduce a LRU cache to avoid searches that occur frequently
from the enrich processor.
Relates to #48988