Skip to content

Commit 7975eac

Browse files
committed
documented benchmarking suite
1 parent 9248475 commit 7975eac

File tree

10 files changed

+157
-15
lines changed

10 files changed

+157
-15
lines changed

asv_bench/README.rst

Lines changed: 135 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,142 @@
11
Hangar Performance Benchmarking Suite
22
=====================================
33

4-
This directory contains the hangar performance benchmarking suite. Benchmarks
5-
are run via the `Airspeed Velocity (ASV)
6-
<https://https://asv.readthedocs.io/>`_ project tooling.
4+
A set of benchmarking tools are included in order to track the performance of
5+
common hangar operations over the course of time. The benchmark suite is run
6+
via the phenomenal `Airspeed Velocity (ASV) <https://asv.readthedocs.io/>`_
7+
project.
8+
9+
Benchmarks can be viewed at the following web link, or by examining the raw
10+
data files in the separate benchmark results repo.
11+
12+
- `Benchmark Web View <https://tensorwerk.com/hangar-benchmarks>`_
13+
- `Benchmark Results Repo <https://github.com/tensorwerk/hangar-benchmarks>`_
14+
15+
.. figure:: ../docs/img/asv-detailed.png
16+
:align: center
17+
18+
Purpose
19+
*******
20+
21+
In addition to providing historical metrics and insight into application
22+
performance over many releases of Hangar, *the benchmark suite is used as a
23+
canary to identify potentially problematic pull requests.* All PRs to the
24+
Hangar repository are automatically benchmarked by our CI system to compare the
25+
performance of proposed changes to that of the current ``master`` branch.
26+
27+
*The results of this canary are explicitly NOT to be used as the
28+
"be-all-end-all" decider of whether a PR is suitable to be merged or not.*
29+
30+
Instead, it is meant to serve the following purposes:
31+
32+
1. **Help contributors understand the consequences of some set of changes on the
33+
greater system early in the PR process.** Simple code is best; if there's no
34+
obvious performance degradation or significant improvement to be had, then
35+
there's no need (or really rationale) for using more complex algorithms or
36+
data structures. It's more work for the author, project maintainers, and
37+
long term health of the codebase.
38+
39+
2. **Not everything can be caught by the capabilities of a traditional test
40+
suite.** Hangar is fairly flat/modular in structure, but there are certain
41+
hotspots in the codebase where a simple change could drastically degrade
42+
performance. It's not always obvious where these hotspots are, and even a
43+
change which is functionally identical (introducing no issues/bugs to the
44+
end user) can unknowingly cross a line and introduce some large regression
45+
completely unnoticed to the authors/reviewers.
46+
47+
3. Sometimes tradeoffs need to be made when introducing something new to a
48+
system. Whether this be due to fundamental CS problems (space vs. time) or
49+
simple matters of practicality vs. purity, it's always easier to act in
50+
environments where relevant information is available before a decision is
51+
made. **Identifying and quantifying tradeoffs/regressions/benefits during
52+
development is the only way we can make informed decisions.** The only times
53+
to be OK with some regression is when knowing about it in advance, it might
54+
be the right choice at the time, but if we don't measure we will never know.
55+
56+
57+
Important Notes on Using/Modifying the Benchmark Suite
58+
******************************************************
59+
60+
1. **Do not commit any of the benchmark results, environment files, or generated
61+
visualizations to the repository**. We store benchmark results in a `separate
62+
repository <https://github.com/tensorwerk/hangar-benchmarks>`_ so to not
63+
clutter the main repo with un-necessary data. The default directories these are
64+
generated in are excluded in our ``.gitignore`` config, so baring some unusual
65+
git usage patterns, this should not be a day-to-day concern.
66+
67+
2. Proposed changes to the benchmark suite should be made to the code in this
68+
repository first. The benchmark results repository mirror will be
69+
synchronized upon approval/merge of changes to the main Hangar repo.
70+
71+
72+
Introduction to Running Benchmarks
73+
**********************************
774

