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

Support read only variables in painless #49884

Closed
stu-elastic opened this issue Dec 5, 2019 · 3 comments
Closed

Support read only variables in painless #49884

stu-elastic opened this issue Dec 5, 2019 · 3 comments
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache high hanging fruit Team:Core/Infra Meta label for core/infra team

Comments

@stu-elastic
Copy link
Contributor

Read only variables would help users reason about their code and allow us to avoid several hash look ups for unchanged variables.

Migrated from: #31009

@stu-elastic stu-elastic added the :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache label Dec 5, 2019
@elasticmachine
Copy link
Collaborator

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

@stu-elastic
Copy link
Contributor Author

This enables optimizations per doc that is not possible right now. Eg a param does not change per doc but maybe recomputed. This would enable us to avoid the lookup per doc. The accessor for a doc value should be reusable as it gets changed behind the scenes.

Notes:

  • Classbindings assume read only values, but there this invariant is not ensured.
  • Subclassing classes like Map would be a lot of work for nested Maps (eg watcher input)
  • Change eg params to unmodifiable map, which doesn't work with arrays
  • Can use an annotation in whitelist @readonly for methods that are safe
  • May have to change doc to a non-map, we currently use a map for bracket access. This will change with Annotate whitelisted methods for bracket access #52589.
    • Will still have to track the output from @readonly whitelisted methods for correctness.
  • Modify IR tree to add caching once @readonly tracking is implemented.

@rjernst rjernst added the Team:Core/Infra Meta label for core/infra team label May 4, 2020
@rjernst rjernst added the needs:triage Requires assignment of a team area label label Dec 3, 2020
@stu-elastic stu-elastic added high hanging fruit and removed needs:triage Requires assignment of a team area label labels Dec 9, 2020
@rjernst
Copy link
Member

rjernst commented May 25, 2024

This has been open for quite a while, and we haven't made much progress on this due to focus in other areas. For now I'm going to close this as something we aren't planning on implementing. We can re-open it later if needed.

@rjernst rjernst closed this as completed May 25, 2024
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 high hanging fruit Team:Core/Infra Meta label for core/infra team
Projects
None yet
Development

No branches or pull requests

3 participants