aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/cpp/microbenchmarks
diff options
context:
space:
mode:
authorGravatar Hope Casey-Allen <hcaseyal@google.com>2018-09-19 22:40:59 -0700
committerGravatar Hope Casey-Allen <hcaseyal@google.com>2018-09-20 09:54:59 -0700
commitd44feec92ffd1edff7836409f38069edc0836d63 (patch)
tree73a29f3b8f3003f21e34e2e7ae91a287aad9cb88 /test/cpp/microbenchmarks
parent4b721fbde0b6a623968987b52a9500471242cfcb (diff)
Reassign arena pointer instead of stomping on memory
Diffstat (limited to 'test/cpp/microbenchmarks')
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index 528cabd0e3..ba712548e6 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/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_init(&p);
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_user_data = arena;
for (auto slice : init_slices) {
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();
// Recreate arena every 4k iterations to avoid oom
if (0 == (state.iterations() & 0xfff)) {
- gpr_arena_destroy(arena);
- arena = gpr_arena_create(kArenaSize);
+ gpr_arena_destroy((gpr_arena*)p.on_header_user_data);
+ p.on_header_user_data = gpr_arena_create(kArenaSize);
}
}
// 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 : benchmark_slices) grpc_slice_unref(slice);
grpc_chttp2_hpack_parser_destroy(&p);