Skip to content

nyrkio/change-detection

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nyrkio-logo / Change Detection

Action Marketplace Build Status codecov

This repository provides a GitHub Action for integrating Nyrkiö Change Detection with your Continuous Benchmarking Results.

Screenshot of a Nyrkiö GitHub Action that has rendered a green checkmark

How to use

This action takes a file that contains benchmark output. The benchmark results are parsed into a common JSON format, which is then sent to nyrkio.com for analysis. All the main benchmarking frameworks are supported.

Minimal setup

Let's start with a minimal workflow setup. For explanation, here let's say we have a Go project. But basic setup is the same when you use other languages. For language-specific setup, please read the later section.

Note: You need to create an account at nyrkio.com to get the NYRKIO_JWT_TOKEN that is used below. To receive alerts from Nyrkiö as pull request comments or GitHub issues, the recommended way to create your account is to install Nyrkiö as a GitHub app.

name: Minimal setup
on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master

jobs:
  benchmark:
    name: Performance regression check
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
        with:
          go-version: "stable"
      # Run benchmark with `go test -bench` and stores the output to a file
      - name: Run benchmark
        run: go test -bench 'BenchmarkFib' | tee output.txt

      - name: Analyze benchmark results with Nyrkiö
        uses: nyrkio/change-detection@v2
        with:
          tool: 'go'
          output-file-path: output.txt
          # Pick up your token at https://nyrkio.com/docs/getting-started
          nyrkio-token: ${{ secrets.NYRKIO_JWT_TOKEN }}

The step which runs nyrkio/change-detection does followings:

  1. Extract benchmark result from the output in output.txt
  2. Transform the benchmark results into a common JSON format
  3. Send the new result(s) to Nyrkiö API for analysis
  4. If a change is detected, either immediately or after a few days, you can receive alerts by slack, email, and github issues.

Live demo

A live workflow example is here. And the output of the workflow can be seen here and finally the graphs on Nyrkiö here.

nyrkio-footer-graph

About Nyrkiö

If you've managed to automate and run some benchmarks routinely as part of your GitHub Action pipelines, you may have noticed it is not easy to spot performance regressions (nor improvements) in all those benchmark results your GitHub Action workflows now produce! Nyrkiö was developed to help with this last bit. We will analyze your history of benchmark results, and alert you if we find any regressions. (Or improvements, for that matter!)

Automating the analysis of continuous benchmarking results is a surprisingly difficult task. Many benchmarks have a range of variation - random noise - anywhere from 5 % to 20 %. Nyrkiö uses a state of the art change detection algorithm to find statistically significant, persistent changes, in noisy benchmarking results. It adapts automatically to the noise level in your benchmarks, thus avoiding false positive alerts. By analyzing the entire history of results, it can detect even very small regressions, in particular, changes smaller than your range of random noise!

You can read more about how Nyrkiö works here.

nyrkio-footer-graph

Supported Benchmarking Frameworks

This GitHub Action supports the commonly used benchmarking frameworks of all major programming languages. In addition we support some generic options such as the time utility, a custom JSON format, and Nyrkiö's own JSON format in pass-thru mode:

Multiple languages in the same repository are supported for polyglot projects.

We wish to thank the open source community for this incredible feat of integration! Nyrkiö Change Detection GitHub Action is based on 6 years of work over at the "GitHub Action Benchmark". Nyrkiö will be upstreaming patches like a good open source citizen, whenever we add functionality for our own customers. (Starting with the time command support.)

Examples

Example projects for each language are in examples/ directory. Live example workflow definitions are in .github/workflows/ directory. Live workflows are:

Language Workflow Example Project
Rust Rust Example Workflow examples/rust
Go Go Example Workflow examples/go
JavaScript JavaScript Example Workflow examples/benchmarkjs
Python pytest-benchmark Example Workflow examples/pytest
C++ C++ Example Workflow examples/cpp
C++ (Catch2) C++ Catch2 Example Workflow examples/catch2
Julia Julia Example examples/julia
.Net C# Benchmark.Net Example Workflow examples/benchmarkdotnet
Java Java Example Workflow examples/java
Luau Coming soon Coming soon

Nyrkiö JSON format

You can also simply send your benchmark results to Nyrkiö in Nyrkiö's own JSON format. An example is included in the same format as above.

Nyrkiö JSON is documented in the main Nyrkiö documentation.

Generic JSON format

This JSON format created and supported by the github-action-benchmark team.

Additionally, even though there is no explicit example for them, you can use customBiggerIsBetter and customSmallerIsBetter to use this action and create your own graphs from your own benchmark data. The name in these tools define which direction "is better" for your benchmarks.

