commit | 37e642e07a535938ec8027213575dbc40b4407f0 | [log] [tgz] |
---|---|---|
author | Todd Lee <leetodd@google.com> | Thu Nov 05 21:43:23 2020 |
committer | Todd Lee <leetodd@google.com> | Fri Nov 06 19:28:08 2020 |
tree | 1a23ac2a6dfc82b7e7b3cbde8ff36f12a041a5bd | |
parent | b357824f9ce68876c43aa65765a828e84358cc10 [diff] |
[budgets] add budget/owner support for binary sizes This change adds support for including optional budget info from the binary_sizes dictionary. https://screenshot.googleplex.com/6HAix9d6ceZn7gY.png Here we extend the original dictionary format, which was limited just binary name + size data of the form: { "foo.so": 1024, } To now include budget & optional owner info of the form: { "foo.so": 1024, "foo.so.budget": 2048, "foo.so.owner": "mailto:foo_owner@gmail.com", } The budget info is only shown in the UI when there is at least one budget entry in the dictionary. The owner URL (when present) is a link that will be followed when the respective budget value is clicked. This change is backwards compatible with the original binary-sizes dictionary format. Bug: fuchsia:63619 Change-Id: If64c57febd487685272e833fa04229b0a7b544aa
The plugin queries tryjobs for the current patchset on Gerrit, and gets the binary_sizes
property from each of them. It also queries the equivalent CI jobs for the same base revision, and gets the same property from them. It then displays the results in a table, with rows being the files (keys in binary_sizes
dict), and the columns being:
Size before | Size after | Size delta (including %) | Budget info | File | Builder
This is based on JSON output of the form:
{ “some binary name”: BINARY_SIZE_IN_BYTES, “some binary name.budget”: BINARY_SIZE_BUDGET_IN_BYTES, “some binary name.owner”: OWNER_URL, }
For example:
{ “foo”: 1024, “foo.budget”: 2048, “foo.owner”: “mailto:foo_owner@gmail.com” “bar”: 2048, }
Note that including a *.budget item for any given binary is optional. If no budget items are provided, then the “Budget info” column will be omitted from the results table. In the event that a *.budget item is specified, an addition *.owner item can be used to provide a URL for context/ownership related to the pertinent budget item (in the UI, the budget value is clickable, taking the user to the provided URL).
This plugin is configured via the binary-size.config
file present in the repo‘s refs/meta/config
ref, as well as the same file in all repositories in the repo’s inheritance chain (up to and including All-Projects).
See an example of binary-size.config:
https://webrtc.googlesource.com/src/+/refs/meta/config/binary-size.config
Also a short snippet below:
[host] git = "webrtc.googlesource.com" gerrit = "webrtc-review.googlesource.com" [builder "luci.webrtc.try/linux_rel"] base = "luci.webrtc.ci/Linux64 Release" # Optional, needed if the base builder is triggered from a different repo # than the try builder. Assumed to be hosted on [host].git. baseRepo = "foo" [builder "luci.webrtc.try/win_x64_clang_rel"] base = "luci.webrtc.ci/Win64 Release (Clang)"
This contains a mapping between tryjob builders and equivalent postsubmit builders. Equivalent in the sense that if they ran with the same code, they would produce the same binary_sizes
. The plugin queries builds only from buckets that are mentioned at least once. It is OK to specify builders that don't provide a binary_sizes
property, they will just be ignored.
Note that populating the binary_sizes
property is a separate responsibility, and it is up to you to implement in your recipes. It needs to be a dict like {"some_file.so": 123456, ...}
. The values of the dict are treated as sizes in bytes.
All changes to binary-size.config
files are instantly reflected. There is no caching period or need to restart the server.
This plugin requires the buildbucket plugin in order to search builds. Ensure that they are both installed, or prepare to see errors in the browser's console.
git clone --recursive https://gerrit.googlesource.com/gerrit cd gerrit/plugins git clone https://chromium.googlesource.com/infra/gerrit-plugins/buildbucket cd buildbucket ln -s src/main/resources/static static # May be unneeded in the future. cd .. git clone https://chromium.googlesource.com/infra/gerrit-plugins/binary-size cd binary-size
Use the script run-with-prod-data.sh
(based on polygerrit-ui/run-server.sh
). You may change some paths by setting environment variables, for example:
# Install dependencies: sudo apt-get install -y nodejs GERRIT_DIR="$HOME/gerrit" ./run-with-prod-data.sh
You can test on a live Gerrit instance by replacing the plugin JavaScript using Gerrit FE Dev Helper.
Note: this works only for frontend (JavaScript) changes. Not for changes to the backennd (Java) code.
cd <root of gerrit checkout> bazel build plugins/binary-size:all # Ensure the bundle was built BUNDLE_PATH=$(find bazel-out/ -name binary-size-bundle.js) echo ${BUNDLE_PATH} cd $(dirname ${BUNDLE_PATH}) python3 -m http.server 8080
Install the Gerrit FE Dev Helper Chrome extension.
Navigate to a Gerrit page that you expect to show size diffs. E.g. https://webrtc-review.googlesource.com/c/src/+/188502.
Configure the Gerrit FE Dev Helper to redirect to your local binary-size-bundle.js. For example:
Target: https://webrtc-review.googlesource.com/plugins/binary-size/static/binary-size.js
, Operator: redirect
, Destination: http://localhost:8080/binary-size-bundle.js
Note it may also be necessary to redirect the CDN for the polygerrit_assets to reflect changes to static html etc in the bundled plugin. You can find the appropriate URL under the “Sources” section of Chrome's developer console. It will look something like this, but possibly with a different versioning number (e.g. 426.0):
https://cdn.googlesource.com/polygerrit_assets/426.0/plugins/binary-size/static/binary-size.js
This redirect should also go to http://localhost:8080/binary-size-bundle.js
# Install dependencies. sudo apt-get install -y npm npm install -g bower npm install -g web-component-tester cd test/ bower install # Run the tests from the directory root. cd ../ wct
Note: Testing is disabled for Safari due to this issue.