875
As ASV sets up and manages it's own virtual environments and source
9-
installations, benchmark execution is not run via ``tox``. Please refer to the
10-
`ASV Docs <https://https://asv.readthedocs.io/>`_ for information on how to run
11-
this suite locally. All pull requests to the main Hangar GitHub Repo are
12-
automatically benchmarked by our CI servers, and all results are compared to
13-
the ``master`` branch to identify any regressions early in the PR process.
76+
installations, benchmark execution is not run via ``tox``. While a brief
77+
tutorial is included below, please refer to the `ASV Docs
78+
<https://asv.readthedocs.io/>`_ for detailed information on how to both run,
79+
understand, and write ASV benchmarks.
80+
81+
First Time Setup
82+
----------------
83+
84+
1. Ensure that ``virtualenv``, ``setuptools``, ``pip`` are updated to the
85+
latest version.
86+
87+
2. Install ASV ``$ pip install asv``.
88+
89+
3. Open a terminal and navigate to the ``hangar-py/asv-bench`` directory.
90+
91+
4. Run ``$ asv machine`` to record details of your machine, it is OK to
92+
just use the defaults.
93+
94+
95+
Running Benchmarks
96+
------------------
97+
98+
Refer to the `using ASV
99+
<https://asv.readthedocs.io/en/stable/using.html#running-benchmarks>`_ page for
100+
a full tutorial, paying close attention to the `asv run
101+
<https://asv.readthedocs.io/en/stable/commands.html#asv-run>`_ command.
102+
Generally ``asv run`` requires a range of commits to benchmark across
103+
(specified via either branch name, tags, or commit digests).
104+
105+
To benchmark every commit between the current master ``HEAD`` and ``v0.3.0``,
106+
you would execute::
107+
108+
$ asv run v0.2.0..master
109+
110+
However, this may result in a larger workload then you are willing to wait
111+
around for. To limit the number of commits, you can specify the ``--steps=N``
112+
option to only benchmark ``N`` commits at most between ``HEAD`` and ``v0.3.0``.
113+
114+
The most useful tool during development is the `asv continuous
115+
<https://asv.readthedocs.io/en/stable/commands.html#asv-continuous>`_ command.
116+
using the following syntax will benchmark any changes in a local development
117+
branch against the base ``master`` commit::
118+
119+
$ asv continuous origin/master HEAD
120+
121+
Running `asv compare
122+
<https://asv.readthedocs.io/en/stable/commands.html#asv-compare>`_ will
123+
generate a quick summary of any performance differences::
124+
125+
$ asv compare origin/master HEAD
126+
127+
Visualizing Results
128+
-------------------
129+
130+
After generating benchmark data for a number of commits through history, the
131+
results can be reviewed in (an automatically generated) local web interface by
132+
running the following commands::
133+
134+
$ asv publish
135+
$ asv preview
14136

15-
* Benchmark Results Repo: https://github.com/tensorwerk/hangar-benchmarks
137+
Navigating to ``http://127.0.0.1:8080/`` will pull up an interactive webpage
138+
where the full set of benchmark graphs/explorations utilities can be viewed.
139+
This will look something like the image below.
16140

17-
* Benchmark Web View: https://tensorwerk.com/hangar-benchmarks
141+
.. figure:: ../docs/img/asv-main.png
142+
:align: center

docs/Tutorial-001.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
"\n",
232232
"See the docstrings below or in [init_arrayset()](api.rst#hangar.arrayset.Arraysets.init_arrayset)\n",
233233
"\n",
234-
".. automethod:: hangar.arrayset.Arraysets.init_arrayset"
234+
".. include:: ./noindexapi/apiinit.rst"
235235
]
236236
},
237237
{

docs/Tutorial-003.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@
806806
"\n",
807807
"The amount / type of data to retrieve is extremly configurable via the following options:\n",
808808
"\n",
809-
".. automethod:: hangar.repository.Remotes.fetch_data\n",
809+
".. include:: ./noindexapi/apiremotefetchdata.rst\n",
810810
"\n",
811811
"This will retrieve all the data on the `master` branch, but not on the `add-train` branch."
812812
]
@@ -1619,4 +1619,4 @@
16191619
},
16201620
"nbformat": 4,
16211621
"nbformat_minor": 4
1622-
}
1622+
}

docs/benchmarking.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. include:: ../asv_bench/README.rst

docs/contributingindex.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. _ref-contributing:
2+
3+
######################
4+
Contributing to Hangar
5+
######################
6+
7+
.. toctree::
8+
:maxdepth: 3
9+
:titlesonly:
10+
11+
contributing
12+
codeofconduct
13+
benchmarking

docs/img/asv-detailed.png

588 KB
Loading

docs/img/asv-main.png

369 KB
Loading

docs/index.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
externals
1616
faq
1717
backends
18-
contributing
19-
codeofconduct
18+
contributingindex
2019
authors
2120
changelog
2221

docs/noindexapi/apiinit.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. automethod:: hangar.arrayset.Arraysets.init_arrayset
2+
:noindex:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.. automethod:: hangar.repository.Remotes.fetch_data
2+
:noindex:

0 commit comments

Comments
 (0)