From 68be8a7742c889cdd0ba11654ee19a593a7e02e0 Mon Sep 17 00:00:00 2001 From: Lidi Zheng Date: Mon, 10 Feb 2020 13:21:51 -0800 Subject: [PATCH] Improve log readability & polish scenario parameters --- .../tests_aio/benchmark/worker_servicer.py | 19 ++++++-- .../run_tests/performance/scenario_config.py | 47 +++++++++++-------- 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/python/grpcio_tests/tests_aio/benchmark/worker_servicer.py b/src/python/grpcio_tests/tests_aio/benchmark/worker_servicer.py index 18a6e3f2207..f23b07c9151 100644 --- a/src/python/grpcio_tests/tests_aio/benchmark/worker_servicer.py +++ b/src/python/grpcio_tests/tests_aio/benchmark/worker_servicer.py @@ -34,12 +34,24 @@ from tests.unit.framework.common import get_socket _NUM_CORES = multiprocessing.cpu_count() _NUM_CORE_PYTHON_CAN_USE = 1 _WORKER_ENTRY_FILE = os.path.split(os.path.abspath(__file__))[0] + '/worker.py' -_SubWorker = collections.namedtuple('_SubWorker', - ['process', 'port', 'channel', 'stub']) _LOGGER = logging.getLogger(__name__) +class _SubWorker( + collections.namedtuple('_SubWorker', + ['process', 'port', 'channel', 'stub'])): + + def _repr(self): + return f'<_SubWorker pid={self.process.pid} port={self.port}>' + + def __repr__(self): + return self._repr() + + def __str__(self): + return self._repr() + + def _get_server_status(start_time: float, end_time: float, port: int) -> control_pb2.ServerStatus: end_time = time.time() @@ -231,9 +243,8 @@ class WorkerServicer(worker_service_pb2_grpc.WorkerServiceServicer): for worker in sub_workers: await worker.stub.QuitWorker(control_pb2.Void()) await worker.channel.close() - _LOGGER.info('Waiting for sub worker [%s] to quit...', worker) + _LOGGER.info('Waiting for [%s] to quit...', worker) await worker.process.wait() - _LOGGER.info('Sub worker [%s] quit', worker) async def _run_single_client(self, config, request_iterator, context): running_tasks = [] diff --git a/tools/run_tests/performance/scenario_config.py b/tools/run_tests/performance/scenario_config.py index b7791afc4ce..c8c7f8875ed 100644 --- a/tools/run_tests/performance/scenario_config.py +++ b/tools/run_tests/performance/scenario_config.py @@ -829,27 +829,34 @@ class PythonAsyncIOLanguage: return 1200 def scenarios(self): - yield _ping_pong_scenario( - 'python_asyncio_protobuf_async_unary_ping_pong_64_max', - rpc_type='UNARY', - client_type='ASYNC_CLIENT', - server_type='ASYNC_SERVER', - outstanding=64, - channels=1, - unconstrained_client='async', - categories=[SMOKETEST, SCALABLE]) + for outstanding in [32, 64, 128, 256]: + for channels in [1, 5]: + yield _ping_pong_scenario( + 'python_asyncio_protobuf_async_unary_ping_pong_%dx%d_max' % + ( + outstanding, + channels, + ), + rpc_type='UNARY', + client_type='ASYNC_CLIENT', + server_type='ASYNC_SERVER', + outstanding=outstanding, + channels=channels, + unconstrained_client='async', + categories=[SMOKETEST, SCALABLE]) - yield _ping_pong_scenario( - 'python_asyncio_protobuf_async_unary_ping_pong_128_1thread', - rpc_type='UNARY', - client_type='ASYNC_CLIENT', - server_type='ASYNC_SERVER', - outstanding=128, - channels=1, - async_client_threads=1, - async_server_threads=1, - unconstrained_client='async', - categories=[SMOKETEST, SCALABLE]) + yield _ping_pong_scenario( + 'python_asyncio_protobuf_async_unary_ping_pong_%d_1thread' % + outstanding, + rpc_type='UNARY', + client_type='ASYNC_CLIENT', + server_type='ASYNC_SERVER', + outstanding=outstanding, + channels=1, + async_client_threads=1, + async_server_threads=1, + unconstrained_client='async', + categories=[SMOKETEST, SCALABLE]) yield _ping_pong_scenario( 'python_asyncio_generic_async_streaming_ping_pong',