From b56dae554ca14dfd5a76690462b9efbc38314de0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Apr 2017 08:22:24 -0700 Subject: [PATCH 1/5] Allow a longer fetch time for port server --- test/core/util/port_server_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index 38054dd1e74..254c3a6b613 100644 --- a/test/core/util/port_server_client.c +++ b/test/core/util/port_server_client.c @@ -103,7 +103,7 @@ void grpc_free_port_using_server(int port) { grpc_resource_quota *resource_quota = grpc_resource_quota_create("port_server_client/free"); grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req, - grpc_timeout_seconds_to_deadline(10), + grpc_timeout_seconds_to_deadline(30), grpc_closure_create(freed_port_from_server, &pr, grpc_schedule_on_exec_ctx), &rsp); @@ -235,7 +235,7 @@ int grpc_pick_port_using_server(void) { grpc_resource_quota_create("port_server_client/pick"); grpc_httpcli_get( &exec_ctx, &context, &pr.pops, resource_quota, &req, - grpc_timeout_seconds_to_deadline(10), + grpc_timeout_seconds_to_deadline(30), grpc_closure_create(got_port_from_server, &pr, grpc_schedule_on_exec_ctx), &pr.response); grpc_resource_quota_unref_internal(&exec_ctx, resource_quota); From c9c6aa7df0442a2861619a6403380350420871c4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Apr 2017 08:27:31 -0700 Subject: [PATCH 2/5] Be resilient against failed runs --- tools/profiling/microbenchmarks/bm_diff.py | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/profiling/microbenchmarks/bm_diff.py b/tools/profiling/microbenchmarks/bm_diff.py index 6ee4cbfc7bb..3c15478774e 100755 --- a/tools/profiling/microbenchmarks/bm_diff.py +++ b/tools/profiling/microbenchmarks/bm_diff.py @@ -204,7 +204,10 @@ def eintr_be_gone(fn): def read_json(filename): - with open(filename) as f: return json.loads(f.read()) + try: + with open(filename) as f: return json.loads(f.read()) + except ValueError, e: + return None def finalize(): @@ -217,16 +220,18 @@ def finalize(): js_old_ctr = read_json('%s.counters.old.%d.json' % (bm, loop)) js_old_opt = read_json('%s.opt.old.%d.json' % (bm, loop)) - for row in bm_json.expand_json(js_new_ctr, js_new_opt): - print row - name = row['cpp_name'] - if name.endswith('_mean') or name.endswith('_stddev'): continue - benchmarks[name].add_sample(row, True) - for row in bm_json.expand_json(js_old_ctr, js_old_opt): - print row - name = row['cpp_name'] - if name.endswith('_mean') or name.endswith('_stddev'): continue - benchmarks[name].add_sample(row, False) + if js_new_ctr: + for row in bm_json.expand_json(js_new_ctr, js_new_opt): + print row + name = row['cpp_name'] + if name.endswith('_mean') or name.endswith('_stddev'): continue + benchmarks[name].add_sample(row, True) + if js_old_ctr: + for row in bm_json.expand_json(js_old_ctr, js_old_opt): + print row + name = row['cpp_name'] + if name.endswith('_mean') or name.endswith('_stddev'): continue + benchmarks[name].add_sample(row, False) really_interesting = set() for name, bm in benchmarks.items(): From 9fd7cf5dc3fca5a07df03b2dda08519a2e6b308a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Apr 2017 08:34:14 -0700 Subject: [PATCH 3/5] Recycle ports --- test/cpp/microbenchmarks/fullstack_fixtures.h | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index f129ede26a6..98aca1c3465 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -113,13 +113,17 @@ class TCP : public FullstackFixture { public: TCP(Service* service, const FixtureConfiguration& fixture_configuration = FixtureConfiguration()) - : FullstackFixture(service, fixture_configuration, MakeAddress()) {} + : FullstackFixture(service, fixture_configuration, MakeAddress(&port_)) {} + + ~TCP() { grpc_recycle_unused_port(port_); } private: - static grpc::string MakeAddress() { - int port = grpc_pick_unused_port_or_die(); + int port_; + + static grpc::string MakeAddress(int* port) { + *port = grpc_pick_unused_port_or_die(); std::stringstream addr; - addr << "localhost:" << port; + addr << "localhost:" << *port; return addr.str(); } }; @@ -128,14 +132,18 @@ class UDS : public FullstackFixture { public: UDS(Service* service, const FixtureConfiguration& fixture_configuration = FixtureConfiguration()) - : FullstackFixture(service, fixture_configuration, MakeAddress()) {} + : FullstackFixture(service, fixture_configuration, MakeAddress(&port_)) {} + + ~UDS() { grpc_recycle_unused_port(port_); } private: - static grpc::string MakeAddress() { - int port = grpc_pick_unused_port_or_die(); // just for a unique id - not a - // real port + int port_; + + static grpc::string MakeAddress(int* port) { + *port = grpc_pick_unused_port_or_die(); // just for a unique id - not a + // real port std::stringstream addr; - addr << "unix:/tmp/bm_fullstack." << port; + addr << "unix:/tmp/bm_fullstack." << *port; return addr.str(); } }; From a27edc69c3e9b957a32f8d89f4969abe6cc37580 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Apr 2017 09:20:30 -0700 Subject: [PATCH 4/5] Ensure port server running --- tools/jenkins/run_performance.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/jenkins/run_performance.sh b/tools/jenkins/run_performance.sh index 544e31dcbdb..f530fb46b86 100755 --- a/tools/jenkins/run_performance.sh +++ b/tools/jenkins/run_performance.sh @@ -37,4 +37,5 @@ BENCHMARKS_TO_RUN="bm_fullstack_unary_ping_pong bm_fullstack_streaming_ping_pong # Enter the gRPC repo root cd $(dirname $0)/../.. +tools/run_tests/start_port_server.py tools/profiling/microbenchmarks/bm_diff.py -d origin/$ghprbTargetBranch -b $BENCHMARKS_TO_RUN From 09ebed7bf4c19a8c31195b44c8d911f39779323e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Apr 2017 10:19:10 -0700 Subject: [PATCH 5/5] Ensure port server can shutdown --- tools/run_tests/python_utils/port_server.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/run_tests/python_utils/port_server.py b/tools/run_tests/python_utils/port_server.py index 522cbed9e1c..e96ee0b08c1 100755 --- a/tools/run_tests/python_utils/port_server.py +++ b/tools/run_tests/python_utils/port_server.py @@ -46,7 +46,7 @@ import threading # increment this number whenever making a change to ensure that # the changes are picked up by running CI servers # note that all changes must be backwards compatible -_MY_VERSION = 11 +_MY_VERSION = 14 if len(sys.argv) == 2 and sys.argv[1] == 'dump_version': @@ -166,12 +166,11 @@ class Handler(BaseHTTPRequestHandler): elif self.path == '/quitquitquit': self.send_response(200) self.end_headers() - sys.exit(0) + self.server.shutdown() class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): """Handle requests in a separate thread""" -httpd = ThreadedHTTPServer(('', args.port), Handler) -httpd.serve_forever() +ThreadedHTTPServer(('', args.port), Handler).serve_forever()