diff options
author | Hope Casey-Allen <hcaseyal@google.com> | 2018-09-13 18:47:40 -0700 |
---|---|---|
committer | Hope Casey-Allen <hcaseyal@google.com> | 2018-09-19 19:13:23 -0700 |
commit | 91727bd015c9fd0ac9076b191520504bc227f685 (patch) | |
tree | 91cbac69eb78daf2e37f39ae61e63dfb564a3752 /test/cpp/microbenchmarks | |
parent | 967bbcd5d38e37f3640101a630e660c1276d7ee3 (diff) |
Move arena create outside of benchmark, format, and typo fix
Diffstat (limited to 'test/cpp/microbenchmarks')
-rw-r--r-- | test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 8d1aa3f10c..f160e77634 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -457,8 +457,10 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { std::vector<grpc_slice> benchmark_slices = Fixture::GetBenchmarkSlices(); grpc_chttp2_hpack_parser p; grpc_chttp2_hpack_parser_init(&p); + const int kArenaSize = 4096; + gpr_arena* arena = gpr_arena_create(kArenaSize); p.on_header = OnHeader; - p.on_header_user_data = nullptr; + p.on_header_user_data = arena; for (auto slice : init_slices) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice)); } @@ -467,6 +469,11 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice)); } grpc_core::ExecCtx::Get()->Flush(); + // recreate arena every 64k iterations to avoid oom + if (0 == (state.iterations() & 0xffff)) { + gpr_arena_destroy(arena); + arena = gpr_arena_create(kArenaSize); + } } for (auto slice : init_slices) grpc_slice_unref(slice); for (auto slice : benchmark_slices) grpc_slice_unref(slice); @@ -769,10 +776,9 @@ static void free_timeout(void* p) { gpr_free(p); } // Benchmark the current on_initial_header implementation static void OnInitialHeader(void* user_data, grpc_mdelem md) { - // Setup for benchmark. this will bloat the absolute values of this benchmark + // Setup for benchmark. This will bloat the absolute values of this benchmark grpc_chttp2_incoming_metadata_buffer buffer; - gpr_arena* arena = gpr_arena_create(1024); - grpc_chttp2_incoming_metadata_buffer_init(&buffer, arena); + grpc_chttp2_incoming_metadata_buffer_init(&buffer, (gpr_arena*)user_data); bool seen_error = false; // Below here is the code we actually care about benchmarking @@ -815,7 +821,6 @@ static void OnInitialHeader(void* user_data, grpc_mdelem md) { GPR_ASSERT(0); } } - gpr_arena_destroy(arena); } // Benchmark timeout handling |