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 benchmarks for json string serialize/deserialize #12258

Merged
merged 13 commits into from
May 6, 2022

Conversation

paradust7
Copy link
Contributor

@paradust7 paradust7 commented May 2, 2022

  • Pulls the Catch2 testing and benchmarking library into lib/catch2 (a single header file)
  • Adds --run-benchmarks command-line flag
  • Adds BUILD_BENCHMARKS flag which is FALSE by default.
  • Adds src/benchmark directory
  • Adds benchmark_serialize.cpp which contains benchmarks of serializeJsonStringIfNeeded and deSerializeJsonStringIfNeeded
  • Adds .github/workflows/perf.yml which runs the benchmarks and stores them to the github pages branch. (*)

(*) I have no way of testing this, so it may be better to use the web interface to create it. It assumes the existence of a gh-pages branch specially created as described here: https://github.com/benchmark-action/github-action-benchmark

@paradust7 paradust7 changed the title Add benchmarks for json string serialize/deserialize (#12250) Add benchmarks for json string serialize/deserialize May 2, 2022
@sfan5 sfan5 added the Feature ✨ PRs that add or enhance a feature label May 2, 2022
.github/workflows/perf.yml Outdated Show resolved Hide resolved
src/benchmark/benchmark.cpp Outdated Show resolved Hide resolved
src/benchmark/benchmark_serialize.cpp Outdated Show resolved Hide resolved
lib/catch2/CMakeLists.txt Outdated Show resolved Hide resolved
.github/workflows/perf.yml Outdated Show resolved Hide resolved
.github/workflows/perf.yml Outdated Show resolved Hide resolved
@paradust7
Copy link
Contributor Author

There's an embarassing bug in the workflow alerter. It ignores time units. So "1 ms" compared to "900 us" looks like a performance regression of 900x:

paradust7@28ed9bf#commitcomment-72699948

I'm going to disable alerts for now, and hope this is the only bug.

@sfan5
Copy link
Member

sfan5 commented May 4, 2022

Example page with results: https://sfan5.github.io/minetest/dev/bench/

CMakeLists.txt Outdated Show resolved Hide resolved
@rubenwardy
Copy link
Member

Example page with results: sfan5.github.io/minetest/dev/bench

That's pretty cool

@sfan5
Copy link
Member

sfan5 commented May 4, 2022

grafik

The graphs are junk though, this is not usable.

@sfan5 sfan5 added the Action / change needed Code still needs changes (PR) / more information requested (Issues) label May 4, 2022
@paradust7
Copy link
Contributor Author

paradust7 commented May 4, 2022

Sad. It's strange that it has no problem parsing the time units, but does nothing with them.

We could fork github-action-benchmark to fix this, but it would be probably be easier to just have catch2 always emit the same unit for now.

EDIT: I filed an issue for them: benchmark-action/github-action-benchmark#122

@paradust7
Copy link
Contributor Author

Can you give this action write permissions only on gh-pages? I didn't realize it was a third-party action. Maybe forking it is a good idea, or revision pinning.

@sfan5 sfan5 removed the Action / change needed Code still needs changes (PR) / more information requested (Issues) label May 5, 2022
@sfan5
Copy link
Member

sfan5 commented May 5, 2022

How would I do that? It worked out of the box on my personal repo (after creating the branch).

@paradust7
Copy link
Contributor Author

Unfortunately, I don't see any way to limit it. The workflow gives it write permission for "deployments" and "contents" access groups. These are documented in terms of API access. "Contents" allows it to generate a pull request and merge it. But I don't see any way to limit it to a specific branch. There's a "pages" API group but it seems to be read-only.

https://docs.github.com/en/rest/overview/permissions-required-for-github-apps

If the action is pinned to a specific revision, at least that will guarantee that future changes to upstream will not introduce a sudden surprise. But won't help if there's already a backdoor or exploit in it. (very unlikely, it's only 4529 lines, but still...)

Alternatively, could put the workflow in a completely separate repository, e.g. minetest/benchmarks, which has its own gh-pages, and keeps sync with a cron workflow. I'll try to do this and see if there are any snags.

@paradust7
Copy link
Contributor Author

@sfan5 I got it working successfully from another repo.

Can you create a "benchmarks" repo (or other appropriate name) under the minetest organization, so I can make a PR against it? Thanks.

The "benchmarks" repo will also need a gh-pages branch to work. One will be created automatically if you setup a theme, as per these instructions: https://docs.github.com/en/pages/getting-started-with-github-pages/adding-a-theme-to-your-github-pages-site-with-the-theme-chooser

The graphs will then be available at https://minetest.github.io/benchmarks/dev/bench

@paradust7
Copy link
Contributor Author

I removed the github workflow from this PR. It will instead be in the benchmarks repo.
This PR still needs to go in to add catch2, --run-benchmarks, etc.

@sfan5
Copy link
Member

sfan5 commented May 6, 2022

Sounds good. How will the other workflow track commits in the main repo? Does Github Actions have something for that?
Or will it just run e.g. every 12 hours?

Can you create a "benchmarks" repo (or other appropriate name) under the minetest organization, so I can make a PR against it?

I can't do this myself but I'll get someone who can to do it.

@rubenwardy
Copy link
Member

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

Looks good.

util/ci/common.sh Outdated Show resolved Hide resolved
@rubenwardy
Copy link
Member

Looks good apart from that indentation issue. Haven't tested, will trust sfan5 on that

@paradust7
Copy link
Contributor Author

Thanks! Here's the PR on the benchmarks repo:

minetest/benchmarks#1

@rubenwardy rubenwardy merged commit 8747215 into minetest:master May 6, 2022
@paradust7 paradust7 deleted the add_benchmarks branch May 6, 2022 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature ✨ PRs that add or enhance a feature >= Two approvals ✅ ✅
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants