Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce bloat_diff #12832

Merged
merged 4 commits into from
Oct 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@
path = third_party/cares/cares
url = https://github.com/c-ares/c-ares.git
branch = cares-1_12_0
[submodule "third_party/bloaty"]
path = third_party/bloaty
url = https://github.com/google/bloaty.git
1 change: 1 addition & 0 deletions third_party/bloaty
Submodule bloaty added at 73594c
2 changes: 2 additions & 0 deletions tools/internal_ci/linux/grpc_microbenchmark_diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ cd $(dirname $0)/../../..
source tools/internal_ci/helper_scripts/prepare_build_linux_perf_rc

tools/run_tests/start_port_server.py
tools/jenkins/run_c_cpp_test.sh tools/profiling/bloat/bloat_diff.py \
-d origin/$ghprbTargetBranch || FAILED="true"
tools/jenkins/run_c_cpp_test.sh tools/profiling/microbenchmarks/bm_diff/bm_main.py \
-d origin/$ghprbTargetBranch \
-b $BENCHMARKS_TO_RUN || FAILED="true"
Expand Down
99 changes: 99 additions & 0 deletions tools/profiling/bloat/bloat_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#!/usr/bin/env python2.7
#
# Copyright 2017 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import argparse
import glob
import multiprocessing
import os
import shutil
import subprocess
import sys

sys.path.append(
os.path.join(
os.path.dirname(sys.argv[0]), '..', '..', 'run_tests', 'python_utils'))
import comment_on_pr

argp = argparse.ArgumentParser(
description='Perform diff on microbenchmarks')

argp.add_argument(
'-d',
'--diff_base',
type=str,
help='Commit or branch to compare the current one to')

argp.add_argument(
'-j',
'--jobs',
type=int,
default=multiprocessing.cpu_count())

args = argp.parse_args()

LIBS = [
'libgrpc.so',
'libgrpc++.so',
]

def build(where):
subprocess.check_call('make -j%d' % args.jobs,
shell=True, cwd='.')
shutil.rmtree('bloat_diff_%s' % where, ignore_errors=True)
os.rename('libs', 'bloat_diff_%s' % where)

build('new')

if args.diff_base:
old = 'old'
where_am_i = subprocess.check_output(
['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
subprocess.check_call(['git', 'checkout', args.diff_base])
subprocess.check_call(['git', 'submodule', 'update'])
try:
try:
build('old')
except subprocess.CalledProcessError, e:
subprocess.check_call(['make', 'clean'])
build('old')
finally:
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')

text = ''
for lib in LIBS:
text += '****************************************************************\n\n'
text += lib + '\n\n'
old_version = glob.glob('bloat_diff_old/opt/%s' % lib)
new_version = glob.glob('bloat_diff_new/opt/%s' % lib)
assert len(new_version) == 1
cmd = 'third_party/bloaty/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)
else:
text += subprocess.check_output('%s %s' %
(cmd, new_version[0]),
shell=True)
text += '\n\n'

print text
comment_on_pr.comment_on_pr('```\n%s\n```' % text)
1 change: 1 addition & 0 deletions tools/run_tests/sanity/check_submodules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ cat << EOF | awk '{ print $1 }' | sort > $want_submodules
80a37e0782d2d702d52234b62dd4b9ec74fd2c95 third_party/protobuf (v3.4.0)
cacf7f1d4e3d44d871b605da3b647f07d718623f third_party/zlib (v1.2.11)
3be1924221e1326df520f8498d704a5c4c8d0cce third_party/cares/cares (cares-1_13_0)
73594cde8c9a52a102c4341c244c833aa61b9c06 third_party/bloaty
EOF

diff -u $submodules $want_submodules
Expand Down