• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..05-Nov-2021-

README_CI.mdH A D05-Nov-20217.8 KiB12387

__init__.pyH A D05-Nov-20211.5 KiB6848

combine.pyH A D05-Nov-20211.2 KiB3928

dataarray_missing.pyH A D05-Nov-20212 KiB8162

dataset_io.pyH A D05-Nov-202114.8 KiB479353

groupby.pyH A D05-Nov-2021989 4028

import_xarray.pyH A D05-Nov-2021221 107

indexing.pyH A D05-Nov-20214.8 KiB150117

interp.pyH A D05-Nov-20211.5 KiB5240

pandas.pyH A D05-Nov-2021718 2721

reindexing.pyH A D05-Nov-20211.3 KiB5339

repr.pyH A D05-Nov-20211 KiB4131

rolling.pyH A D05-Nov-20213.5 KiB11190

unstacking.pyH A D05-Nov-2021763 3020

README_CI.md

1# Benchmark CI
2
3<!-- Author: @jaimergp -->
4<!-- Last updated: 2021.07.06 -->
5<!-- Describes the work done as part of https://github.com/scikit-image/scikit-image/pull/5424 -->
6
7## How it works
8
9The `asv` suite can be run for any PR on GitHub Actions (check workflow `.github/workflows/benchmarks.yml`) by adding a `run-benchmark` label to said PR. This will trigger a job that will run the benchmarking suite for the current PR head (merged commit) against the PR base (usually `main`).
10
11We use `asv continuous` to run the job, which runs a relative performance measurement. This means that there's no state to be saved and that regressions are only caught in terms of performance ratio (absolute numbers are available but they are not useful since we do not use stable hardware over time). `asv continuous` will:
12
13* Compile `scikit-image` for _both_ commits. We use `ccache` to speed up the process, and `mamba` is used to create the build environments.
14* Run the benchmark suite for both commits, _twice_  (since `processes=2` by default).
15* Generate a report table with performance ratios:
16    * `ratio=1.0` -> performance didn't change.
17    * `ratio<1.0` -> PR made it slower.
18    * `ratio>1.0` -> PR made it faster.
19
20Due to the sensitivity of the test, we cannot guarantee that false positives are not produced. In practice, values between `(0.7, 1.5)` are to be considered part of the measurement noise. When in doubt, running the benchmark suite one more time will provide more information about the test being a false positive or not.
21
22## Running the benchmarks on GitHub Actions
23
241. On a PR, add the label `run-benchmark`.
252. The CI job will be started. Checks will appear in the usual dashboard panel above the comment box.
263. If more commits are added, the label checks will be grouped with the last commit checks _before_ you added the label.
274. Alternatively, you can always go to the `Actions` tab in the repo and [filter for `workflow:Benchmark`](https://github.com/scikit-image/scikit-image/actions?query=workflow%3ABenchmark). Your username will be assigned to the `actor` field, so you can also filter the results with that if you need it.
28
29## The artifacts
30
31The CI job will also generate an artifact. This is the `.asv/results` directory compressed in a zip file. Its contents include:
32
33* `fv-xxxxx-xx/`. A directory for the machine that ran the suite. It contains three files:
34    * `<baseline>.json`, `<contender>.json`: the benchmark results for each commit, with stats.
35    * `machine.json`: details about the hardware.
36* `benchmarks.json`: metadata about the current benchmark suite.
37* `benchmarks.log`: the CI logs for this run.
38* This README.
39
40## Re-running the analysis
41
42Although the CI logs should be enough to get an idea of what happened (check the table at the end), one can use `asv` to run the analysis routines again.
43
441. Uncompress the artifact contents in the repo, under `.asv/results`. This is, you should see `.asv/results/benchmarks.log`, not `.asv/results/something_else/benchmarks.log`. Write down the machine directory name for later.
452. Run `asv show` to see your available results. You will see something like this:
46
47```
48$> asv show
49
50Commits with results:
51
52Machine    : Jaimes-MBP
53Environment: conda-py3.9-cython-numpy1.20-scipy
54
55    00875e67
56
57Machine    : fv-az95-499
58Environment: conda-py3.7-cython-numpy1.17-pooch-scipy
59
60    8db28f02
61    3a305096
62```
63
643. We are interested in the commits for `fv-az95-499` (the CI machine for this run). We can compare them with `asv compare` and some extra options. `--sort ratio` will show largest ratios first, instead of alphabetical order. `--split` will produce three tables: improved, worsened, no changes. `--factor 1.5` tells `asv` to only complain if deviations are above a 1.5 ratio. `-m` is used to indicate the machine ID (use the one you wrote down in step 1). Finally, specify your commit hashes: baseline first, then contender!
65
66```
67$> asv compare --sort ratio --split --factor 1.5 -m fv-az95-499 8db28f02 3a305096
68
69Benchmarks that have stayed the same:
70
71       before           after         ratio
72     [8db28f02]       [3a305096]
73     <ci-benchmark-check~9^2>
74              n/a              n/a      n/a  benchmark_restoration.RollingBall.time_rollingball_ndim
75      1.23±0.04ms       1.37±0.1ms     1.12  benchmark_transform_warp.WarpSuite.time_to_float64(<class 'numpy.float64'>, 128, 3)
76       5.07±0.1μs       5.59±0.4μs     1.10  benchmark_transform_warp.ResizeLocalMeanSuite.time_resize_local_mean(<class 'numpy.float32'>, (192, 192, 192), (192, 192, 192))
77      1.23±0.02ms       1.33±0.1ms     1.08  benchmark_transform_warp.WarpSuite.time_same_type(<class 'numpy.float32'>, 128, 3)
78       9.45±0.2ms       10.1±0.5ms     1.07  benchmark_rank.Rank3DSuite.time_3d_filters('majority', (32, 32, 32))
79       23.0±0.9ms         24.6±1ms     1.07  benchmark_interpolation.InterpolationResize.time_resize((80, 80, 80), 0, 'symmetric', <class 'numpy.float64'>, True)
80         38.7±1ms         41.1±1ms     1.06  benchmark_transform_warp.ResizeLocalMeanSuite.time_resize_local_mean(<class 'numpy.float32'>, (2048, 2048), (192, 192, 192))
81       4.97±0.2μs       5.24±0.2μs     1.05  benchmark_transform_warp.ResizeLocalMeanSuite.time_resize_local_mean(<class 'numpy.float32'>, (2048, 2048), (2048, 2048))
82       4.21±0.2ms       4.42±0.3ms     1.05  benchmark_rank.Rank3DSuite.time_3d_filters('gradient', (32, 32, 32))
83
84...
85```
86
87If you want more details on a specific test, you can use `asv show`. Use `-b pattern` to filter which tests to show, and then specify a commit hash to inspect:
88
89```
90$> asv show -b time_to_float64 8db28f02
91
92Commit: 8db28f02 <ci-benchmark-check~9^2>
93
94benchmark_transform_warp.WarpSuite.time_to_float64 [fv-az95-499/conda-py3.7-cython-numpy1.17-pooch-scipy]
95  ok
96  =============== ============= ========== ============= ========== ============ ========== ============ ========== ============
97  --                                                                N / order
98  --------------- --------------------------------------------------------------------------------------------------------------
99      dtype_in       128 / 0     128 / 1      128 / 3     1024 / 0    1024 / 1    1024 / 3    4096 / 0    4096 / 1    4096 / 3
100  =============== ============= ========== ============= ========== ============ ========== ============ ========== ============
101    numpy.uint8    2.56±0.09ms   523±30μs   1.28±0.05ms   130±3ms     28.7±2ms    81.9±3ms   2.42±0.01s   659±5ms    1.48±0.01s
102    numpy.uint16   2.48±0.03ms   530±10μs   1.28±0.02ms   130±1ms    30.4±0.7ms   81.1±2ms    2.44±0s     653±3ms    1.47±0.02s
103   numpy.float32    2.59±0.1ms   518±20μs   1.27±0.01ms   127±3ms     26.6±1ms    74.8±2ms   2.50±0.01s   546±10ms   1.33±0.02s
104   numpy.float64   2.48±0.04ms   513±50μs   1.23±0.04ms   134±3ms     30.7±2ms    85.4±2ms   2.55±0.01s   632±4ms    1.45±0.01s
105  =============== ============= ========== ============= ========== ============ ========== ============ ========== ============
106  started: 2021-07-06 06:14:36, duration: 1.99m
107```
108
109## Other details
110
111### Skipping slow or demanding tests
112
113To minimize the time required to run the full suite, we trimmed the parameter matrix in some cases and, in others, directly skipped tests that ran for too long or require too much memory. Unlike `pytest`, `asv` does not have a notion of marks. However, you can `raise NotImplementedError` in the setup step to skip a test. In that vein, a new private function is defined at `benchmarks.__init__`: `_skip_slow`. This will check if the `ASV_SKIP_SLOW` environment variable has been defined. If set to `1`, it will raise `NotImplementedError` and skip the test. To implement this behavior in other tests, you can add the following attribute:
114
115```python
116from . import _skip_slow  # this function is defined in benchmarks.__init__
117
118def time_something_slow():
119    pass
120
121time_something.setup = _skip_slow
122```
123