For more details, please consult the LEGACY_README

Other features

Pull request comment

Nyrkiö can comment on your PR. when benchmark results changed too much compared to the main branch. For this to work you need to install Nyrkiö as a github app into your org. This allows Nyrkiö to send comments on your pull requests and file github issues. Please click on https://github.com/apps/nyrkio/installations/new and proceed to install Nyrkiö if you didn't already.

- name: Analyze benchmark results with Nyrkiö
  uses: nyrkio/change-detection@v2
  with:
    tool: 'go'
    output-file-path: output.txt
    # Comment on the pull request if there were changes in the benchmark results, but do not hard fail
    comment-on-alert: true
    fail-on-alert: false
    nyrkio-token: ${{ secrets.NYRKIO_JWT_TOKEN }}

Now, instead of making workflow fail, the step leaves a comment on the PR when it detects performance regression like this.

Tool specific setup

Please read README.md files at each example directory. Usually, take stdout from a benchmark tool and store it to file. Then specify the file path to output-file-path input.

These examples are run in workflows of this repository as described in the 'Examples' section above.

Action inputs

Input definitions are written in action.yml.

name (Required)

  • Type: String
  • Default: "Benchmark"

Name of the benchmark. This value must be identical across all benchmarks in your repository.

tool (Required)

  • Type: String
  • Default: N/A

Tool for running benchmark. The value must be one of "cargo", "go", "benchmarkjs", "pytest", "googlecpp", "catch2", "julia", "jmh", "benchmarkdotnet","benchmarkluau", "customBiggerIsBetter", "customSmallerIsBetter".

output-file-path (Required)

  • Type: String
  • Default: N/A

Path to a file which contains the output from benchmark tool. The path can be relative to repository root. Note: When using tool: nyrkioJson format, this parameter should instead be a directory with JSON files.

github-token (Optional)

  • Type: String
  • Default: N/A

GitHub API access token. Can be used to get meta-data about your pull request or commit.

comment-always (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, this action will leave a pull request comment both if there was a regression and if there wasn't.

comment-on-alert (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, this action will leave a comment on your pull request when an alert happens like this.

Note: Currently with Nyrkiö this is synonymous with comment-always

fail-on-alert (Optional)

  • Type: Boolean
  • Default: false

If it is set to true, the workflow will fail when an alert happens. Note that because Nyrkiö also alerts on positive changes (such as fixing a regression), then setting this to true together with using strict branch protection in GitHub may not be that practical.

Nyrkiö specific configuration

nyrkio-token (Required when using Nyrkiö)

  • Type: String
  • Default: nullS

A JWT token from your nyrkio.com settings page: https://nyrkio.com/docs/getting-started

nyrkio-public (Recommended)

  • Type: Boolean
  • Default: false

Publish these benchmark results at nyrkio.com/public. (Recommended for open source projects.)

nyrkio-org

  • Type: String
  • Default: ""

The name of a github org where you have installed Nyrkiö. See https://nyrkio.com/user/settings#nyrkio-settings-userinfo

nyrkio-settings-pvalue

  • Type: Number
  • Default: 0.001

The p-value used to determine if a change in benchmark results is statistically significant. Example: 0.01 (If specified, will be applied to all your nyrkio.com test results.)

nyrkio-settings-threshold

  • Type: String (percentage)
  • Default: 5%

Threshold percentage below which changes will be ignored. Example: 2% (If specified, will be applied to all your nyrkio.com test results.)

never-fail:

  • Type: Boolean
  • Default: false

Don't fail the workflow, ever. Not even if the action itself fails due to bugs or network or whatever.

nyrkio-enable

  • Type: Boolean
  • Default: true

Use Nyrkiö (web service) to store your benchmark results and to find statistically significant change points.

nyrkio-api-root

The root URL for a Nyrkiö API

The remaining parameters aren't used by Nyrkiö. We've preserved the functionality of the original threshold based alerting system, but its use is not recommended. The related parameters are documented in LEGACY_README.md.

Action outputs

No action output is set by this action for the parent GitHub workflow.

Versioning

This action conforms semantic versioning 2.0.

For example, nyrkio/change-detection@v2 means the latest version of 2.x.y. And nyrkio/[email protected] always uses v2.0.2 even if a newer version is published.

HEAD would use the most recent commit of the development branch. This is for experimental and development use only!

Track updates of this action

To notice new version releases, please watch 'release only' at this repository. Every release will appear on your GitHub notifications page.

License

the MIT License