-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Scripting: Per-context script cache, default off #52855
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
Scripting: Per-context script cache, default off #52855
Conversation
* Adds per context settings: `script.context.${CONTEXT}.cache_max_size` ~ `script.cache.max_size` `script.context.${CONTEXT}.cache_expire` ~ `script.cache.expire` `script.context.${CONTEXT}.max_compilations_rate` ~ `script.max_compilations_rate` * General script cache is used if there are no cache settings or if the general settings are used. * Context script cache is used if there are any context cache settings and no general cache settings. * Mixed context and general cache settings are an error. * Context cache settings are dynamically updatable. If the general cache is used, these updates are rejected. * Existing general cache setting, `script.max_compilations_rate` remains dynamically updatable. Updates are rejected if context caches are in use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent more time thinking about how we use SCRIPT_MAX_COMPILATIONS_RATE_DEPRECATED
as a sentinel value for determining whether we have overlapping deprecated settings versus new context settings, and I think we need to come up with something different :/ See my comment at those specific lines.
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few comments
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
…TEXT_PREFIX, use `exists` for non-affix settings; Remove general compilation rate exists check in dynamic validator
Blocking this change on fixing affix settings in #52933 |
Allow AffixSetting as validator dependencies. If a validator specifies AffixSettings as a dependency, then `validate(T, Map)` will have the concrete setting in a map. Fixes: elastic#52933
…152-painless-limit-per-context__02__context_specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for all the work here. One very minor comment.
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
…152-painless-limit-per-context__02__context_specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good. I like the new semantics. However I think we can further simplify.
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/script/ScriptService.java
Outdated
Show resolved
Hide resolved
…-> ScriptService, throw to assert
…lambda in SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING
…152-painless-limit-per-context__02__context_specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after all these changes. Thanks for cleaning this up so much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Adds per context settings: `script.context.${CONTEXT}.cache_max_size` ~ `script.cache.max_size` `script.context.${CONTEXT}.cache_expire` ~ `script.cache.expire` `script.context.${CONTEXT}.max_compilations_rate` ~ `script.max_compilations_rate` * Context cache is used if: `script.max_compilations_rate=use-context`. This value is dynamically updatable, so users can switch back to the general cache if desired. * Settings for context caches take the first value that applies: 1) Context specific settings if set, eg `script.context.ingest.cache_max_size` 2) Correlated general setting is set to the non-default value, eg `script.cache.max_size` 3) Context default The reason for 2's inclusion is to allow an easy transition for users who've customized their general cache settings. Using the general cache settings for the context caches results in higher effective settings, since they are multiplied across the number of contexts. So a general cache max size of 200 will become 200 * # of contexts. However, this behavior it will avoid users snapping to a value that is too low for them. Refs: elastic#50152
* Adds per context settings: `script.context.${CONTEXT}.cache_max_size` ~ `script.cache.max_size` `script.context.${CONTEXT}.cache_expire` ~ `script.cache.expire` `script.context.${CONTEXT}.max_compilations_rate` ~ `script.max_compilations_rate` * Context cache is used if: `script.max_compilations_rate=use-context`. This value is dynamically updatable, so users can switch back to the general cache if desired. * Settings for context caches take the first value that applies: 1) Context specific settings if set, eg `script.context.ingest.cache_max_size` 2) Correlated general setting is set to the non-default value, eg `script.cache.max_size` 3) Context default The reason for 2's inclusion is to allow an easy transition for users who've customized their general cache settings. Using the general cache settings for the context caches results in higher effective settings, since they are multiplied across the number of contexts. So a general cache max size of 200 will become 200 * # of contexts. However, this behavior it will avoid users snapping to a value that is too low for them. Backport of: #52855 Refs: #50152
master: 070ea7e |
Adds per context settings:
script.context.${CONTEXT}.cache_max_size
~script.cache.max_size
script.context.${CONTEXT}.cache_expire
~script.cache.expire
script.context.${CONTEXT}.max_compilations_rate
~script.max_compilations_rate
Context cache is used if:
script.max_compilations_rate=use-context
. Thisvalue is dynamically updatable, so users can
switch back to the general cache if desired.
Settings for context caches take the first value
that applies:
script.context.ingest.cache_max_size
value, eg
script.cache.max_size
The reason for 2's inclusion is to allow an easy
transition for users who've customized their general
cache settings.
Using the general cache settings for the context caches
results in higher effective settings, since they are
multiplied across the number of contexts. So a general
cache max size of 200 will become 200 * # of contexts.
However, this behavior it will avoid users snapping to a
value that is too low for them.
Refs: #50152