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

Scripting: Per-context script cache, default off #52855

Conversation

stu-elastic
Copy link
Contributor

@stu-elastic stu-elastic commented Feb 26, 2020

  • 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: #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`

* 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.
Copy link
Contributor

@jdconrad jdconrad left a 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.

@jdconrad jdconrad added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Feb 27, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Scripting)

Copy link
Member

@rjernst rjernst left a 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

…TEXT_PREFIX, use `exists` for non-affix settings; Remove general compilation rate exists check in dynamic validator
@stu-elastic
Copy link
Contributor Author

Blocking this change on fixing affix settings in #52933

Copy link
Contributor

@jdconrad jdconrad left a 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.

Copy link
Member

@rjernst rjernst left a 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.

Copy link
Contributor

@jdconrad jdconrad left a 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.

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stu-elastic stu-elastic merged commit 070ea7e into elastic:master Mar 18, 2020
stu-elastic added a commit to stu-elastic/elasticsearch that referenced this pull request Mar 18, 2020
* 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
stu-elastic added a commit that referenced this pull request Mar 18, 2020
* 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
@stu-elastic
Copy link
Contributor Author

master: 070ea7e
7.x: cdbee32

yyff pushed a commit to yyff/elasticsearch that referenced this pull request Apr 17, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v7.7.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants