-
Notifications
You must be signed in to change notification settings - Fork 149
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
Port perf/benchmark_matrix_ops.jl to benchmark/*.jl #742
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5ead6c8
[ci skip] Port perf/benchmark_matrix_ops.jl to benchmark/*.jl
tkf d9ca659
[ci skip] Add Random to benchmark/Project.toml
tkf 2f69235
[ci skip] Fix `rand` usage
tkf 298f375
[ci skip] Reduce number of benchmarks to run in CI
tkf 479b0ca
Pad benchmark names
tkf 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 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,45 @@ | ||
module BenchMatrixOps | ||
|
||
import Random | ||
using BenchmarkTools | ||
using LinearAlgebra | ||
using StaticArrays | ||
|
||
const suite = BenchmarkGroup() | ||
const matrix_sizes = if haskey(ENV, "GITHUB_EVENT_PATH") | ||
(1, 2, 3, 4, 10, 20) | ||
else | ||
1:20 | ||
end | ||
|
||
# Use same arrays across processes (at least with the same Julia version): | ||
Random.seed!(1234) | ||
|
||
# Unary operators | ||
for f in [det, inv, exp] | ||
s1 = suite["$f"] = BenchmarkGroup() | ||
for N in matrix_sizes | ||
SA = @SMatrix rand(N, N) | ||
A = Array(SA) | ||
s2 = s1[string(N, pad=2)] = BenchmarkGroup() | ||
s2["SMatrix"] = @benchmarkable $f($SA) | ||
s2["Matrix"] = @benchmarkable $f($A) | ||
end | ||
end | ||
|
||
# Binary operators | ||
for f in [*, \] | ||
tkf marked this conversation as resolved.
Show resolved
Hide resolved
|
||
s1 = suite["$f"] = BenchmarkGroup() | ||
for N in matrix_sizes | ||
SA = @SMatrix rand(N, N) | ||
SB = @SMatrix rand(N, N) | ||
A = Array(SA) | ||
B = Array(SB) | ||
s2 = s1[string(N, pad=2)] = BenchmarkGroup() | ||
s2["SMatrix"] = @benchmarkable $f($SA, $SB) | ||
s2["Matrix"] = @benchmarkable $f($A, $B) | ||
end | ||
end | ||
|
||
end # module | ||
BenchMatrixOps.suite |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
matrix_sizes = 1:20
=> total CI time = 37 min https://github.com/JuliaArrays/StaticArrays.jl/runs/456805444matrix_sizes = (1, 2, 3, 4, 10, 20)
=> total CI time = 15 min https://github.com/JuliaArrays/StaticArrays.jl/runs/456815324There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍
If we're already at 15 min, I worry a bit about will happen for a comprehensive benchmark suite 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I guess using the same treatment for QR would probably help with that 15 mins though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I have the same worry. I guess we can't do the "full sweep" in CI and be a bit less greedy about the parameters we try.
An option to reduce CI time is to tune benchmarks separately and store the JSON file somewhere. But I think it's easy to get it stale and it's cumbersome to add benchmarks...
BTW, a less ad-hoc way to do this kind of filtering is to use
@tagged
from BenchmarkToos.jl: https://github.com/JuliaCI/BenchmarkTools.jl/blob/master/doc/manual.md#indexing-into-a-benchmarkgroup-using-tagged I don't think PkgBenchmark.jl support this though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also wonder how much of this is compile time; some of the algorithms are probably quite terrible for N=20.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, one thing I can't copy easily from
perf/*.jl
is the compile-time benchmarks. It'd be great if BenchmarkTools reports compile-time while doing the tuning. I don't think it is difficult but just tedious...