GithubHelp home page GithubHelp logo

varadaio / presto-workload-analyzer Goto Github PK

View Code? Open in Web Editor NEW
135.0 9.0 37.0 131 KB

The Workload Analyzer collects Presto® and Trino workload statistics, and analyzes them

License: GNU General Public License v3.0

Dockerfile 0.20% Python 69.03% HTML 30.77%
presto prestodb prestosql trino visualization analysis analyzer workloads cluster trinodb

presto-workload-analyzer's Introduction

Presto Workload Analyzer

Presto Workload Analyzer Logo

The Workload Analyzer collects Presto® and Trino workload statistics, and analyzes them. The analysis provides improved visibility into your analytical workloads, and enables query optimization - to enhance cluster performance.

The Presto® Workload Analyzer collects, and stores, QueryInfo JSONs for queries executed while it is running, and any historical queries held in the Presto® Coordinator memory.

The collection process has negligible compute-costs, and does not impact cluster query execution in any way. Ensure that sufficient disk space is available in your working directory. Typically, a compressed JSON file size will be 50kb - 200kb.

Table of contents

Features

  • Continuously collects and stores QueryInfo JSONs, in the background without impacting query performance.
  • Summarizes key query metrics to a summary.jsonl file.
  • Generates an analysis report:
    • Query detail- query peak memory, input data read by query, and joins distribution.
    • Table activity- wall time utilization, and input bytes read, by table scans.
    • Presto® Operators- wall time usage, and input bytes read, by operator.

Supported Versions of Presto

The Workload Analyzer supports the following versions:

  1. Trino (FKA PrestoSQL)- 402 and older.
  2. PrestoDB- 0.245.1 and older.
  3. Starburst Enterprise- 402e and older.
  4. Dataproc- 1.5.x and older.

Although the Workload Analyzer may run with newer versions of Presto®, these scenarios have not been tested.

Installation

For installation, see here.

Usage

Local machine/ Remote machine

First, go to the analyzer directory, where the Workload Analyzer Python code can be found.

cd analyzer/

To collect statistics from your cluster, run the following script for a period that will provide a representative sample of your workload.

./collect.py -c http://<presto-coordinator>:8080 --username-request-header "X-Trino-User" -o ./JSONs/ --loop

Notes:

  1. In most cases, this period will be between 5 and 15 days, with longer durations providing more significant analysis.
  2. The above command will continue running until stopped by the user (Ctrl+C).

To analyze the downloaded JSONs directory (e.g. ./JSONs/) and generate a zipped HTML report, execute the following command:

./extract.py -i ./JSONs/ && ./analyze.py -i ./JSONs/summary.jsonl.gz -o ./output.zip

Docker

To collect statistics from your cluster, run the following script for a period that will provide a representative sample of your workload.

$ mkdir JSONs/
$ docker run -v $PWD/JSONs/:/app/JSONs analyzer ./analyzer/collect.py -c http://$PRESTO_COORDINATOR:8080 --username-request-header "X-Trino-User" -o JSONs/ --loop

To analyze the downloaded JSONs directory (e.g. ./JSONs/), and generate a zipped HTML report, execute the following commands:

$ docker run -v $PWD/JSONs/:/app/JSONs analyzer ./analyzer/extract.py -i JSONs/
$ docker run -v $PWD/JSONs/:/app/JSONs analyzer ./analyzer/analyze.py -i JSONs/summary.jsonl.gz -o JSONs/output.zip

Notes:

  1. In most cases, this period will be between 5 and 15 days, with longer durations providing more significant analysis.
  2. The above command will continue running until stopped by the user (Ctrl+C).

Screencasts

See the following screencasts for usage examples:

Collection

asciicast

Analysis

asciicast

Advanced Features

  • In exceptional circumstances, it may be desirable to do one or more of the following:
  1. Obfuscate the schema names
  2. Remove the SQL queries from the summary file
  3. Analyze queries for a specific schema (joins with other schemas are included)

To enable these requirements, the ./jsonl_process.py script may be executed, after the ./extract.py script, but before the ./analyze.py script.

In the example below, only queries from the transactions schema are kept, and the SQL queries are removed from the new summary file:

./jsonl_process.py -i ./JSONs/summary.jsonl.gz -o ./processed_summary.jsonl.gz --filter-schema transactions --remove-query 

In the following example, all the schema names are obfuscated:

./jsonl_process.py -i ./JSONs/summary.jsonl.gz -o ./processed_summary.jsonl.gz --rename-schemas 

In the following example, all the partition and user names are obfuscated:

./jsonl_process.py -i ./JSONs/summary.jsonl.gz -o ./processed_summary.jsonl.gz --rename-partitions --rename-user 

