elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.41k stars 24.56k forks source link

Painless Compiler Extensibility #53702

Open stu-elastic opened 4 years ago

stu-elastic commented 4 years ago

The Painless compiler can produce more performant code and allow better integration with other query languages by reworking it’s internal structure.

Changing the structure allows us to:

After this work, we will be able to:

The monolithic implementation of the existing compiler complicates both of these goals.

We will change the implementation of the compiler to a modern structure:

Frontend -> Intermediate Representation -> Compiler Phases -> Backend

This will allow us to incrementally add performance enhancements and provide an obvious integration point for other languages (they provide the frontend & initial IR).

Background:

Painless uses a single tree with several embedded phases for doing:

This design has reached its limits, it has several problems:

In progress:

The tree is currently split into a "user" tree and an "IR" tree.

User Tree:
IR Tree:

Outcomes:

Related PRs: https://github.com/elastic/elasticsearch/pull/51278 https://github.com/elastic/elasticsearch/pull/51452 https://github.com/elastic/elasticsearch/pull/51452 https://github.com/elastic/elasticsearch/pull/51690 https://github.com/elastic/elasticsearch/pull/51776 https://github.com/elastic/elasticsearch/pull/51954 https://github.com/elastic/elasticsearch/pull/52612 https://github.com/elastic/elasticsearch/pull/52783 https://github.com/elastic/elasticsearch/pull/52915 https://github.com/elastic/elasticsearch/pull/53075 https://github.com/elastic/elasticsearch/pull/53348 https://github.com/elastic/elasticsearch/pull/53685

Related Issues: https://github.com/elastic/elasticsearch/issues/49870 https://github.com/elastic/elasticsearch/issues/49869

elasticmachine commented 4 years ago

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

stu-elastic commented 3 years ago

Still in progress.