diff --git a/third_party/bloaty b/third_party/bloaty index 73594cde8c9..60209eb1ccc 160000 --- a/third_party/bloaty +++ b/third_party/bloaty @@ -1 +1 @@ -Subproject commit 73594cde8c9a52a102c4341c244c833aa61b9c06 +Subproject commit 60209eb1ccc34d5deefb002d1b7f37545204f7f2 diff --git a/tools/profiling/bloat/bloat_diff.py b/tools/profiling/bloat/bloat_diff.py index b6bd1de6575..9d1d0158f8c 100755 --- a/tools/profiling/bloat/bloat_diff.py +++ b/tools/profiling/bloat/bloat_diff.py @@ -15,9 +15,12 @@ # limitations under the License. import argparse +import csv import glob +import math import multiprocessing import os +import pathlib import shutil import subprocess import sys @@ -71,27 +74,48 @@ if args.diff_base: subprocess.check_call(['git', 'checkout', where_am_i]) subprocess.check_call(['git', 'submodule', 'update']) -subprocess.check_call('make -j%d' % args.jobs, - shell=True, - cwd='third_party/bloaty') +pathlib.Path('bloaty-build').mkdir(exist_ok=True) +subprocess.check_call( + ['cmake', '-G', 'Unix Makefiles', '../third_party/bloaty'], + cwd='bloaty-build') +subprocess.check_call('make -j%d' % args.jobs, shell=True, cwd='bloaty-build') text = '' +diff_size = 0 for lib in LIBS: text += '****************************************************************\n\n' text += lib + '\n\n' old_version = glob.glob('bloat_diff_old/%s' % lib) new_version = glob.glob('bloat_diff_new/%s' % lib) assert len(new_version) == 1 - cmd = 'third_party/bloaty/bloaty -d compileunits,symbols' + cmd = 'bloaty-build/bloaty -d compileunits,symbols' if old_version: assert len(old_version) == 1 text += subprocess.check_output('%s %s -- %s' % (cmd, new_version[0], old_version[0]), shell=True).decode() + for filename in [old_version, new_version]: + subprocess.check_call('strip %s' % filename[0], shell=True) + sections = [ + x for x in csv.reader( + subprocess.check_output('bloaty-build/bloaty --csv %s -- %s' % + (old_version[0], new_version[0]), + shell=True).decode().splitlines()) + ] + print(sections) + for section in sections[1:]: + diff_size += int(section[2]) else: text += subprocess.check_output('%s %s' % (cmd, new_version[0]), shell=True).decode() text += '\n\n' +severity = int( + math.copysign(max(0, math.log(abs(diff_size) / 1000, 10), + diff_size))) if diff_size != 0 else 0 + +print("SEVERITY: %d" % severity) + print(text) check_on_pr.check_on_pr('Bloat Difference', '```\n%s\n```' % text) +check_on_pr.label_significance_on_pr('bloat', severity) diff --git a/tools/run_tests/python_utils/check_on_pr.py b/tools/run_tests/python_utils/check_on_pr.py index 12db1c4d45c..7bd91fec079 100644 --- a/tools/run_tests/python_utils/check_on_pr.py +++ b/tools/run_tests/python_utils/check_on_pr.py @@ -33,6 +33,14 @@ _ACCESS_TOKEN_CACHE = None _ACCESS_TOKEN_FETCH_RETRIES = 6 _ACCESS_TOKEN_FETCH_RETRIES_INTERVAL_S = 15 +_CHANGE_LABELS = { + -1: 'improvement', + 0: 'none', + 1: 'low', + 2: 'medium', + 3: 'high', +} + def _jwt_token(): github_app_key = open( @@ -139,3 +147,42 @@ def check_on_pr(name, summary, success=True): }) print('Result of Creating/Updating Check on PR:', json.dumps(resp.json(), indent=2)) + + +def label_significance_on_pr(name, change): + """Add a label to the PR indicating the significance of the check. + + Requires environment variable 'KOKORO_GITHUB_PULL_REQUEST_NUMBER' to indicate which pull request + should be updated. + + Args: + name: The name of the label. + value: A str in Markdown to be used as the detail information of the label. + """ + if change < min(list(_CHANGE_LABELS.keys())): + change = min(list(_CHANGE_LABELS.keys())) + if change > max(list(_CHANGE_LABELS.keys())): + change = max(list(_CHANGE_LABELS.keys())) + value = _CHANGE_LABELS[change] + if 'KOKORO_GIT_COMMIT' not in os.environ: + print('Missing KOKORO_GIT_COMMIT env var: not checking') + return + if 'KOKORO_KEYSTORE_DIR' not in os.environ: + print('Missing KOKORO_KEYSTORE_DIR env var: not checking') + return + if 'KOKORO_GITHUB_PULL_REQUEST_NUMBER' not in os.environ: + print('Missing KOKORO_GITHUB_PULL_REQUEST_NUMBER env var: not checking') + return + existing = _call( + '/repos/%s/issues/%s/labels' % + (_GITHUB_REPO, os.environ['KOKORO_GITHUB_PULL_REQUEST_NUMBER']), + method='GET').json() + print('Result of Deleting Labels on PR:', existing) + new = [x['name'] for x in existing if not x['name'].startswith(name + '/')] + new.append(name + '/' + value) + resp = _call( + '/repos/%s/issues/%s/labels' % + (_GITHUB_REPO, os.environ['KOKORO_GITHUB_PULL_REQUEST_NUMBER']), + method='POST', + json=new) + print('Result of Adding Label on PR:', resp.text) diff --git a/tools/run_tests/sanity/check_submodules.sh b/tools/run_tests/sanity/check_submodules.sh index e6fee2edb82..c779fda231a 100755 --- a/tools/run_tests/sanity/check_submodules.sh +++ b/tools/run_tests/sanity/check_submodules.sh @@ -27,7 +27,7 @@ git submodule | awk '{ print $2 " " $1 }' | sort >"$submodules" cat <"$want_submodules" third_party/abseil-cpp 278e0a071885a22dcd2fd1b5576cc44757299343 third_party/benchmark 0baacde3618ca617da95375e0af13ce1baadea47 -third_party/bloaty 73594cde8c9a52a102c4341c244c833aa61b9c06 +third_party/bloaty 60209eb1ccc34d5deefb002d1b7f37545204f7f2 third_party/boringssl-with-bazel 95b3ed1b01f2ef1d72fed290ed79fe1b0e7dafc0 third_party/cares/cares e982924acee7f7313b4baa4ee5ec000c5e373c30 third_party/envoy-api 20b1b5fcee88a20a08b71051a961181839ec7268