-
-
Notifications
You must be signed in to change notification settings - Fork 2k
176 lines (149 loc) · 5.98 KB
/
benchmark.yml
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
name: Benchmark
on:
pull_request:
paths:
- crates/**
- Cargo.toml
- py-polars/tests/benchmark/**
- .github/workflows/benchmark.yml
push:
branches:
- main
paths:
- crates/**
- Cargo.toml
- py-polars/tests/benchmark/**
- .github/workflows/benchmark.yml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
SCCACHE_GHA_ENABLED: 'true'
RUSTC_WRAPPER: sccache
RUST_BACKTRACE: 1
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Set up Graphviz
uses: ts-graphviz/setup-graphviz@v2
- name: Create virtual environment
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
echo "VIRTUAL_ENV=$GITHUB_WORKSPACE/.venv" >> $GITHUB_ENV
- name: Install Python dependencies
working-directory: py-polars
run: |
# Install typing-extensions separately whilst the `--extra-index-url` in `requirements-ci.txt`
# doesn't have an up-to-date typing-extensions, see
# https://github.com/astral-sh/uv/issues/6028#issuecomment-2287232150
uv pip install -U typing-extensions
uv pip install --compile-bytecode -r requirements-dev.txt -r requirements-ci.txt --verbose
- name: Set up Rust
run: rustup show
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: py-polars
save-if: ${{ github.ref_name == 'main' }}
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
- name: Install Polars release build
env:
RUSTFLAGS: -C embed-bitcode -D warnings
working-directory: py-polars
run: maturin develop --release -- -C codegen-units=8 -C lto=thin -C target-cpu=native
- name: Set wheel size
run: |
WHEEL_SIZE=$(ls -l py-polars/polars/polars*.so | awk '{ print $5 }')
echo "WHEEL_SIZE=$WHEEL_SIZE" >> $GITHUB_ENV
- name: Wheel size txt
if: github.ref_name == 'main'
run: |
echo "$GITHUB_RUN_ID $WHEEL_SIZE" > wheel_sizes.txt
- name: Upload wheel sizes artifact (main only)
if: github.ref_name == 'main'
uses: actions/upload-artifact@v4
with:
name: wheel-size
path: wheel_sizes.txt
- name: Download main wheel size
uses: actions/download-artifact@v4
with:
name: wheel-size
continue-on-error: true
- name: Extract previous wheel size
if: github.ref_name != 'main'
id: load_previous_size
run: |
ls -la
if [[ -f wheel_sizes.txt ]]; then
PREVIOUS_WHEEL_SIZE=$(tail -n 1 wheel_sizes.txt | awk '{ print $2 }')
echo "PREVIOUS_WHEEL_SIZE=$PREVIOUS_WHEEL_SIZE" >> $GITHUB_ENV
else
echo "PREVIOUS_WHEEL_SIZE=Unknown" >> $GITHUB_ENV
fi
continue-on-error: true
- name: Comment wheel size
uses: actions/github-script@v7
if: github.ref_name != 'main'
with:
script: |
const previousSize = process.env.PREVIOUS_WHEEL_SIZE || 'Unknown';
const currentSize = process.env.WHEEL_SIZE || 'Unknown';
// Convert to MB
const previousSizeMB = previousSize !== 'Unknown' ? (previousSize / 1024 / 1024).toFixed(4) : 'Unknown';
const currentSizeMB = currentSize !== 'Unknown' ? (currentSize / 1024 / 1024).toFixed(4) : 'Unknown';
let commentBody = `The previous uncompressed lib size was **${previousSizeMB} MB**.\nThe current uncompressed lib size after this PR is **${currentSizeMB} MB**.`;
// Calculate percentage increase if both sizes are available
if (previousSize !== 'Unknown' && currentSize !== '') {
const increase = ((currentSize - previousSize) / previousSize) * 100;
commentBody += `\nThis represents a **${increase.toFixed(2)}% increase** in size.`;
}
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
// Look for an existing comment
const existingComment = comments.find(comment =>
comment.body.includes('The previous uncompressed lib size was')
);
if (existingComment) {
// Update the existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody,
});
} else {
// Create a new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody,
});
}
continue-on-error: true
- name: Run benchmark tests
uses: CodSpeedHQ/action@v3
with:
working-directory: py-polars
run: pytest -m benchmark --codspeed -v
- name: Run non-benchmark tests
working-directory: py-polars
run: pytest -m 'not benchmark and not debug' -n auto --dist loadgroup
- name: Run non-benchmark tests on new streaming engine
working-directory: py-polars
env:
POLARS_AUTO_NEW_STREAMING: 1
run: pytest -n auto --dist loadgroup -m "not may_fail_auto_streaming and not slow and not write_disk and not release and not docs and not hypothesis and not benchmark and not ci_only"