-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: Enable visualizing a query profile #124361
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
ESQL: Enable visualizing a query profile #124361
Conversation
Invoke it like this: ./gradlew x-pack:plugin:esql:qa:testFixtures:parseProfile --args='~/elasticsearch/profile.json ~/elasticsearch/output.json' Then it can be imported into e.g. perfetto or into Chromes trace viewer (about:tracing)
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
| Path outputFileName = Path.of(args[1].replaceFirst("^~", System.getProperty("user.home"))).toAbsolutePath(); | ||
|
|
||
| Map<String, Object> map; | ||
| try (InputStream input = Files.newInputStream(inputFileName)) { |
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 believe you originally started with jq. What was the final reason to replace it with java?
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.
- It was too messy to properly emit metadata events for nodes, assign correct
tidandpids etc. - If we want to evolve either the visualization/profile parsing or the profile itself, it's much easier to do so in Java.
- I can nicely test this.
| Map<String, Object> map; | ||
| try (InputStream input = Files.newInputStream(inputFileName)) { | ||
| logger.info("Starting to parse {}", inputFileName); | ||
| map = XContentHelper.convertToMap(JsonXContent.jsonXContent, input, true); |
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 wonder if we should consider model rather than a map?
Possibly something like:
public record Response(Profile profile) {}
public record Profile(List<Driver> drivers) {}
public record Driver(
@JsonProperty("task_description") String taskDescription,
@JsonProperty("cluster_name") String cluster,
@JsonProperty("node_name") String node,
@JsonProperty("start_millis") long startMillis,
@JsonProperty("stop_millis") long stopMillis,
List<Operator> operators
) {}
public record Operator(String operator) {}
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.
Thank you, with Jackson it's indeed much clearer. I use this approach now + updated the tests accordingly.
💔 Backport failed
You can use sqren/backport to manually backport by running |
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation |
To understand query performance, we often peruse the output of `_query`-requests run with `"profile": true`. This is difficult when the query runs in a large cluster with many nodes and shards, or in case of CCQ. This adds an option to visualize a query using Chromium's/Chrome's builtin `about:tracing` - or, for even better visuals and querying the different drivers via SQL, perfetto (c.f. https://ui.perfetto.dev/). To use, save the JSON output of a query run with `"profile": true` to a file, like `output.json` and then invoke the following Gradle task: ``` ./gradlew x-pack:plugin:esql:tools:parseProfile --args='~/output.json ~/parsed_profile.json' ``` Either open `about:tracing` in Chromium/Chrome  Or head over to https://ui.perfetto.dev (build locally in case of potentially sensitive data in the profille):  Every slice is a driver, the colors indicating the ratio of cpu time over total time. - In Perfetto, essentials like duration, cpu duration, timestamp and a few others can be queried via SQL - this allows e.g. querying for all drivers that spent more than 50% of their time waiting and other fun things.  - Details about a driver, esp. which operators it ran, are available when clicking the driver's slice.  (cherry picked from commit fc4d8d6) # Conflicts: # x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java
To understand query performance, we often peruse the output of `_query`-requests run with `"profile": true`. This is difficult when the query runs in a large cluster with many nodes and shards, or in case of CCQ. This adds an option to visualize a query using Chromium's/Chrome's builtin `about:tracing` - or, for even better visuals and querying the different drivers via SQL, perfetto (c.f. https://ui.perfetto.dev/). To use, save the JSON output of a query run with `"profile": true` to a file, like `output.json` and then invoke the following Gradle task: ``` ./gradlew x-pack:plugin:esql:tools:parseProfile --args='~/output.json ~/parsed_profile.json' ``` Either open `about:tracing` in Chromium/Chrome  Or head over to https://ui.perfetto.dev (build locally in case of potentially sensitive data in the profille):  Every slice is a driver, the colors indicating the ratio of cpu time over total time. - In Perfetto, essentials like duration, cpu duration, timestamp and a few others can be queried via SQL - this allows e.g. querying for all drivers that spent more than 50% of their time waiting and other fun things.  - Details about a driver, esp. which operators it ran, are available when clicking the driver's slice. 
* ESQL: Enable visualizing a query profile (#124361) To understand query performance, we often peruse the output of `_query`-requests run with `"profile": true`. This is difficult when the query runs in a large cluster with many nodes and shards, or in case of CCQ. This adds an option to visualize a query using Chromium's/Chrome's builtin `about:tracing` - or, for even better visuals and querying the different drivers via SQL, perfetto (c.f. https://ui.perfetto.dev/). To use, save the JSON output of a query run with `"profile": true` to a file, like `output.json` and then invoke the following Gradle task: ``` ./gradlew x-pack:plugin:esql:tools:parseProfile --args='~/output.json ~/parsed_profile.json' ``` Either open `about:tracing` in Chromium/Chrome  Or head over to https://ui.perfetto.dev (build locally in case of potentially sensitive data in the profille):  Every slice is a driver, the colors indicating the ratio of cpu time over total time. - In Perfetto, essentials like duration, cpu duration, timestamp and a few others can be queried via SQL - this allows e.g. querying for all drivers that spent more than 50% of their time waiting and other fun things.  - Details about a driver, esp. which operators it ran, are available when clicking the driver's slice.  (cherry picked from commit fc4d8d6) # Conflicts: # x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java * Account for missing driver descr., node, cluster
To understand query performance, we often peruse the output of
_query-requests run with"profile": true.This is difficult when the query runs in a large cluster with many nodes and shards, or in case of CCQ.
This adds an option to visualize a query using Chromium's/Chrome's builtin
about:tracing- or, for even better visuals and querying the different drivers via SQL, perfetto (c.f. https://ui.perfetto.dev/).To use, save the JSON output of a query run with
"profile": trueto a file, likeoutput.jsonand then invoke the following Gradle task:Either open


about:tracingin Chromium/ChromeOr head over to https://ui.perfetto.dev (build locally in case of potentially sensitive data in the profille):
Every slice is a driver, the colors indicating the ratio of cpu time over total time.
In Perfetto, essentials like duration, cpu duration, timestamp and a few others can be queried via SQL - this allows e.g. querying for all drivers that spent more than 50% of their time waiting and other fun things.

Details about a driver, esp. which operators it ran, are available when clicking the driver's slice.
