From ac5522bef7755089f631802aa213259e1d6f74df Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Thu, 2 Nov 2017 13:17:02 -0700 Subject: Revert "Fix benchmark crash" --- .../fullstack_streaming_ping_pong.h | 47 +++++++++------------- 1 file changed, 19 insertions(+), 28 deletions(-) (limited to 'test') diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h index 06d18b890d..6df044f344 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h @@ -278,7 +278,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { void* t; bool ok; - int expect_tags; + int need_tags; // Send 'max_ping_pongs' number of ping pong messages int ping_pong_cnt = 0; @@ -289,7 +289,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { request_rw->Write(send_request, tag(2)); // Start client send } - int await_tags = (1 << 2); + need_tags = (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5); if (ping_pong_cnt == 0) { // wait for the server call structure (call_hook, etc.) to be @@ -301,8 +301,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { // In some cases tag:2 comes before tag:0 (write tag comes out // first), this while loop is to make sure get tag:0. int i = (int)(intptr_t)t; - GPR_ASSERT(await_tags & (1 << i)); - await_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); GPR_ASSERT(fixture->cq()->Next(&t, &ok)); } } @@ -310,11 +310,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { response_rw.Read(&recv_request, tag(3)); // Start server recv request_rw->Read(&recv_response, tag(4)); // Start client recv - await_tags |= (1 << 3) | (1 << 4); - expect_tags = await_tags; - await_tags |= (1 << 5); - - while (await_tags != 0) { + while (need_tags) { GPR_ASSERT(fixture->cq()->Next(&t, &ok)); GPR_ASSERT(ok); int i = (int)(intptr_t)t; @@ -325,39 +321,34 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { if (write_and_finish == 1) { response_rw.WriteAndFinish(send_response, WriteOptions(), Status::OK, tag(5)); - expect_tags |= (1 << 5); } else { response_rw.WriteLast(send_response, WriteOptions(), tag(5)); - // WriteLast buffers the write, so it's possible neither server - // write op nor client read op will finish inside the while - // loop. - await_tags &= ~(1 << 4); - await_tags &= ~(1 << 5); - expect_tags |= (1 << 5); + // WriteLast buffers the write, so neither server write op nor + // client read op will finish inside the while loop. + need_tags &= ~(1 << 4); + need_tags &= ~(1 << 5); } } else { response_rw.Write(send_response, tag(5)); - expect_tags |= (1 << 5); } } - GPR_ASSERT(expect_tags & (1 << i)); - expect_tags &= ~(1 << i); - await_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); } ping_pong_cnt++; } if (max_ping_pongs == 0) { - expect_tags |= (1 << 6) | (1 << 7) | (1 << 8); + need_tags = (1 << 6) | (1 << 7) | (1 << 8); } else { if (write_and_finish == 1) { - expect_tags |= (1 << 8); + need_tags = (1 << 8); } else { // server's buffered write and the client's read of the buffered write // tags should come up. - expect_tags |= (1 << 7) | (1 << 8); + need_tags = (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8); } } @@ -369,8 +360,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { GPR_ASSERT(fixture->cq()->Next(&t, &ok)); while ((int)(intptr_t)t != 0) { int i = (int)(intptr_t)t; - GPR_ASSERT(expect_tags & (1 << i)); - expect_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); GPR_ASSERT(fixture->cq()->Next(&t, &ok)); } response_rw.Finish(Status::OK, tag(7)); @@ -383,11 +374,11 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { Status recv_status; request_rw->Finish(&recv_status, tag(8)); - while (expect_tags) { + while (need_tags) { GPR_ASSERT(fixture->cq()->Next(&t, &ok)); int i = (int)(intptr_t)t; - GPR_ASSERT(expect_tags & (1 << i)); - expect_tags &= ~(1 << i); + GPR_ASSERT(need_tags & (1 << i)); + need_tags &= ~(1 << i); } GPR_ASSERT(recv_status.ok()); -- cgit v1.2.3