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

Add Presto #195

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions presto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Presto

Presto is a distributed SQL query engine for big data.
- [Github](https://github.com/prestodb/presto)
- [Homepage](https://prestodb.io)

The benchmarks are based on Presto version `0.287`.

We assume that a Presto cluster is already running. For more information, visit [Getting Started](https://prestodb.io/getting-started/).
Copy link
Member

@alexey-milovidov alexey-milovidov Jun 14, 2024

Choose a reason for hiding this comment

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

Need to add instructions on how to install Presto on an empty machine with Ubuntu on AWS.

These instructions should be in the form of a shell script; see benchmark.sh in other directories.

Choose a reason for hiding this comment

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

It's probably not possible to have a single script to set up a cluster since the environment is complicated, what should I do?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Having a standard setup is important otherwise different setups may not give identical results.

Would be nice if you can do either of the following:

  • You can create an AWS AMI and add that AMI id in the README.
  • You can setup a docker-compose based setup of Presto.

Copy link
Member

Choose a reason for hiding this comment

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

@allenshen13 As the other commenters said already, benchmark.sh is supposed to be as automatic as possible. This ensures reproducibility and comparability with other systems.

Looking at https://prestodb.io/docs/current/installation/deploy-docker.html, it seem fairly easy to deploy a single-node Presto cluster. The JVM config file could be stored within /presto and copied to the right place by "benchmarks.h". It would be great to have Presto included, would you like to continue this PR?


----------
## Steps

1. Access the parquet file through this path: s3://clickhouse-public-datasets/hits_compatible/hits.parquet or just download the parquet file and upload it to an S3 Bucket yourself ex. s3://your-bucket/clickbench-parquet/hits/hits.parquet.
2. Create a new schema named `clickbench_parquet` in the Hive metastore (Hive catalog) and create the hits table in the new schema using the create.sql file. Modify the end of the table creation statement to use the parquet file on S3.
```
WITH (
format = 'PARQUET',
external_location = 's3a://your-bucket/clickbench-parquet/hits/'
);
```
3. Connect to the Presto coordinator and run these commands:
```
git clone https://github.com/ClickHouse/ClickBench
cd ClickBench/presto
chmod +x run.sh
./run.sh
```
111 changes: 111 additions & 0 deletions presto/create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
CREATE TABLE IF NOT EXISTS hits (
"watchid" bigint,
"javaenable" smallint,
"title" varchar(65535),
"goodevent" smallint,
"eventtime" timestamp,
"eventdate" date,
"counterid" int,
"clientip" int,
"regionid" int,
"userid" bigint,
"counterclass" smallint,
"os" smallint,
"useragent" smallint,
"url" varchar(65535),
"referer" varchar(65535),
"isrefresh" smallint,
"referercategoryid" smallint,
"refererregionid" int,
"urlcategoryid" smallint,
"urlregionid" int,
"resolutionwidth" smallint,
"resolutionheight" smallint,
"resolutiondepth" smallint,
"flashmajor" smallint,
"flashminor" smallint,
"flashminor2" varchar(65535),
"netmajor" smallint,
"netminor" smallint,
"useragentmajor" smallint,
"useragentminor" varchar(65535),
"cookieenable" smallint,
"javascriptenable" smallint,
"ismobile" smallint,
"mobilephone" smallint,
"mobilephonemodel" varchar(65535),
"params" varchar(65535),
"ipnetworkid" int,
"traficsourceid" smallint,
"searchengineid" smallint,
"searchphrase" varchar(65535),
"advengineid" smallint,
"isartifical" smallint,
"windowclientwidth" smallint,
"windowclientheight" smallint,
"clienttimezone" smallint,
"clienteventtime" timestamp,
"silverlightversion1" smallint,
"silverlightversion2" smallint,
"silverlightversion3" int,
"silverlightversion4" smallint,
"pagecharset" varchar(65535),
"codeversion" int,
"islink" smallint,
"isdownload" smallint,
"isnotbounce" smallint,
"funiqid" bigint,
"originalurl" varchar(65535),
"hid" int,
"isoldcounter" smallint,
"isevent" smallint,
"isparameter" smallint,
"dontcounthits" smallint,
"withhash" smallint,
"hitcolor" varchar(65535),
"localeventtime" timestamp,
"age" smallint,
"sex" smallint,
"income" smallint,
"interests" smallint,
"robotness" smallint,
"remoteip" int,
"windowname" int,
"openername" int,
"historylength" smallint,
"browserlanguage" varchar(65535),
"browsercountry" varchar(65535),
"socialnetwork" varchar(65535),
"socialaction" varchar(65535),
"httperror" smallint,
"sendtiming" int,
"dnstiming" int,
"connecttiming" int,
"responsestarttiming" int,
"responseendtiming" int,
"fetchtiming" int,
"socialsourcenetworkid" smallint,
"socialsourcepage" varchar(65535),
"paramprice" bigint,
"paramorderid" varchar(65535),
"paramcurrency" varchar(65535),
"paramcurrencyid" smallint,
"openstatservicename" varchar(65535),
"openstatcampaignid" varchar(65535),
"openstatadid" varchar(65535),
"openstatsourceid" varchar(65535),
"utmsource" varchar(65535),
"utmmedium" varchar(65535),
"utmcampaign" varchar(65535),
"utmcontent" varchar(65535),
"utmterm" varchar(65535),
"fromtag" varchar(65535),
"hasgclid" smallint,
"refererhash" bigint,
"urlhash" bigint,
"clid" int
)
WITH (
format = 'PARQUET',
external_location = 's3a://your-bucket/clickbench-parquet/hits/'
);
Archy-X marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 43 additions & 0 deletions presto/queries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
SELECT COUNT(*) FROM hits;
SELECT COUNT(*) FROM hits WHERE AdvEngineID <> 0;
SELECT SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) FROM hits;
SELECT AVG(UserID) FROM hits;
SELECT COUNT(DISTINCT UserID) FROM hits;
SELECT COUNT(DISTINCT SearchPhrase) FROM hits;
SELECT MIN(EventDate), MAX(EventDate) FROM hits;
SELECT AdvEngineID, COUNT(*) FROM hits WHERE AdvEngineID <> 0 GROUP BY AdvEngineID ORDER BY COUNT(*) DESC;
SELECT RegionID, COUNT(DISTINCT UserID) AS u FROM hits GROUP BY RegionID ORDER BY u DESC LIMIT 10;
SELECT RegionID, SUM(AdvEngineID), COUNT(*) AS c, AVG(ResolutionWidth), COUNT(DISTINCT UserID) FROM hits GROUP BY RegionID ORDER BY c DESC LIMIT 10;
SELECT MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhoneModel ORDER BY u DESC LIMIT 10;
SELECT MobilePhone, MobilePhoneModel, COUNT(DISTINCT UserID) AS u FROM hits WHERE MobilePhoneModel <> '' GROUP BY MobilePhone, MobilePhoneModel ORDER BY u DESC LIMIT 10;
SELECT SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT SearchPhrase, COUNT(DISTINCT UserID) AS u FROM hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY u DESC LIMIT 10;
SELECT SearchEngineID, SearchPhrase, COUNT(*) AS c FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT UserID, COUNT(*) FROM hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10;
SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;
SELECT UserID, SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, SearchPhrase LIMIT 10;
SELECT UserID, extract(minute FROM EventTime), SearchPhrase, COUNT(*) FROM hits GROUP BY UserID, extract(minute FROM EventTime), SearchPhrase ORDER BY COUNT(*) DESC LIMIT 10;
SELECT UserID FROM hits WHERE UserID = 435090932899640449;
SELECT COUNT(*) FROM hits WHERE URL LIKE '%google%';
SELECT SearchPhrase, MIN(URL), COUNT(*) AS c FROM hits WHERE URL LIKE '%google%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT SearchPhrase, MIN(URL), MIN(Title), COUNT(*) AS c, COUNT(DISTINCT UserID) FROM hits WHERE Title LIKE '%Google%' AND URL NOT LIKE '%.google.%' AND SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10;
SELECT * FROM hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10;
SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime LIMIT 10;
SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY SearchPhrase LIMIT 10;
SELECT SearchPhrase FROM hits WHERE SearchPhrase <> '' ORDER BY EventTime, SearchPhrase LIMIT 10;
SELECT CounterID, AVG(length(URL)) AS l, COUNT(*) AS c FROM hits WHERE URL <> '' GROUP BY CounterID HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\\1') HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;
SELECT SUM(ResolutionWidth), SUM(ResolutionWidth + 1), SUM(ResolutionWidth + 2), SUM(ResolutionWidth + 3), SUM(ResolutionWidth + 4), SUM(ResolutionWidth + 5), SUM(ResolutionWidth + 6), SUM(ResolutionWidth + 7), SUM(ResolutionWidth + 8), SUM(ResolutionWidth + 9), SUM(ResolutionWidth + 10), SUM(ResolutionWidth + 11), SUM(ResolutionWidth + 12), SUM(ResolutionWidth + 13), SUM(ResolutionWidth + 14), SUM(ResolutionWidth + 15), SUM(ResolutionWidth + 16), SUM(ResolutionWidth + 17), SUM(ResolutionWidth + 18), SUM(ResolutionWidth + 19), SUM(ResolutionWidth + 20), SUM(ResolutionWidth + 21), SUM(ResolutionWidth + 22), SUM(ResolutionWidth + 23), SUM(ResolutionWidth + 24), SUM(ResolutionWidth + 25), SUM(ResolutionWidth + 26), SUM(ResolutionWidth + 27), SUM(ResolutionWidth + 28), SUM(ResolutionWidth + 29), SUM(ResolutionWidth + 30), SUM(ResolutionWidth + 31), SUM(ResolutionWidth + 32), SUM(ResolutionWidth + 33), SUM(ResolutionWidth + 34), SUM(ResolutionWidth + 35), SUM(ResolutionWidth + 36), SUM(ResolutionWidth + 37), SUM(ResolutionWidth + 38), SUM(ResolutionWidth + 39), SUM(ResolutionWidth + 40), SUM(ResolutionWidth + 41), SUM(ResolutionWidth + 42), SUM(ResolutionWidth + 43), SUM(ResolutionWidth + 44), SUM(ResolutionWidth + 45), SUM(ResolutionWidth + 46), SUM(ResolutionWidth + 47), SUM(ResolutionWidth + 48), SUM(ResolutionWidth + 49), SUM(ResolutionWidth + 50), SUM(ResolutionWidth + 51), SUM(ResolutionWidth + 52), SUM(ResolutionWidth + 53), SUM(ResolutionWidth + 54), SUM(ResolutionWidth + 55), SUM(ResolutionWidth + 56), SUM(ResolutionWidth + 57), SUM(ResolutionWidth + 58), SUM(ResolutionWidth + 59), SUM(ResolutionWidth + 60), SUM(ResolutionWidth + 61), SUM(ResolutionWidth + 62), SUM(ResolutionWidth + 63), SUM(ResolutionWidth + 64), SUM(ResolutionWidth + 65), SUM(ResolutionWidth + 66), SUM(ResolutionWidth + 67), SUM(ResolutionWidth + 68), SUM(ResolutionWidth + 69), SUM(ResolutionWidth + 70), SUM(ResolutionWidth + 71), SUM(ResolutionWidth + 72), SUM(ResolutionWidth + 73), SUM(ResolutionWidth + 74), SUM(ResolutionWidth + 75), SUM(ResolutionWidth + 76), SUM(ResolutionWidth + 77), SUM(ResolutionWidth + 78), SUM(ResolutionWidth + 79), SUM(ResolutionWidth + 80), SUM(ResolutionWidth + 81), SUM(ResolutionWidth + 82), SUM(ResolutionWidth + 83), SUM(ResolutionWidth + 84), SUM(ResolutionWidth + 85), SUM(ResolutionWidth + 86), SUM(ResolutionWidth + 87), SUM(ResolutionWidth + 88), SUM(ResolutionWidth + 89) FROM hits;
SELECT SearchEngineID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY SearchEngineID, ClientIP ORDER BY c DESC LIMIT 10;
SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits WHERE SearchPhrase <> '' GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;
SELECT WatchID, ClientIP, COUNT(*) AS c, SUM(IsRefresh), AVG(ResolutionWidth) FROM hits GROUP BY WatchID, ClientIP ORDER BY c DESC LIMIT 10;
SELECT URL, COUNT(*) AS c FROM hits GROUP BY URL ORDER BY c DESC LIMIT 10;
SELECT 1, URL, COUNT(*) AS c FROM hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10;
SELECT ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3, COUNT(*) AS c FROM hits GROUP BY ClientIP, ClientIP - 1, ClientIP - 2, ClientIP - 3 ORDER BY c DESC LIMIT 10;
SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND DontCountHits = 0 AND IsRefresh = 0 AND URL <> '' GROUP BY URL ORDER BY PageViews DESC LIMIT 10;
SELECT Title, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND DontCountHits = 0 AND IsRefresh = 0 AND Title <> '' GROUP BY Title ORDER BY PageViews DESC LIMIT 10;
SELECT URL, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 AND IsLink <> 0 AND IsDownload = 0 GROUP BY URL ORDER BY PageViews DESC OFFSET 1000 LIMIT 10;
SELECT TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END AS Src, URL AS Dst, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, CASE WHEN (SearchEngineID = 0 AND AdvEngineID = 0) THEN Referer ELSE '' END, URL ORDER BY PageViews DESC OFFSET 1000 LIMIT 10;
SELECT URLHash, EventDate, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 AND TraficSourceID IN (-1, 6) AND RefererHash = 3594120000172545465 GROUP BY URLHash, EventDate ORDER BY PageViews DESC OFFSET 100 LIMIT 10;
SELECT WindowClientWidth, WindowClientHeight, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-01') AND EventDate <= DATE('2013-07-31') AND IsRefresh = 0 AND DontCountHits = 0 AND URLHash = 2868770270353813622 GROUP BY WindowClientWidth, WindowClientHeight ORDER BY PageViews DESC OFFSET 10000 LIMIT 10;
SELECT DATE_FORMAT(EventTime, '%Y-%m-%d %H:%i:00') AS M, COUNT(*) AS PageViews FROM hits WHERE CounterID = 62 AND EventDate >= DATE('2013-07-14') AND EventDate <= DATE('2013-07-15') AND IsRefresh = 0 AND DontCountHits = 0 GROUP BY DATE_FORMAT(EventTime, '%Y-%m-%d %H:%i:00') ORDER BY DATE_FORMAT(EventTime, '%Y-%m-%d %H:%i:00') OFFSET 1000 LIMIT 10;
54 changes: 54 additions & 0 deletions presto/results/r5.4xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"system": "Presto",
"date": "2024-05-29",
"machine": "r5.4xlarge",
"cluster_size": 8,
"tags": ["Java", "column-oriented", "analytical", "aws"],
"load_time": 0,
"data_size": 14779976446,
"result": [
[0.402341,0.14951,0.107155],
[0.865487,0.485257,0.449763],
[1.08203,0.582326,0.578284],
[0.903962,0.639918,0.323288],
[1.038797,0.583585,0.545404],
[1.743717,1.229381,0.83916],
[0.435739,0.369782,0.218763],
[0.465126,0.721039,0.462598],
[1.656187,1.494111,1.15386],
[2.26484,2.182731,2.15843],
[1.613815,0.862942,0.742684],
[0.86709,0.883782,0.927072],
[1.16082,0.895078,0.941215],
[1.598979,1.759072,1.707651],
[0.995013,1.041356,1.022605],
[1.006878,0.546081,0.547675],
[1.697766,1.561924,1.643762],
[1.584176,1.468025,1.542148],
[2.549345,1.837268,1.792735],
[1.145295,0.724914,0.772503],
[4.041169,2.178436,1.944694],
[1.914926,1.840498,1.810634],
[3.332607,2.360467,2.354433],
[16.975438,14.76662,14.693455],
[0.86101,0.872084,0.925221],
[0.724581,1.692928,2.356877],
[0.944508,0.901719,0.911748],
[2.019593,2.060255,1.918732],
[6.497533,5.79828,5.426521],
[4.74789,4.869418,5.262414],
[1.453415,1.323398,1.381095],
[2.206553,1.681973,1.482222],
[3.807869,3.670072,3.547302],
[3.077398,2.848014,2.775159],
[2.998571,2.806663,3.031418],
[1.175695,1.365279,1.179885],
[1.436026,1.408173,1.412845],
[0.988737,1.093128,0.917244],
[1.279827,1.210123,1.225414],
[2.491988,2.587187,2.417893],
[1.147617,0.949788,0.825057],
[0.941498,0.845771,0.796313],
[0.935166,0.912135,0.964027]
]
}
54 changes: 54 additions & 0 deletions presto/results/r5.8xlarge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"system": "Presto",
"date": "2024-05-28",
"machine": "r5.8xlarge",
"cluster_size": 16,
"tags": ["Java", "column-oriented", "analytical", "aws"],
"load_time": 0,
"data_size": 14779976446,
"result": [
[0.272035,0.099357,0.095395],
[1.030367,0.42591,0.317257],
[0.984987,0.566008,0.600528],
[1.101233,0.493982,0.310671],
[0.836894,0.551534,0.374873],
[1.122529,0.687931,0.677321],
[0.517202,0.221515,0.203558],
[0.337413,0.410747,0.432223],
[1.014921,0.906677,0.973607],
[1.676214,1.227126,1.282348],
[0.691311,0.586472,0.607044],
[0.758122,0.744563,0.756044],
[0.82537,0.782558,0.725295],
[1.132906,1.090836,1.231984],
[0.774198,0.757493,0.926341],
[0.750924,0.919412,0.425668],
[1.042794,1.081188,1.121617],
[0.977894,1.103013,1.936754],
[2.003017,1.40578,1.46733],
[0.966183,0.618001,0.622388],
[4.699365,1.885068,1.878264],
[1.699708,1.7211,1.782673],
[3.645092,2.153739,2.197017],
[18.776412,14.377456,13.632139],
[0.901729,0.722576,0.776895],
[0.673601,0.528899,0.592662],
[0.706932,1.111863,0.887926],
[1.864925,1.843051,2.01332],
[5.212292,4.749804,4.849626],
[4.017339,3.97698,3.797817],
[1.574938,1.249199,1.113597],
[2.108874,1.30992,1.301631],
[2.507421,2.557384,2.607363],
[2.783502,2.155876,2.391084],
[2.150036,2.168119,2.484738],
[0.91182,0.944813,0.840529],
[1.84562,1.463736,1.434443],
[0.940396,1.105479,0.981559],
[1.292506,1.326009,1.438981],
[2.678968,2.712577,2.823577],
[1.243846,0.958157,0.872599],
[0.834459,0.95686,0.886505],
[1.043745,0.970481,1.01311]
]
}
13 changes: 13 additions & 0 deletions presto/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

TRIES=3

queryNum=1
cat queries.sql | while read query; do
for i in $(seq 1 $TRIES); do
echo "Running query $queryNum: $query"
/opt/presto-cli --server 127.0.0.1:8080 --user clickbench_runner --catalog "hive" --schema "clickbench_parquet" --session offset_clause_enabled=true --execute "${query}"
execution_time=$(/opt/presto-cli --server 127.0.0.1:8080 --user clickbench_manager --execute "SELECT date_diff('millisecond',started,\"end\") FROM system.runtime.queries WHERE user='clickbench_runner' ORDER BY created DESC LIMIT 1" | tr -d '"') && echo "Execution time: ${execution_time}ms"
done
((queryNum++))
done