This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved parquet read benches (#533)
- Loading branch information
1 parent
fb8b6f3
commit ee68d18
Showing
7 changed files
with
207 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
runs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import timeit | ||
import io | ||
import os | ||
import json | ||
|
||
import pyarrow.parquet | ||
|
||
|
||
def _bench_single(log2_size: int, column: str, use_dict: bool) -> float: | ||
if use_dict: | ||
path = f"fixtures/pyarrow3/v1/dict/benches_{2**log2_size}.parquet" | ||
else: | ||
path = f"fixtures/pyarrow3/v1/benches_{2**log2_size}.parquet" | ||
with open(path, "rb") as f: | ||
data = f.read() | ||
data = io.BytesIO(data) | ||
|
||
def f(): | ||
pyarrow.parquet.read_table(data, columns=[column]) | ||
|
||
seconds = timeit.Timer(f).timeit(number=512) / 512 | ||
ns = seconds * 1000 * 1000 * 1000 | ||
return ns | ||
|
||
|
||
def _report(name: str, result: float): | ||
path = f"benchmarks/runs/{name}/new" | ||
os.makedirs(path, exist_ok=True) | ||
with open(f"{path}/estimates.json", "w") as f: | ||
json.dump({"mean": {"point_estimate": result}}, f) | ||
|
||
|
||
def _bench(size, ty): | ||
column, use_dict = { | ||
"i64": ("int64", False), | ||
"bool": ("bool", False), | ||
"utf8": ("string", False), | ||
"utf8 dict": ("string", True), | ||
}[ty] | ||
|
||
result = _bench_single(size, column, use_dict) | ||
print(result) | ||
_report(f"read {ty} 2_{size}", result) | ||
|
||
|
||
for size in range(10, 22, 2): | ||
for ty in ["i64", "bool", "utf8", "utf8 dict"]: | ||
print(size, ty) | ||
_bench(size, ty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import subprocess | ||
|
||
|
||
# run pyarrow | ||
subprocess.call(["python", "benchmarks/bench_read.py"]) | ||
|
||
|
||
for ty in ["i64", "bool", "utf8", "utf8 dict"]: | ||
args = [ | ||
"cargo", | ||
"bench", | ||
"--features", | ||
"io_parquet,io_parquet_compression", | ||
"--bench", | ||
"read_parquet", | ||
"--", | ||
f"{ty} 2", | ||
] | ||
|
||
subprocess.call(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import json | ||
import os | ||
|
||
|
||
def _read_reports(engine: str): | ||
root = { | ||
"arrow2": "target/criterion", | ||
"pyarrow": "benchmarks/runs", | ||
}[engine] | ||
|
||
result = [] | ||
for item in os.listdir(root): | ||
if item == "report": | ||
continue | ||
|
||
with open(os.path.join(root, item, "new", "estimates.json")) as f: | ||
data = json.load(f) | ||
|
||
ms = data["mean"]["point_estimate"] / 1000 | ||
task = item.split()[0] | ||
type = " ".join(item.split()[1:-1]) | ||
size = int(item.split()[-1].split("_")[1]) | ||
result.append( | ||
{ | ||
"engine": engine, | ||
"task": task, | ||
"type": type, | ||
"size": size, | ||
"time": ms, | ||
} | ||
) | ||
return result | ||
|
||
|
||
def _print_report(result): | ||
for ty in ["i64", "bool", "utf8", "utf8 dict"]: | ||
print(ty) | ||
r = filter(lambda x: x["type"] == ty, result) | ||
r = sorted(r, key=lambda x: x["size"]) | ||
for row in r: | ||
print(row["time"]) | ||
|
||
|
||
def print_report(): | ||
for engine in ["arrow2", "pyarrow"]: | ||
print(engine) | ||
result = _read_reports(engine) | ||
_print_report(result) | ||
|
||
|
||
print_report() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters