Skip to content
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

add benchmark script and testing #158

Merged
merged 21 commits into from
Oct 29, 2024
Merged

add benchmark script and testing #158

merged 21 commits into from
Oct 29, 2024

Conversation

JoshuaLampert
Copy link
Owner

I recently came across AirspeedVelocity.jl and think it is a nice tool to run benchmarks for changes in a PR. The GitHub Action file is (almost) a copy of https://github.com/SymbolicML/DynamicQuantities.jl/blob/21b7468801c773c5072c6db358f2fddcb8529ff9/.github/workflows/benchmark_pr.yml.
For the benchmark test I included some elixirs, which should cover most of the features.

Copy link

codecov bot commented Oct 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.97%. Comparing base (2061e53) to head (820f2b2).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #158   +/-   ##
=======================================
  Coverage   97.97%   97.97%           
=======================================
  Files          19       19           
  Lines        1776     1776           
=======================================
  Hits         1740     1740           
  Misses         36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JoshuaLampert
Copy link
Owner Author

Looks like some test values need to be adjusted. Tests were also failing locally. I used the values I now got locally.

@JoshuaLampert
Copy link
Owner Author

I'm not sure why there is the UndefVarError: sol not defined error in the new benchmark Action. Looks like some namespace issue. I guess that's related to the fact that AirspeedVelocity.jl creates a module internally, but I don't know how to fix that. Locally, it runs fine.

Copy link
Collaborator

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a nice idea to try out - if it does not cause too much work/trouble to set it up

@JoshuaLampert
Copy link
Owner Author

I have set it up in another repo, which worked easily and nicely. But I'm not sure what to do with the error here.

@JoshuaLampert JoshuaLampert marked this pull request as draft October 29, 2024 09:08
benchmark/benchmarks.jl Outdated Show resolved Hide resolved
Copy link
Contributor

github-actions bot commented Oct 29, 2024

Benchmark Results

main 820f2b2... main/820f2b2d99ae92...
bbm_1d/bbm_1d_basic.jl 13.9 ± 0.29 μs 13.8 ± 0.29 μs 1.01
bbm_1d/bbm_1d_fourier.jl 0.528 ± 0.0039 ms 0.216 ± 0.015 ms 2.45
bbm_bbm_1d/bbm_bbm_1d_basic_reflecting.jl 0.114 ± 0.0034 ms 0.121 ± 0.0034 ms 0.944
bbm_bbm_1d/bbm_bbm_1d_dg.jl 0.0344 ± 0.00048 ms 0.0341 ± 0.00047 ms 1.01
bbm_bbm_1d/bbm_bbm_1d_relaxation.jl 27.6 ± 0.46 μs 27.4 ± 0.41 μs 1.01
bbm_bbm_1d/bbm_bbm_1d_upwind_relaxation.jl 0.0485 ± 0.00054 ms 0.0485 ± 0.00091 ms 1
hyperbolic_serre_green_naghdi_1d/hyperbolic_serre_green_naghdi_dingemans.jl 4.1 ± 0.012 μs 4.1 ± 0.013 μs 1
serre_green_naghdi_1d/serre_green_naghdi_well_balanced.jl 0.198 ± 0.0074 ms 0.201 ± 0.0062 ms 0.985
svaerd_kalisch_1d/svaerd_kalisch_1d_dingemans_relaxation.jl 0.145 ± 0.0029 ms 0.151 ± 0.0037 ms 0.958
time_to_load 1.98 ± 0.017 s 1.99 ± 0.024 s 0.996

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR.
Benchmark Plot

@JoshuaLampert
Copy link
Owner Author

Seems like trixi_include is the problem. With include instead it works. But then we cannot set a smaller time span for the ODE.

@JoshuaLampert JoshuaLampert marked this pull request as ready for review October 29, 2024 10:08
@JoshuaLampert
Copy link
Owner Author

This seems fine now. The plots can be found here.
It's not optimal that all elixirs are run for the whole time span (because trixi_include creates namespace issues in combination with AirspeedVelocity.jl), but with a total runtime of less than 10 minutes I think it's still reasonable.

@ranocha
Copy link
Collaborator

ranocha commented Oct 29, 2024

Seems like trixi_include is the problem. With include instead it works. But then we cannot set a smaller time span for the ODE.

trixi_include([mod::Module=Main,] elixir::AbstractString; kwargs...) uses Main as module whereas include uses the current module. Can you use @__MODULE__ as first argument to trixi_include?

@JoshuaLampert
Copy link
Owner Author

Seems like trixi_include is the problem. With include instead it works. But then we cannot set a smaller time span for the ODE.

trixi_include([mod::Module=Main,] elixir::AbstractString; kwargs...) uses Main as module whereas include uses the current module. Can you use @MODULE as first argument to trixi_include?

Ah, I see. Thanks! Let' see.

ranocha
ranocha previously approved these changes Oct 29, 2024
Copy link
Collaborator

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me. Benchmarks on GitHub runners can be quite noisy but let's see 👍

.github/workflows/benchmark.yml Outdated Show resolved Hide resolved
test/test_serre_green_naghdi_1d.jl Outdated Show resolved Hide resolved
@ranocha
Copy link
Collaborator

ranocha commented Oct 29, 2024

This seems fine now. The plots can be found here. It's not optimal that all elixirs are run for the whole time span (because trixi_include creates namespace issues in combination with AirspeedVelocity.jl), but with a total runtime of less than 10 minutes I think it's still reasonable.

Is there some way to display the plots in a PR comment like the table above?

@JoshuaLampert
Copy link
Owner Author

This seems fine now. The plots can be found here. It's not optimal that all elixirs are run for the whole time span (because trixi_include creates namespace issues in combination with AirspeedVelocity.jl), but with a total runtime of less than 10 minutes I think it's still reasonable.

Is there some way to display the plots in a PR comment like the table above?

Good question. I agree that this would be nice. Let me see if I can wangle that.

@JoshuaLampert
Copy link
Owner Author

JoshuaLampert commented Oct 29, 2024

This seems fine now. The plots can be found here. It's not optimal that all elixirs are run for the whole time span (because trixi_include creates namespace issues in combination with AirspeedVelocity.jl), but with a total runtime of less than 10 minutes I think it's still reasonable.

Is there some way to display the plots in a PR comment like the table above?

Good question. I agree that this would be nice. Let me see if I can wangle that.

I think it's not so easy. We would need to upload it somewhere else and then put the link into the comment, cf. peter-evans/create-or-update-comment#68. IMHO, that's a bit too sophisticated. The numbers in the table also show most relevant information. EDIT: We can at least link to the artifact, which saves some clicks, but having the plot inside the comment is not so easy, I think. Artifacts are always uploaded as zip, see https://github.com/actions/upload-artifact?tab=readme-ov-file#zip-archives.
What makes this even harder in the general case is the fact that multiple plots are generated by AirspeedVelocity.jl if there are a lot of benchmarks tests (the default is 10 benchmark tests per image, i.e. we have only one image because we currently have 10 benchmark tests).

Copy link
Collaborator

@ranocha ranocha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Thanks!

@JoshuaLampert JoshuaLampert merged commit 17a3d77 into main Oct 29, 2024
18 checks passed
@JoshuaLampert JoshuaLampert deleted the benchmark branch October 29, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants