forked from pola-rs/polars-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
200 lines (154 loc) · 6.05 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
.DEFAULT_GOAL := help
# Variables
PYTHONPATH =
SHELL = /bin/bash
VENV = .venv
VENV_BIN = $(VENV)/bin
SCALE_FACTOR ?= 1.0
# Phony targets
.PHONY: \
run-10-times \
bump-deps \
fmt \
pre-commit \
run-polars \
run-fireducks \
run-cudf \
run-polars-eager \
run-polars-gpu \
run-polars-streaming \
run-polars-no-env \
run-polars-gpu-no-env \
run-duckdb \
run-pandas \
run-pyspark \
run-dask \
run-modin \
run-all \
run-all-polars \
run-all-gpu \
plot \
clean \
clean-tpch-dbgen \
clean-tables \
help
## Setup and Installation
.venv: ## Set up Python virtual environment
curl -LsSf https://astral.sh/uv/install.sh | sh
PATH=$$HOME/.cargo/bin:$$PATH uv venv --python 3.11 --seed
install-deps: .venv .venv/.installed-deps ## Install Python project dependencies if not already installed
.venv/.installed-deps: | .venv ## Install only if dependencies aren't already installed
@unset CONDA_PREFIX \
&& $(VENV_BIN)/python -m pip install --upgrade uv \
&& $(VENV_BIN)/uv pip install --compile -r requirements.txt --extra-index-url=https://pypi.nvidia.com \
&& touch $@
bump-deps: .venv ## Bump Python project dependencies
$(VENV_BIN)/python -m pip install --upgrade uv
$(VENV_BIN)/uv pip compile requirements.in -o requirements.txt
rm -f .venv/.installed-deps
bump-deps-with-gpu: .venv ## Bump Python project dependencies with GPU support
$(VENV_BIN)/python -m pip install --upgrade uv
$(VENV_BIN)/uv pip compile --extra-index-url=https://pypi.nvidia.com requirements.in requirements-gpu.in -o requirements.txt
rm -f .venv/.installed-deps
## Code Quality and Formatting
fmt: ## Run autoformatting and linting
$(VENV_BIN)/ruff check
$(VENV_BIN)/ruff format
$(VENV_BIN)/mypy
pre-commit: fmt ## Run all code quality checks
## Data Preparation
tables: data/tables/scale-$(SCALE_FACTOR)/.done ## Alias for the dataset generation
data/tables/scale-$(SCALE_FACTOR)/.done: | install-deps ## Generate data tables if not already generated
$(MAKE) -C tpch-dbgen dbgen
(cd tpch-dbgen && ./dbgen -vf -s $(SCALE_FACTOR))
mkdir -p "data/tables/scale-$(SCALE_FACTOR)"
mv tpch-dbgen/*.tbl data/tables/scale-$(SCALE_FACTOR)/
$(VENV_BIN)/python -m scripts.prepare_data
rm -rf data/tables/scale-$(SCALE_FACTOR)/*.tbl
touch $@
## Benchmark Runs
run-polars: install-deps tables ## Run Polars benchmarks
$(VENV_BIN)/python -m queries.polars
run-fireducks: install-deps tables ## Run Fireducks benchmarks
$(VENV_BIN)/python -m queries.fireducks
run-cudf: install-deps tables ## Run cuDF benchmarks
$(VENV_BIN)/python -m queries.cudf
run-polars-eager: install-deps tables ## Run Polars benchmarks in eager mode
POLARS_EAGER=1 $(VENV_BIN)/python -m queries.polars
run-polars-gpu: install-deps tables ## Run Polars GPU benchmarks
POLARS_GPU=1 $(VENV_BIN)/python -m queries.polars
run-polars-streaming: install-deps tables ## Run Polars streaming benchmarks
POLARS_STREAMING=1 $(VENV_BIN)/python -m queries.polars
run-polars-no-env: ## Run Polars benchmarks without virtual environment
$(MAKE) -C tpch-dbgen dbgen
(cd tpch-dbgen && ./dbgen -f -s $(SCALE_FACTOR))
mkdir -p "data/tables/scale-$(SCALE_FACTOR)"
mv tpch-dbgen/*.tbl data/tables/scale-$(SCALE_FACTOR)/
python -m scripts.prepare_data
rm -rf data/tables/scale-$(SCALE_FACTOR)/*.tbl
python -m queries.polars
run-polars-gpu-no-env: run-polars-no-env ## Run Polars CPU and GPU benchmarks without virtual environment
RUN_POLARS_GPU=true CUDA_MODULE_LOADING=EAGER python -m queries.polars
run-duckdb: install-deps tables ## Run DuckDB benchmarks
$(VENV_BIN)/python -m queries.duckdb
run-pandas: install-deps tables ## Run pandas benchmarks
$(VENV_BIN)/python -m queries.pandas
run-pyspark: install-deps tables ## Run PySpark benchmarks
$(VENV_BIN)/python -m queries.pyspark
run-dask: install-deps tables ## Run Dask benchmarks
$(VENV_BIN)/python -m queries.dask
run-modin: install-deps tables ## Run Modin benchmarks
$(VENV_BIN)/python -m queries.modin
## Run-all Targets
run-all: run-all-polars run-cudf run-duckdb run-pandas run-pyspark run-dask #run-modin ## Run all benchmarks
run-performant: run-all-polars run-cudf run-duckdb ## Run all benchmarks for high scale datasets
run-all-polars: run-polars run-polars-eager run-polars-gpu run-polars-streaming ## Run all Polars benchmarks
run-all-gpu: run-polars run-polars-gpu run-pandas run-cudf ## Run all GPU-accelerated library benchmarks
## Plotting
plot: install-deps ## Plot results
$(VENV_BIN)/python -m scripts.plot_bars
## Cleaning
clean: clean-tpch-dbgen clean-tables ## Clean up everything
@rm -rf .mypy_cache/
@rm -rf $(VENV)/
@rm -rf output/
@rm -rf spark-warehouse/
clean-tpch-dbgen: ## Clean up TPC-H folder
@$(MAKE) -C tpch-dbgen clean
@rm -rf tpch-dbgen/*.tbl
clean-tables: ## Clean up data tables
@rm -rf data/tables/
## Help
help: ## Display this help screen
@echo -e "\033[1mAvailable commands:\033[0m"
@grep -E '^[a-zA-Z0-9_\.-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-22s\033[0m %s\n", $$1, $$2}' | sort
## Other
run-10-times-light: ## Run benchmarks 10 times over multiple SCALE_FACTOR values
for i in {1..5}; do \
for scale in 0.1 1.0 5.0 10.0; do \
echo "Running benchmarks for SCALE_FACTOR=$$scale (iteration $$i)"; \
SCALE_FACTOR=$$scale $(MAKE) run-all; \
mv output/run/timings.csv output/run/timings-$(HARDWARE)-scale-$$scale-iteration-$$i.csv; \
done; \
done;
run-10-times-heavy:
@if [ -z "$(HARDWARE)" ]; then \
echo "Error: HARDWARE environment variable is not set."; \
exit 1; \
fi; \
for i in {1..5}; do \
for scale in 20.0 35.0 50.0; do \
echo "Running benchmarks for SCALE_FACTOR=$$scale (iteration $$i)"; \
SCALE_FACTOR=$$scale $(MAKE) run-performant; \
mv output/run/timings.csv output/run/timings-$(HARDWARE)-scale-$$scale-iteration-$$i.csv; \
done; \
done; \
benchmark:
@if [ -z "$(HARDWARE)" ]; then \
echo "Error: HARDWARE environment variable is not set."; \
exit 1; \
fi; \
$(MAKE) run-10-times-light
$(MAKE) run-10-times-heavy
unset HARDWARE