From 60a9051922474787e7a9e2325a5206b5a7122bcd Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Sun, 24 Sep 2023 15:48:09 +0000 Subject: binderThroughputTest: gather servers right away Start gathering servers upon worker creation. Don't wait until signaled by test. This should allow all clients to start transactions at a better coordinated time. Change-Id: I4568eb55fc9ce18839c1e5592a722a0284987745 Test: Ran a benchmark on cuttlefish, and it did not get stuck Signed-off-by: Carlos Llamas Co-developed-by: Alice Ryhl Signed-off-by: Alice Ryhl --- libs/binder/tests/binderThroughputTest.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp index d7f631828a..b899c34e95 100644 --- a/libs/binder/tests/binderThroughputTest.cpp +++ b/libs/binder/tests/binderThroughputTest.cpp @@ -220,6 +220,9 @@ void worker_fx(int num, workers.push_back(serviceMgr->waitForService(generateServiceName(i))); } + p.signal(); + p.wait(); + // Run the benchmark if client ProcResults results(iterations); @@ -300,8 +303,15 @@ void run_main(int iterations, pipes.push_back(make_worker(i, iterations, workers, payload_size, cs_pair)); } wait_all(pipes); + // All workers have now been spawned and added themselves to service + // manager. Signal each worker to obtain a handle to the server workers from + // servicemanager. + signal_all(pipes); + // Wait for each worker to finish obtaining a handle to all server workers + // from servicemanager. + wait_all(pipes); - // Run the workers and wait for completion. + // Run the benchmark and wait for completion. chrono::time_point start, end; cout << "waiting for workers to complete" << endl; start = chrono::high_resolution_clock::now(); -- cgit v1.2.3-59-g8ed1b From 625212e119d8ca2a6fc80a17db251b89b10aea7e Mon Sep 17 00:00:00 2001 From: Carlos Llamas Date: Sun, 24 Sep 2023 16:16:18 +0000 Subject: binderThroughputTest: skip benchmark loop for servers Skip the entire benchmarking loop if this is a server worker instead of asking the same fixed question on every single iteration. Change-Id: I66d1578132099ea1cb4a3b5a10a830bb11b579a2 Test: Ran a benchmark on cuttlefish, and it did not get stuck Signed-off-by: Carlos Llamas Co-developed-by: Alice Ryhl Signed-off-by: Alice Ryhl --- libs/binder/tests/binderThroughputTest.cpp | 40 ++++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/libs/binder/tests/binderThroughputTest.cpp b/libs/binder/tests/binderThroughputTest.cpp index b899c34e95..10912c7363 100644 --- a/libs/binder/tests/binderThroughputTest.cpp +++ b/libs/binder/tests/binderThroughputTest.cpp @@ -223,29 +223,31 @@ void worker_fx(int num, p.signal(); p.wait(); - // Run the benchmark if client ProcResults results(iterations); - chrono::time_point start, end; - for (int i = 0; (!cs_pair || num >= server_count) && i < iterations; i++) { - Parcel data, reply; - int target = cs_pair ? num % server_count : rand() % workers.size(); - int sz = payload_size; - - while (sz >= sizeof(uint32_t)) { - data.writeInt32(0); - sz -= sizeof(uint32_t); - } - start = chrono::high_resolution_clock::now(); - status_t ret = workers[target]->transact(BINDER_NOP, data, &reply); - end = chrono::high_resolution_clock::now(); - uint64_t cur_time = uint64_t(chrono::duration_cast(end - start).count()); - results.add_time(cur_time); + // Skip the benchmark if server of a cs_pair. + if (!(cs_pair && num < server_count)) { + for (int i = 0; i < iterations; i++) { + Parcel data, reply; + int target = cs_pair ? num % server_count : rand() % workers.size(); + int sz = payload_size; + + while (sz >= sizeof(uint32_t)) { + data.writeInt32(0); + sz -= sizeof(uint32_t); + } + start = chrono::high_resolution_clock::now(); + status_t ret = workers[target]->transact(BINDER_NOP, data, &reply); + end = chrono::high_resolution_clock::now(); + + uint64_t cur_time = uint64_t(chrono::duration_cast(end - start).count()); + results.add_time(cur_time); - if (ret != NO_ERROR) { - cout << "thread " << num << " failed " << ret << "i : " << i << endl; - exit(EXIT_FAILURE); + if (ret != NO_ERROR) { + cout << "thread " << num << " failed " << ret << "i : " << i << endl; + exit(EXIT_FAILURE); + } } } -- cgit v1.2.3-59-g8ed1b