From 891e8162e409b7048297c5b820a399f19f2a020b Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Wed, 15 Feb 2017 23:30:27 -0800
Subject: Fix escaping in index.html
---
tools/run_tests/run_microbenchmark.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'tools/run_tests/run_microbenchmark.py')
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index 4e60cce868..9bcba598b8 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -28,6 +28,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import cgi
import multiprocessing
import os
import subprocess
@@ -71,11 +72,12 @@ def heading(name):
def link(txt, tgt):
global index_html
- index_html += "%s
\n" % (tgt, txt)
+ index_html += "%s
\n" % (
+ cgi.escape(tgt, quote=True), cgi.escape(txt))
def text(txt):
global index_html
- index_html += "%s
\n" % txt
+ index_html += "%s
\n" % cgi.escape(txt)
def collect_latency(bm_name, args):
"""generate latency profiles"""
--
cgit v1.2.3
From ece502fa12ae9db7fc969f0bae1f7c26ece1dce3 Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Fri, 17 Feb 2017 16:20:50 -0800
Subject: Speed up latency profiling (and tune down the memory usage)
---
tools/run_tests/run_microbenchmark.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
(limited to 'tools/run_tests/run_microbenchmark.py')
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index a9a563c1be..1cafffb52d 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -91,7 +91,9 @@ def collect_latency(bm_name, args):
'--benchmark_list_tests']).splitlines():
link(line, '%s.txt' % fnize(line))
benchmarks.append(
- jobset.JobSpec(['bins/basicprof/%s' % bm_name, '--benchmark_filter=^%s$' % line],
+ jobset.JobSpec(['bins/basicprof/%s' % bm_name,
+ '--benchmark_filter=^%s$' % line,
+ '--benchmark_min_time=0.05'],
environ={'LATENCY_TRACE': '%s.trace' % fnize(line)}))
profile_analysis.append(
jobset.JobSpec([sys.executable,
@@ -103,7 +105,7 @@ def collect_latency(bm_name, args):
# consume upwards of five gigabytes of ram in some cases, and so analysing
# hundreds of them at once is impractical -- but we want at least some
# concurrency or the work takes too long
- if len(benchmarks) >= min(4, multiprocessing.cpu_count()):
+ if len(benchmarks) >= min(16, multiprocessing.cpu_count()):
# run up to half the cpu count: each benchmark can use up to two cores
# (one for the microbenchmark, one for the data flush)
jobset.run(benchmarks, maxjobs=max(1, multiprocessing.cpu_count()/2),
--
cgit v1.2.3
From 523d54beebb4566af5b3f6f7e53ad609de016cbd Mon Sep 17 00:00:00 2001
From: Craig Tiller
Date: Thu, 23 Feb 2017 08:52:38 -0800
Subject: Refine to just be a HPACK benchmark
---
CMakeLists.txt | 10 +-
Makefile | 30 +-
build.yaml | 4 +-
test/cpp/microbenchmarks/bm_chttp2.cc | 442 ---------------------
test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 442 +++++++++++++++++++++
third_party/gflags | 2 +-
tools/run_tests/generated/sources_and_headers.json | 4 +-
tools/run_tests/generated/tests.json | 2 +-
tools/run_tests/run_microbenchmark.py | 7 +-
9 files changed, 474 insertions(+), 469 deletions(-)
delete mode 100644 test/cpp/microbenchmarks/bm_chttp2.cc
create mode 100644 test/cpp/microbenchmarks/bm_chttp2_hpack.cc
(limited to 'tools/run_tests/run_microbenchmark.py')
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3023a4a9d7..b72b8e79d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -570,7 +570,7 @@ if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx bm_call_create)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
-add_dependencies(buildtests_cxx bm_chttp2)
+add_dependencies(buildtests_cxx bm_chttp2_hpack)
endif()
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
add_dependencies(buildtests_cxx bm_closure)
@@ -7407,13 +7407,13 @@ endif (gRPC_BUILD_TESTS)
if (gRPC_BUILD_TESTS)
if(_gRPC_PLATFORM_LINUX OR _gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_POSIX)
-add_executable(bm_chttp2
- test/cpp/microbenchmarks/bm_chttp2.cc
+add_executable(bm_chttp2_hpack
+ test/cpp/microbenchmarks/bm_chttp2_hpack.cc
third_party/googletest/src/gtest-all.cc
)
-target_include_directories(bm_chttp2
+target_include_directories(bm_chttp2_hpack
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${BORINGSSL_ROOT_DIR}/include
@@ -7427,7 +7427,7 @@ target_include_directories(bm_chttp2
PRIVATE ${_gRPC_PROTO_GENS_DIR}
)
-target_link_libraries(bm_chttp2
+target_link_libraries(bm_chttp2_hpack
${_gRPC_PROTOBUF_LIBRARIES}
${_gRPC_ALLTARGETS_LIBRARIES}
benchmark
diff --git a/Makefile b/Makefile
index 333992129e..1fff137589 100644
--- a/Makefile
+++ b/Makefile
@@ -1041,7 +1041,7 @@ alarm_cpp_test: $(BINDIR)/$(CONFIG)/alarm_cpp_test
async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test
auth_property_iterator_test: $(BINDIR)/$(CONFIG)/auth_property_iterator_test
bm_call_create: $(BINDIR)/$(CONFIG)/bm_call_create
-bm_chttp2: $(BINDIR)/$(CONFIG)/bm_chttp2
+bm_chttp2_hpack: $(BINDIR)/$(CONFIG)/bm_chttp2_hpack
bm_closure: $(BINDIR)/$(CONFIG)/bm_closure
bm_cq: $(BINDIR)/$(CONFIG)/bm_cq
bm_error: $(BINDIR)/$(CONFIG)/bm_error
@@ -1450,7 +1450,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/async_end2end_test \
$(BINDIR)/$(CONFIG)/auth_property_iterator_test \
$(BINDIR)/$(CONFIG)/bm_call_create \
- $(BINDIR)/$(CONFIG)/bm_chttp2 \
+ $(BINDIR)/$(CONFIG)/bm_chttp2_hpack \
$(BINDIR)/$(CONFIG)/bm_closure \
$(BINDIR)/$(CONFIG)/bm_cq \
$(BINDIR)/$(CONFIG)/bm_error \
@@ -1560,7 +1560,7 @@ buildtests_cxx: privatelibs_cxx \
$(BINDIR)/$(CONFIG)/async_end2end_test \
$(BINDIR)/$(CONFIG)/auth_property_iterator_test \
$(BINDIR)/$(CONFIG)/bm_call_create \
- $(BINDIR)/$(CONFIG)/bm_chttp2 \
+ $(BINDIR)/$(CONFIG)/bm_chttp2_hpack \
$(BINDIR)/$(CONFIG)/bm_closure \
$(BINDIR)/$(CONFIG)/bm_cq \
$(BINDIR)/$(CONFIG)/bm_error \
@@ -1882,8 +1882,8 @@ test_cxx: buildtests_cxx
$(Q) $(BINDIR)/$(CONFIG)/auth_property_iterator_test || ( echo test auth_property_iterator_test failed ; exit 1 )
$(E) "[RUN] Testing bm_call_create"
$(Q) $(BINDIR)/$(CONFIG)/bm_call_create || ( echo test bm_call_create failed ; exit 1 )
- $(E) "[RUN] Testing bm_chttp2"
- $(Q) $(BINDIR)/$(CONFIG)/bm_chttp2 || ( echo test bm_chttp2 failed ; exit 1 )
+ $(E) "[RUN] Testing bm_chttp2_hpack"
+ $(Q) $(BINDIR)/$(CONFIG)/bm_chttp2_hpack || ( echo test bm_chttp2_hpack failed ; exit 1 )
$(E) "[RUN] Testing bm_closure"
$(Q) $(BINDIR)/$(CONFIG)/bm_closure || ( echo test bm_closure failed ; exit 1 )
$(E) "[RUN] Testing bm_cq"
@@ -12350,15 +12350,15 @@ endif
endif
-BM_CHTTP2_SRC = \
- test/cpp/microbenchmarks/bm_chttp2.cc \
+BM_CHTTP2_HPACK_SRC = \
+ test/cpp/microbenchmarks/bm_chttp2_hpack.cc \
-BM_CHTTP2_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CHTTP2_SRC))))
+BM_CHTTP2_HPACK_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_CHTTP2_HPACK_SRC))))
ifeq ($(NO_SECURE),true)
# You can't build secure targets if you don't have OpenSSL.
-$(BINDIR)/$(CONFIG)/bm_chttp2: openssl_dep_error
+$(BINDIR)/$(CONFIG)/bm_chttp2_hpack: openssl_dep_error
else
@@ -12369,26 +12369,26 @@ ifeq ($(NO_PROTOBUF),true)
# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+.
-$(BINDIR)/$(CONFIG)/bm_chttp2: protobuf_dep_error
+$(BINDIR)/$(CONFIG)/bm_chttp2_hpack: protobuf_dep_error
else
-$(BINDIR)/$(CONFIG)/bm_chttp2: $(PROTOBUF_DEP) $(BM_CHTTP2_OBJS) $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(BINDIR)/$(CONFIG)/bm_chttp2_hpack: $(PROTOBUF_DEP) $(BM_CHTTP2_HPACK_OBJS) $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
$(E) "[LD] Linking $@"
$(Q) mkdir -p `dirname $@`
- $(Q) $(LDXX) $(LDFLAGS) $(BM_CHTTP2_OBJS) $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_chttp2
+ $(Q) $(LDXX) $(LDFLAGS) $(BM_CHTTP2_HPACK_OBJS) $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_chttp2_hpack
endif
endif
-$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_chttp2.o: $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
+$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_chttp2_hpack.o: $(LIBDIR)/$(CONFIG)/libbenchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a
-deps_bm_chttp2: $(BM_CHTTP2_OBJS:.o=.dep)
+deps_bm_chttp2_hpack: $(BM_CHTTP2_HPACK_OBJS:.o=.dep)
ifneq ($(NO_SECURE),true)
ifneq ($(NO_DEPS),true)
--include $(BM_CHTTP2_OBJS:.o=.dep)
+-include $(BM_CHTTP2_HPACK_OBJS:.o=.dep)
endif
endif
diff --git a/build.yaml b/build.yaml
index 5ac2ff52f5..4dca4d8694 100644
--- a/build.yaml
+++ b/build.yaml
@@ -2980,11 +2980,11 @@ targets:
- mac
- linux
- posix
-- name: bm_chttp2
+- name: bm_chttp2_hpack
build: test
language: c++
src:
- - test/cpp/microbenchmarks/bm_chttp2.cc
+ - test/cpp/microbenchmarks/bm_chttp2_hpack.cc
deps:
- benchmark
- grpc++_test_util
diff --git a/test/cpp/microbenchmarks/bm_chttp2.cc b/test/cpp/microbenchmarks/bm_chttp2.cc
deleted file mode 100644
index 10bccdfcee..0000000000
--- a/test/cpp/microbenchmarks/bm_chttp2.cc
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-/* Microbenchmarks around CHTTP2 operations */
-
-#include
-#include
-#include
-extern "C" {
-#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
-#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
-#include "src/core/lib/slice/slice_internal.h"
-#include "src/core/lib/transport/static_metadata.h"
-}
-#include "third_party/benchmark/include/benchmark/benchmark.h"
-
-static struct Init {
- Init() { grpc_init(); }
- ~Init() { grpc_shutdown(); }
-} g_init;
-
-////////////////////////////////////////////////////////////////////////////////
-// HPACK encoder
-//
-
-static void BM_HpackEncoderInitDestroy(benchmark::State &state) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hpack_compressor c;
- while (state.KeepRunning()) {
- grpc_chttp2_hpack_compressor_init(&c);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_exec_ctx_flush(&exec_ctx);
- }
- grpc_exec_ctx_finish(&exec_ctx);
-}
-BENCHMARK(BM_HpackEncoderInitDestroy);
-
-template
-static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
-
- grpc_metadata_batch b;
- grpc_metadata_batch_init(&b);
- std::vector elems = Fixture::GetElems(&exec_ctx);
- std::vector storage(elems.size());
- for (size_t i = 0; i < elems.size(); i++) {
- GPR_ASSERT(GRPC_LOG_IF_ERROR(
- "addmd",
- grpc_metadata_batch_add_tail(&exec_ctx, &b, &storage[i], elems[i])));
- }
-
- grpc_chttp2_hpack_compressor c;
- grpc_chttp2_hpack_compressor_init(&c);
- grpc_transport_one_way_stats stats;
- memset(&stats, 0, sizeof(stats));
- grpc_slice_buffer outbuf;
- grpc_slice_buffer_init(&outbuf);
- while (state.KeepRunning()) {
- grpc_chttp2_encode_header(&exec_ctx, &c, (uint32_t)state.iterations(), &b,
- state.range(0), state.range(1), &stats, &outbuf);
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
- grpc_exec_ctx_flush(&exec_ctx);
- }
- grpc_metadata_batch_destroy(&exec_ctx, &b);
- grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
- grpc_exec_ctx_finish(&exec_ctx);
-
- std::ostringstream label;
- label << "framing_bytes/iter:" << (static_cast(stats.framing_bytes) /
- static_cast(state.iterations()))
- << " header_bytes/iter:" << (static_cast(stats.header_bytes) /
- static_cast(state.iterations()));
- state.SetLabel(label.str());
-}
-
-namespace hpack_encoder_fixtures {
-
-class EmptyBatch {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {};
- }
-};
-
-class SingleStaticElem {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE};
- }
-};
-
-class SingleInternedElem {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
- grpc_slice_intern(grpc_slice_from_static_string("def")))};
- }
-};
-
-class SingleInternedKeyElem {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {grpc_mdelem_from_slices(
- exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
- grpc_slice_from_static_string("def"))};
- }
-};
-
-class SingleNonInternedElem {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {grpc_mdelem_from_slices(exec_ctx,
- grpc_slice_from_static_string("abc"),
- grpc_slice_from_static_string("def"))};
- }
-};
-
-class RepresentativeClientInitialMetadata {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {
- GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST,
- grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_PATH,
- grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
- grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
- grpc_slice_intern(grpc_slice_from_static_string(
- "foo.test.google.fr:1234"))),
- GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
- GRPC_MDELEM_TE_TRAILERS,
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
- grpc_mdelem_from_slices(
- exec_ctx, GRPC_MDSTR_USER_AGENT,
- grpc_slice_intern(grpc_slice_from_static_string(
- "grpc-c/3.0.0-dev (linux; chttp2; green)")))};
- }
-};
-
-class RepresentativeServerInitialMetadata {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {GRPC_MDELEM_STATUS_200,
- GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
- GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP};
- }
-};
-
-class RepresentativeServerTrailingMetadata {
- public:
- static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
- return {GRPC_MDELEM_GRPC_STATUS_0};
- }
-};
-
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, EmptyBatch)->Args({0, 16384});
-// test with eof (shouldn't affect anything)
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, EmptyBatch)->Args({1, 16384});
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleStaticElem)
- ->Args({0, 16384});
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleInternedKeyElem)
- ->Args({0, 16384});
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleInternedElem)
- ->Args({0, 16384});
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleNonInternedElem)
- ->Args({0, 16384});
-// test with a tiny frame size, to highlight continuation costs
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleNonInternedElem)
- ->Args({0, 1});
-
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
- RepresentativeClientInitialMetadata)
- ->Args({0, 16384});
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
- RepresentativeServerInitialMetadata)
- ->Args({0, 16384});
-BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
- RepresentativeServerTrailingMetadata)
- ->Args({1, 16384});
-
-} // namespace hpack_encoder_fixtures
-
-////////////////////////////////////////////////////////////////////////////////
-// HPACK parser
-//
-
-static void BM_HpackParserInitDestroy(benchmark::State &state) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_chttp2_hpack_parser p;
- while (state.KeepRunning()) {
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_flush(&exec_ctx);
- }
- grpc_exec_ctx_finish(&exec_ctx);
-}
-BENCHMARK(BM_HpackParserInitDestroy);
-
-static void UnrefHeader(grpc_exec_ctx *exec_ctx, void *user_data,
- grpc_mdelem md) {
- GRPC_MDELEM_UNREF(exec_ctx, md);
-}
-
-template
-static void BM_HpackParserParseHeader(benchmark::State &state) {
- grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- std::vector init_slices = Fixture::GetInitSlices();
- std::vector benchmark_slices = Fixture::GetBenchmarkSlices();
- grpc_chttp2_hpack_parser p;
- grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
- p.on_header = UnrefHeader;
- p.on_header_user_data = nullptr;
- for (auto slice : init_slices) {
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
- }
- while (state.KeepRunning()) {
- for (auto slice : benchmark_slices) {
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
- }
- grpc_exec_ctx_flush(&exec_ctx);
- }
- grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
- grpc_exec_ctx_finish(&exec_ctx);
-}
-
-namespace hpack_parser_fixtures {
-
-static grpc_slice MakeSlice(std::initializer_list bytes) {
- grpc_slice s = grpc_slice_malloc(bytes.size());
- uint8_t *p = GRPC_SLICE_START_PTR(s);
- for (auto b : bytes) {
- *p++ = b;
- }
- return s;
-}
-
-class EmptyBatch {
- public:
- static std::vector GetInitSlices() { return {}; }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({})};
- }
-};
-
-class IndexedSingleStaticElem {
- public:
- static std::vector GetInitSlices() {
- return {MakeSlice(
- {0x40, 0x07, ':', 's', 't', 'a', 't', 'u', 's', 0x03, '2', '0', '0'})};
- }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({0xbe})};
- }
-};
-
-class AddIndexedSingleStaticElem {
- public:
- static std::vector GetInitSlices() { return {}; }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice(
- {0x40, 0x07, ':', 's', 't', 'a', 't', 'u', 's', 0x03, '2', '0', '0'})};
- }
-};
-
-class KeyIndexedSingleStaticElem {
- public:
- static std::vector GetInitSlices() {
- return {MakeSlice(
- {0x40, 0x07, ':', 's', 't', 'a', 't', 'u', 's', 0x03, '2', '0', '0'})};
- }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({0x7e, 0x03, 'd', 'e', 'f'})};
- }
-};
-
-class IndexedSingleInternedElem {
- public:
- static std::vector GetInitSlices() {
- return {MakeSlice({0x40, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
- }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({0xbe})};
- }
-};
-
-class AddIndexedSingleInternedElem {
- public:
- static std::vector GetInitSlices() { return {}; }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({0x40, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
- }
-};
-
-class KeyIndexedSingleInternedElem {
- public:
- static std::vector GetInitSlices() {
- return {MakeSlice({0x40, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
- }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({0x7e, 0x03, 'g', 'h', 'i'})};
- }
-};
-
-class NonIndexedElem {
- public:
- static std::vector GetInitSlices() { return {}; }
- static std::vector GetBenchmarkSlices() {
- return {MakeSlice({0x00, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
- }
-};
-
-class RepresentativeClientInitialMetadata {
- public:
- static std::vector GetInitSlices() {
- return {grpc_slice_from_static_string(
- // generated with:
- // ```
- // tools/codegen/core/gen_header_frame.py --compression inc --no_framing
- // < test/core/bad_client/tests/simple_request.headers
- // ```
- "@\x05:path\x08/foo/bar"
- "@\x07:scheme\x04http"
- "@\x07:method\x04POST"
- "@\x0a:authority\x09localhost"
- "@\x0c"
- "content-type\x10"
- "application/grpc"
- "@\x14grpc-accept-encoding\x15identity,deflate,gzip"
- "@\x02te\x08trailers"
- "@\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)")};
- }
- static std::vector GetBenchmarkSlices() {
- // generated with:
- // ```
- // tools/codegen/core/gen_header_frame.py --compression pre --no_framing
- // --hex < test/core/bad_client/tests/simple_request.headers
- // ```
- return {MakeSlice({0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe})};
- }
-};
-
-class RepresentativeServerInitialMetadata {
- public:
- static std::vector GetInitSlices() {
- return {grpc_slice_from_static_string(
- // generated with:
- // ```
- // tools/codegen/core/gen_header_frame.py --compression inc --no_framing
- // <
- // test/cpp/microbenchmarks/representative_server_initial_metadata.headers
- // ```
- "@\x07:status\x03"
- "200"
- "@\x0c"
- "content-type\x10"
- "application/grpc"
- "@\x14grpc-accept-encoding\x15identity,deflate,gzip")};
- }
- static std::vector GetBenchmarkSlices() {
- // generated with:
- // ```
- // tools/codegen/core/gen_header_frame.py --compression pre --no_framing
- // --hex <
- // test/cpp/microbenchmarks/representative_server_initial_metadata.headers
- // ```
- return {MakeSlice({0xc0, 0xbf, 0xbe})};
- }
-};
-
-class RepresentativeServerTrailingMetadata {
- public:
- static std::vector GetInitSlices() {
- return {grpc_slice_from_static_string(
- // generated with:
- // ```
- // tools/codegen/core/gen_header_frame.py --compression inc --no_framing
- // <
- // test/cpp/microbenchmarks/representative_server_trailing_metadata.headers
- // ```
- "@\x0bgrpc-status\x01"
- "0"
- "@\x0cgrpc-message\x00")};
- }
- static std::vector GetBenchmarkSlices() {
- // generated with:
- // ```
- // tools/codegen/core/gen_header_frame.py --compression pre --no_framing
- // --hex <
- // test/cpp/microbenchmarks/representative_server_trailing_metadata.headers
- // ```
- return {MakeSlice({0xbf, 0xbe})};
- }
-};
-
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, EmptyBatch);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleStaticElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleStaticElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleStaticElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleInternedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleInternedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleInternedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedElem);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
- RepresentativeClientInitialMetadata);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
- RepresentativeServerInitialMetadata);
-BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
- RepresentativeServerTrailingMetadata);
-
-} // namespace hpack_parser_fixtures
-
-BENCHMARK_MAIN();
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
new file mode 100644
index 0000000000..be0f4943e6
--- /dev/null
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -0,0 +1,442 @@
+/*
+ *
+ * Copyright 2015, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/* Microbenchmarks around CHTTP2 HPACK operations */
+
+#include
+#include
+#include
+extern "C" {
+#include "src/core/ext/transport/chttp2/transport/hpack_encoder.h"
+#include "src/core/ext/transport/chttp2/transport/hpack_parser.h"
+#include "src/core/lib/slice/slice_internal.h"
+#include "src/core/lib/transport/static_metadata.h"
+}
+#include "third_party/benchmark/include/benchmark/benchmark.h"
+
+static struct Init {
+ Init() { grpc_init(); }
+ ~Init() { grpc_shutdown(); }
+} g_init;
+
+////////////////////////////////////////////////////////////////////////////////
+// HPACK encoder
+//
+
+static void BM_HpackEncoderInitDestroy(benchmark::State &state) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_chttp2_hpack_compressor c;
+ while (state.KeepRunning()) {
+ grpc_chttp2_hpack_compressor_init(&c);
+ grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
+ grpc_exec_ctx_flush(&exec_ctx);
+ }
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+BENCHMARK(BM_HpackEncoderInitDestroy);
+
+template
+static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+
+ grpc_metadata_batch b;
+ grpc_metadata_batch_init(&b);
+ std::vector elems = Fixture::GetElems(&exec_ctx);
+ std::vector storage(elems.size());
+ for (size_t i = 0; i < elems.size(); i++) {
+ GPR_ASSERT(GRPC_LOG_IF_ERROR(
+ "addmd",
+ grpc_metadata_batch_add_tail(&exec_ctx, &b, &storage[i], elems[i])));
+ }
+
+ grpc_chttp2_hpack_compressor c;
+ grpc_chttp2_hpack_compressor_init(&c);
+ grpc_transport_one_way_stats stats;
+ memset(&stats, 0, sizeof(stats));
+ grpc_slice_buffer outbuf;
+ grpc_slice_buffer_init(&outbuf);
+ while (state.KeepRunning()) {
+ grpc_chttp2_encode_header(&exec_ctx, &c, (uint32_t)state.iterations(), &b,
+ state.range(0), state.range(1), &stats, &outbuf);
+ grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, &outbuf);
+ grpc_exec_ctx_flush(&exec_ctx);
+ }
+ grpc_metadata_batch_destroy(&exec_ctx, &b);
+ grpc_chttp2_hpack_compressor_destroy(&exec_ctx, &c);
+ grpc_exec_ctx_finish(&exec_ctx);
+
+ std::ostringstream label;
+ label << "framing_bytes/iter:" << (static_cast(stats.framing_bytes) /
+ static_cast(state.iterations()))
+ << " header_bytes/iter:" << (static_cast(stats.header_bytes) /
+ static_cast(state.iterations()));
+ state.SetLabel(label.str());
+}
+
+namespace hpack_encoder_fixtures {
+
+class EmptyBatch {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {};
+ }
+};
+
+class SingleStaticElem {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE};
+ }
+};
+
+class SingleInternedElem {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {grpc_mdelem_from_slices(
+ exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_intern(grpc_slice_from_static_string("def")))};
+ }
+};
+
+class SingleInternedKeyElem {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {grpc_mdelem_from_slices(
+ exec_ctx, grpc_slice_intern(grpc_slice_from_static_string("abc")),
+ grpc_slice_from_static_string("def"))};
+ }
+};
+
+class SingleNonInternedElem {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {grpc_mdelem_from_slices(exec_ctx,
+ grpc_slice_from_static_string("abc"),
+ grpc_slice_from_static_string("def"))};
+ }
+};
+
+class RepresentativeClientInitialMetadata {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {
+ GRPC_MDELEM_SCHEME_HTTP, GRPC_MDELEM_METHOD_POST,
+ grpc_mdelem_from_slices(
+ exec_ctx, GRPC_MDSTR_PATH,
+ grpc_slice_intern(grpc_slice_from_static_string("/foo/bar"))),
+ grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ "foo.test.google.fr:1234"))),
+ GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP,
+ GRPC_MDELEM_TE_TRAILERS,
+ GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
+ grpc_mdelem_from_slices(
+ exec_ctx, GRPC_MDSTR_USER_AGENT,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ "grpc-c/3.0.0-dev (linux; chttp2; green)")))};
+ }
+};
+
+class RepresentativeServerInitialMetadata {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {GRPC_MDELEM_STATUS_200,
+ GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC,
+ GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP};
+ }
+};
+
+class RepresentativeServerTrailingMetadata {
+ public:
+ static std::vector GetElems(grpc_exec_ctx *exec_ctx) {
+ return {GRPC_MDELEM_GRPC_STATUS_0};
+ }
+};
+
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, EmptyBatch)->Args({0, 16384});
+// test with eof (shouldn't affect anything)
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, EmptyBatch)->Args({1, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleStaticElem)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleInternedKeyElem)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleInternedElem)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleNonInternedElem)
+ ->Args({0, 16384});
+// test with a tiny frame size, to highlight continuation costs
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader, SingleNonInternedElem)
+ ->Args({0, 1});
+
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
+ RepresentativeClientInitialMetadata)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
+ RepresentativeServerInitialMetadata)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
+ RepresentativeServerTrailingMetadata)
+ ->Args({1, 16384});
+
+} // namespace hpack_encoder_fixtures
+
+////////////////////////////////////////////////////////////////////////////////
+// HPACK parser
+//
+
+static void BM_HpackParserInitDestroy(benchmark::State &state) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_chttp2_hpack_parser p;
+ while (state.KeepRunning()) {
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
+ grpc_exec_ctx_flush(&exec_ctx);
+ }
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+BENCHMARK(BM_HpackParserInitDestroy);
+
+static void UnrefHeader(grpc_exec_ctx *exec_ctx, void *user_data,
+ grpc_mdelem md) {
+ GRPC_MDELEM_UNREF(exec_ctx, md);
+}
+
+template
+static void BM_HpackParserParseHeader(benchmark::State &state) {
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ std::vector init_slices = Fixture::GetInitSlices();
+ std::vector benchmark_slices = Fixture::GetBenchmarkSlices();
+ grpc_chttp2_hpack_parser p;
+ grpc_chttp2_hpack_parser_init(&exec_ctx, &p);
+ p.on_header = UnrefHeader;
+ p.on_header_user_data = nullptr;
+ for (auto slice : init_slices) {
+ grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
+ }
+ while (state.KeepRunning()) {
+ for (auto slice : benchmark_slices) {
+ grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
+ }
+ grpc_exec_ctx_flush(&exec_ctx);
+ }
+ grpc_chttp2_hpack_parser_destroy(&exec_ctx, &p);
+ grpc_exec_ctx_finish(&exec_ctx);
+}
+
+namespace hpack_parser_fixtures {
+
+static grpc_slice MakeSlice(std::initializer_list bytes) {
+ grpc_slice s = grpc_slice_malloc(bytes.size());
+ uint8_t *p = GRPC_SLICE_START_PTR(s);
+ for (auto b : bytes) {
+ *p++ = b;
+ }
+ return s;
+}
+
+class EmptyBatch {
+ public:
+ static std::vector GetInitSlices() { return {}; }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({})};
+ }
+};
+
+class IndexedSingleStaticElem {
+ public:
+ static std::vector GetInitSlices() {
+ return {MakeSlice(
+ {0x40, 0x07, ':', 's', 't', 'a', 't', 'u', 's', 0x03, '2', '0', '0'})};
+ }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({0xbe})};
+ }
+};
+
+class AddIndexedSingleStaticElem {
+ public:
+ static std::vector GetInitSlices() { return {}; }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice(
+ {0x40, 0x07, ':', 's', 't', 'a', 't', 'u', 's', 0x03, '2', '0', '0'})};
+ }
+};
+
+class KeyIndexedSingleStaticElem {
+ public:
+ static std::vector GetInitSlices() {
+ return {MakeSlice(
+ {0x40, 0x07, ':', 's', 't', 'a', 't', 'u', 's', 0x03, '2', '0', '0'})};
+ }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({0x7e, 0x03, 'd', 'e', 'f'})};
+ }
+};
+
+class IndexedSingleInternedElem {
+ public:
+ static std::vector GetInitSlices() {
+ return {MakeSlice({0x40, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
+ }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({0xbe})};
+ }
+};
+
+class AddIndexedSingleInternedElem {
+ public:
+ static std::vector GetInitSlices() { return {}; }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({0x40, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
+ }
+};
+
+class KeyIndexedSingleInternedElem {
+ public:
+ static std::vector GetInitSlices() {
+ return {MakeSlice({0x40, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
+ }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({0x7e, 0x03, 'g', 'h', 'i'})};
+ }
+};
+
+class NonIndexedElem {
+ public:
+ static std::vector GetInitSlices() { return {}; }
+ static std::vector GetBenchmarkSlices() {
+ return {MakeSlice({0x00, 0x03, 'a', 'b', 'c', 0x03, 'd', 'e', 'f'})};
+ }
+};
+
+class RepresentativeClientInitialMetadata {
+ public:
+ static std::vector GetInitSlices() {
+ return {grpc_slice_from_static_string(
+ // generated with:
+ // ```
+ // tools/codegen/core/gen_header_frame.py --compression inc --no_framing
+ // < test/core/bad_client/tests/simple_request.headers
+ // ```
+ "@\x05:path\x08/foo/bar"
+ "@\x07:scheme\x04http"
+ "@\x07:method\x04POST"
+ "@\x0a:authority\x09localhost"
+ "@\x0c"
+ "content-type\x10"
+ "application/grpc"
+ "@\x14grpc-accept-encoding\x15identity,deflate,gzip"
+ "@\x02te\x08trailers"
+ "@\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)")};
+ }
+ static std::vector GetBenchmarkSlices() {
+ // generated with:
+ // ```
+ // tools/codegen/core/gen_header_frame.py --compression pre --no_framing
+ // --hex < test/core/bad_client/tests/simple_request.headers
+ // ```
+ return {MakeSlice({0xc5, 0xc4, 0xc3, 0xc2, 0xc1, 0xc0, 0xbf, 0xbe})};
+ }
+};
+
+class RepresentativeServerInitialMetadata {
+ public:
+ static std::vector GetInitSlices() {
+ return {grpc_slice_from_static_string(
+ // generated with:
+ // ```
+ // tools/codegen/core/gen_header_frame.py --compression inc --no_framing
+ // <
+ // test/cpp/microbenchmarks/representative_server_initial_metadata.headers
+ // ```
+ "@\x07:status\x03"
+ "200"
+ "@\x0c"
+ "content-type\x10"
+ "application/grpc"
+ "@\x14grpc-accept-encoding\x15identity,deflate,gzip")};
+ }
+ static std::vector GetBenchmarkSlices() {
+ // generated with:
+ // ```
+ // tools/codegen/core/gen_header_frame.py --compression pre --no_framing
+ // --hex <
+ // test/cpp/microbenchmarks/representative_server_initial_metadata.headers
+ // ```
+ return {MakeSlice({0xc0, 0xbf, 0xbe})};
+ }
+};
+
+class RepresentativeServerTrailingMetadata {
+ public:
+ static std::vector GetInitSlices() {
+ return {grpc_slice_from_static_string(
+ // generated with:
+ // ```
+ // tools/codegen/core/gen_header_frame.py --compression inc --no_framing
+ // <
+ // test/cpp/microbenchmarks/representative_server_trailing_metadata.headers
+ // ```
+ "@\x0bgrpc-status\x01"
+ "0"
+ "@\x0cgrpc-message\x00")};
+ }
+ static std::vector GetBenchmarkSlices() {
+ // generated with:
+ // ```
+ // tools/codegen/core/gen_header_frame.py --compression pre --no_framing
+ // --hex <
+ // test/cpp/microbenchmarks/representative_server_trailing_metadata.headers
+ // ```
+ return {MakeSlice({0xbf, 0xbe})};
+ }
+};
+
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, EmptyBatch);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleStaticElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleStaticElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleStaticElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, IndexedSingleInternedElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, AddIndexedSingleInternedElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, KeyIndexedSingleInternedElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedElem);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ RepresentativeClientInitialMetadata);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ RepresentativeServerInitialMetadata);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ RepresentativeServerTrailingMetadata);
+
+} // namespace hpack_parser_fixtures
+
+BENCHMARK_MAIN();
diff --git a/third_party/gflags b/third_party/gflags
index f8a0efe03a..30dbc81fb5 160000
--- a/third_party/gflags
+++ b/third_party/gflags
@@ -1 +1 @@
-Subproject commit f8a0efe03aa69b3336d8e228b37d4ccb17324b88
+Subproject commit 30dbc81fb5ffdc98ea9b14b1918bfe4e8779b26e
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 45708dece1..61c4f37b3e 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -2345,9 +2345,9 @@
"headers": [],
"is_filegroup": false,
"language": "c++",
- "name": "bm_chttp2",
+ "name": "bm_chttp2_hpack",
"src": [
- "test/cpp/microbenchmarks/bm_chttp2.cc"
+ "test/cpp/microbenchmarks/bm_chttp2_hpack.cc"
],
"third_party": false,
"type": "target"
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 815d367c62..e112b93aec 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -2484,7 +2484,7 @@
"flaky": false,
"gtest": false,
"language": "c++",
- "name": "bm_chttp2",
+ "name": "bm_chttp2_hpack",
"platforms": [
"linux",
"mac",
diff --git a/tools/run_tests/run_microbenchmark.py b/tools/run_tests/run_microbenchmark.py
index c5247761ef..8b74d31d50 100755
--- a/tools/run_tests/run_microbenchmark.py
+++ b/tools/run_tests/run_microbenchmark.py
@@ -199,7 +199,12 @@ argp.add_argument('-c', '--collect',
default=sorted(collectors.keys()),
help='Which collectors should be run against each benchmark')
argp.add_argument('-b', '--benchmarks',
- default=['bm_fullstack', 'bm_closure', 'bm_cq', 'bm_call_create', 'bm_error'],
+ default=['bm_fullstack',
+ 'bm_closure',
+ 'bm_cq',
+ 'bm_call_create',
+ 'bm_error',
+ 'bm_chttp2_hpack'],
nargs='+',
type=str,
help='Which microbenchmarks should be run')
--
cgit v1.2.3