-
Notifications
You must be signed in to change notification settings - Fork 69
CI benchmarking suite #533
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
Open
MilesCranmer
wants to merge
13
commits into
JuliaPy:main
Choose a base branch
from
MilesCranmer:benchmarks
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+141
−0
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d0a97df
create simple benchmark suite
MilesCranmer 410e31c
more hierarchy in benchmark
MilesCranmer cd19489
create AirspeedVelocity github action for benchmarks
MilesCranmer 072423d
fix imports in benchmark
MilesCranmer 5f61a9c
fix default branch name in CI
MilesCranmer fcc687a
benchmarks: more hierarchy
MilesCranmer 4f78589
timing + benchmark
ericphanson 397ef3f
benchmarks: include gcbench in runs
MilesCranmer 37c89d7
benchmarks: remove unused code
MilesCranmer 5295cc7
benchmarks: modularize
MilesCranmer 5d4e630
benchmarks: give more time to GC benchmark
MilesCranmer ae73e43
benchmarks: simplify naming scheme
MilesCranmer 83ddd09
benchmarks: avoid issue of `tune`ing away from `evals=1`
MilesCranmer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,64 @@ | ||
name: Benchmark a pull request | ||
|
||
on: | ||
pull_request_target: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
generate_plots: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: julia-actions/setup-julia@v1 | ||
with: | ||
version: "1.9" | ||
- uses: julia-actions/cache@v1 | ||
- name: Extract Package Name from Project.toml | ||
id: extract-package-name | ||
run: | | ||
PACKAGE_NAME=$(grep "^name" Project.toml | sed 's/^name = "\(.*\)"$/\1/') | ||
echo "::set-output name=package_name::$PACKAGE_NAME" | ||
- name: Build AirspeedVelocity | ||
env: | ||
JULIA_NUM_THREADS: 2 | ||
run: | | ||
# Lightweight build step, as sometimes the runner runs out of memory: | ||
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.add(;url="https://github.com/MilesCranmer/AirspeedVelocity.jl.git")' | ||
julia -e 'ENV["JULIA_PKG_PRECOMPILE_AUTO"]=0; import Pkg; Pkg.build("AirspeedVelocity")' | ||
- name: Add ~/.julia/bin to PATH | ||
run: | | ||
echo "$HOME/.julia/bin" >> $GITHUB_PATH | ||
- name: Run benchmarks | ||
run: | | ||
echo $PATH | ||
ls -l ~/.julia/bin | ||
mkdir results | ||
benchpkg ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --url=${{ github.event.repository.clone_url }} --bench-on="${{github.event.pull_request.head.sha}}" --output-dir=results/ --tune --exeflags="-O3 --threads=auto" | ||
- name: Create markdown table from benchmarks | ||
run: | | ||
benchpkgtable ${{ steps.extract-package-name.outputs.package_name }} --rev="${{github.event.repository.default_branch}},${{github.event.pull_request.head.sha}}" --input-dir=results/ --ratio > table.md | ||
echo '### Benchmark Results' > body.md | ||
echo '' >> body.md | ||
echo '' >> body.md | ||
cat table.md >> body.md | ||
echo '' >> body.md | ||
- name: Find Comment | ||
uses: peter-evans/find-comment@v2 | ||
id: fcbenchmark | ||
with: | ||
issue-number: ${{ github.event.pull_request.number }} | ||
comment-author: 'github-actions[bot]' | ||
body-includes: Benchmark Results | ||
|
||
- name: Comment on PR | ||
uses: peter-evans/create-or-update-comment@v3 | ||
with: | ||
comment-id: ${{ steps.fcbenchmark.outputs.comment-id }} | ||
issue-number: ${{ github.event.pull_request.number }} | ||
body-path: body.md | ||
edit-mode: replace |
This file contains hidden or 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,2 @@ | ||
[deps] | ||
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" |
This file contains hidden or 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,62 @@ | ||
using BenchmarkTools | ||
using PythonCall | ||
using PythonCall: pydel!, pyimport, pydict, pystr, pyrange | ||
|
||
const SUITE = BenchmarkGroup() | ||
|
||
function test_pydict_init() | ||
random = pyimport("random").random | ||
x = pydict() | ||
for i in pyrange(1000) | ||
x[pystr(i)] = i + random() | ||
end | ||
return x | ||
end | ||
|
||
SUITE["basic"]["julia"]["pydict"]["init"] = @benchmarkable test_pydict_init() | ||
|
||
function test_pydict_pydel() | ||
random = pyimport("random").random | ||
x = pydict() | ||
for i in pyrange(1000) | ||
k = pystr(i) | ||
r = random() | ||
v = i + r | ||
x[k] = v | ||
pydel!(k) | ||
pydel!(r) | ||
pydel!(v) | ||
pydel!(i) | ||
end | ||
return x | ||
end | ||
|
||
SUITE["basic"]["julia"]["pydict"]["pydel"] = @benchmarkable test_pydict_pydel() | ||
|
||
@generated function test_atpy(::Val{use_pydel}) where {use_pydel} | ||
quote | ||
@py begin | ||
import random: random | ||
x = {} | ||
for i in range(1000) | ||
x[str(i)] = i + random() | ||
$(use_pydel ? :(@jl PythonCall.pydel!(i)) : :(nothing)) | ||
end | ||
x | ||
end | ||
end | ||
end | ||
|
||
SUITE["basic"]["@py"]["pydict"]["init"] = @benchmarkable test_atpy(Val(false)) | ||
SUITE["basic"]["@py"]["pydict"]["pydel"] = @benchmarkable test_atpy(Val(true)) | ||
|
||
|
||
include("gcbench.jl") | ||
using .GCBench: append_lots | ||
|
||
SUITE["gc"]["full"] = @benchmarkable( | ||
GC.gc(true), | ||
setup=(GC.gc(true); append_lots(size=159)), | ||
seconds=30, | ||
evals=1, | ||
) |
This file contains hidden or 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,13 @@ | ||
module GCBench | ||
|
||
using PythonCall | ||
|
||
function append_lots(; iters=100 * 1024, size=1596) | ||
v = pylist() | ||
for i = 1:iters | ||
v.append(pylist(rand(size))) | ||
end | ||
return v | ||
end | ||
|
||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.