After the ./jsonl_process.py script has been executed, to generate a report based on the new summary file, run:

./analyze.py -i ./processed_summary.jsonl.gz -o ./output.zip
  • To create a high-contrast report, use the --high-contrast-mode parameter, for example:
./analyze.py --high-contrast-mode -i ./JSONs/summary.jsonl.gz -o ./output.zip

Notes

Presto® is a trademark of The Linux Foundation.

presto-workload-analyzer's People

Contributors

duhanmin avatar guy-mast avatar ns-mkusper avatar rzeyde-varada avatar sbernauer avatar vromanv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

presto-workload-analyzer's Issues

faced many erros while extracting

I am using trino 406 and faced below errors while doing extract and I am using python 3.8.
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 28/28 [00:00<00:00, 11342.53files/s]
[2023-07-08 12:47:15.354243] INFO: analyze: 28 queries loaded
0%| | 0/28 [00:00<?, ?graphs/s][2023-07-08 12:47:15.685055] ERROR: analyze: failed to generate scheduled_by_date
Traceback (most recent call last):
File "./analyze.py", line 1254, in main
item["doc"]["roots"]["references"].sort(key=lambda r: (r["type"], r["id"]))
TypeError: list indices must be integers or slices, not str
4%|████▉ | 1/28 [00:00<00:08, 3.04graphs/s][2023-07-08 12:47:15.791569] ERROR: analyze: failed to generate scheduled_by_hour
Traceback (most recent call last):
File "./analyze.py", line 1254, in main
item["doc"]["roots"]["references"].sort(key=lambda r: (r["type"], r["id"]))
TypeError: list indices must be integers or slices, not str
7%|█████████▊ | 2/28 [00:00<00:05, 5.05graphs/s][2023-07-08 12:47:15.887112] ERROR: analyze: failed to generate input_by_date
Traceback (most recent call last):
File "./analyze.py", line 1254, in main
item["doc"]["roots"]["references"].sort(key=lambda r: (r["type"], r["id"]))
TypeError: list indices must be integers or slices, not str
[2023-07-08 12:47:15.976779] ERROR: analyze: failed to generate input_by_hour
Traceback (most recent call last):
File "./analyze.py", line 1254, in main
item["doc"]["roots"]["references"].sort(key=lambda r: (r["type"], r["id"]))
TypeError: list indices must be integers or slices, not str
14%|███████████████████▋ | 4/28 [00:00<00:03, 7.58graphs/s][2023-07-08 12:47:16.111376] ERROR: analyze: failed to generate queries_by_date
Traceback (most recent call last):
File "./analyze.py", line 1254, in main
item["doc"]["roots"]["references"].sort(key=lambda r: (r["type"], r["id"]))
TypeError: list indices must be integers or slices, not str
18%|████████████████████████▋ | 5/28 [00:00<00:03, 7.53graphs/s][2023-07-08 12:47:16.222095] ERROR: analyze: failed to generate queries_by_hour
Traceback (most recent call last):
File "./analyze.py", line 1254, in main
item["doc"]["roots"]["references"].sort(key=lambda r: (r["type"], r["id"]))
TypeError: list indices must be integers or slices, not str
21%|█████████████████████████████▌ | 6/28 [00:00<00:02, 7.94graphs/s][2023-07-08 12:47:16.341786] ERROR: analyze: failed to generate peak_mem_by_query

failed to generate joins_selectivity because of DynamicFilterSourceOperator

The analyzer is not able to deal with DynamicFilterSourceOperator to generate the graphs related to joins:

ERROR: analyze: missing keys ('LookupJoinOperator', 'HashBuilderOperator') in {'DynamicFilterSourceOperator': {'node_id': '398', 'type': 'DynamicFilterSourceOperator', 'input_size': 17950.0, 'output_size': 17950.0, 'network_size': 0.0, 'input_rows': 359, 'output_rows': 359, 'network_rows': 0, 'peak_mem': 0.0, 'input_cpu': 0.0007441399999999999, 'output_cpu': 0.00037216, 'finish_cpu': 0.0, 'input_wall': 0.0007452899999999999, 'output_wall': 0.00036805, 'finish_wall': 0.0, 'blocked_wall': 0.0}, 'HashBuilderOperator': {'node_id': '398', 'type': 'HashBuilderOperator', 'input_size': 17950.0, 'output_size': 17950.0, 'network_size': 0.0, 'input_rows': 359, 'output_rows': 359, 'network_rows': 0, 'peak_mem': 196860.0, 'input_cpu': 0.0008561799999999999, 'output_cpu': 0.0, 'finish_cpu': 0.0, 'input_wall': 0.0008708499999999999, 'output_wall': 0.0, 'finish_wall': 0.0, 'blocked_wall': 0.0}}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.