Reassign arena pointer instead of stomping on memory

pull/16629/head
Hope Casey-Allen 6 years ago
parent 4b721fbde0
commit d44feec92f
  1. 9
      test/cpp/microbenchmarks/bm_chttp2_hpack.cc

@ -458,9 +458,8 @@ static void BM_HpackParserParseHeader(benchmark::State& state) {
grpc_chttp2_hpack_parser p; grpc_chttp2_hpack_parser p;
grpc_chttp2_hpack_parser_init(&p); grpc_chttp2_hpack_parser_init(&p);
const int kArenaSize = 4096 * 4096; const int kArenaSize = 4096 * 4096;
gpr_arena* arena = gpr_arena_create(kArenaSize); p.on_header_user_data = gpr_arena_create(kArenaSize);
p.on_header = OnHeader; p.on_header = OnHeader;
p.on_header_user_data = arena;
for (auto slice : init_slices) { for (auto slice : init_slices) {
GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice)); GPR_ASSERT(GRPC_ERROR_NONE == grpc_chttp2_hpack_parser_parse(&p, slice));
} }
@ -471,12 +470,12 @@ static void BM_HpackParserParseHeader(benchmark::State& state) {
grpc_core::ExecCtx::Get()->Flush(); grpc_core::ExecCtx::Get()->Flush();
// Recreate arena every 4k iterations to avoid oom // Recreate arena every 4k iterations to avoid oom
if (0 == (state.iterations() & 0xfff)) { if (0 == (state.iterations() & 0xfff)) {
gpr_arena_destroy(arena); gpr_arena_destroy((gpr_arena*)p.on_header_user_data);
arena = gpr_arena_create(kArenaSize); p.on_header_user_data = gpr_arena_create(kArenaSize);
} }
} }
// Clean up // Clean up
gpr_arena_destroy(arena); gpr_arena_destroy((gpr_arena*)p.on_header_user_data);
for (auto slice : init_slices) grpc_slice_unref(slice); for (auto slice : init_slices) grpc_slice_unref(slice);
for (auto slice : benchmark_slices) grpc_slice_unref(slice); for (auto slice : benchmark_slices) grpc_slice_unref(slice);
grpc_chttp2_hpack_parser_destroy(&p); grpc_chttp2_hpack_parser_destroy(&p);

Loading…
Cancel
Save