aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--build.yaml14
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_encoder.cc252
-rw-r--r--src/core/lib/security/credentials/oauth2/oauth2_credentials.cc2
-rw-r--r--src/core/lib/support/cpu_linux.cc6
-rw-r--r--src/core/lib/transport/metadata.cc7
-rw-r--r--src/core/lib/transport/metadata.h3
-rw-r--r--src/cpp/client/create_channel.cc3
-rw-r--r--templates/tools/run_tests/generated/tests.json.template1
-rw-r--r--test/core/transport/chttp2/hpack_encoder_test.c99
-rw-r--r--test/core/transport/metadata_test.c4
-rw-r--r--test/cpp/microbenchmarks/bm_chttp2_hpack.cc160
-rw-r--r--test/cpp/microbenchmarks/helpers.cc7
-rw-r--r--test/cpp/microbenchmarks/helpers.h3
-rw-r--r--tools/run_tests/generated/tests.json202
-rwxr-xr-xtools/run_tests/run_tests.py30
15 files changed, 629 insertions, 164 deletions
diff --git a/build.yaml b/build.yaml
index 4cb1b68cf3..fd4b4c3c77 100644
--- a/build.yaml
+++ b/build.yaml
@@ -3555,6 +3555,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3577,6 +3578,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3599,6 +3601,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3621,6 +3624,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3642,6 +3646,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3663,6 +3668,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3684,6 +3690,7 @@ targets:
- gpr
args:
- --benchmark_min_time=4
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3705,6 +3712,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3729,6 +3737,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3756,6 +3765,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3782,6 +3792,7 @@ targets:
- grpc++_test_config
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3809,6 +3820,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
excluded_poll_engines:
- poll
@@ -3834,6 +3846,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
@@ -3856,6 +3869,7 @@ targets:
- gpr
args:
- --benchmark_min_time=0
+ benchmark: true
defaults: benchmark
platforms:
- mac
diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
index 17b8c4ab85..0ea50e394b 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
+++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.cc
@@ -178,24 +178,19 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
c->table_elems--;
}
-/* add an element to the decoder table */
-static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem) {
- GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
-
- uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
- uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
- uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
+// Reserve space in table for the new element, evict entries if needed.
+// Return the new index of the element. Return 0 to indicate not adding to
+// table.
+static uint32_t prepare_space_for_new_elem(grpc_chttp2_hpack_compressor *c,
+ size_t elem_size) {
uint32_t new_index = c->tail_remote_index + c->table_elems + 1;
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
-
GPR_ASSERT(elem_size < 65536);
if (elem_size > c->max_table_size) {
while (c->table_size > 0) {
evict_entry(c);
}
- return;
+ return 0;
}
/* Reserve space for this element in the remote table: if this overflows
@@ -209,37 +204,26 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
c->table_size = (uint16_t)(c->table_size + elem_size);
c->table_elems++;
- /* Store this element into {entries,indices}_elem */
- if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) {
- /* already there: update with new index */
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
- } else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)],
- elem)) {
- /* already there (cuckoo): update with new index */
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
- } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) {
- /* not there, but a free element: add */
- c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
- } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_3(elem_hash)])) {
- /* not there (cuckoo), but a free element: add */
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
- } else if (c->indices_elems[HASH_FRAGMENT_2(elem_hash)] <
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)]) {
- /* not there: replace oldest */
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
- c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
- } else {
- /* not there: replace oldest */
- GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
- c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ return new_index;
+}
+
+/* dummy function */
+static void add_nothing(grpc_exec_ctx *exec_ctx,
+ grpc_chttp2_hpack_compressor *c, grpc_mdelem elem,
+ size_t elem_size) {}
+
+// Add a key to the dynamic table. Both key and value will be added to table at
+// the decoder.
+static void add_key_with_index(grpc_exec_ctx *exec_ctx,
+ grpc_chttp2_hpack_compressor *c,
+ grpc_mdelem elem, uint32_t new_index) {
+ if (new_index == 0) {
+ return;
}
- /* do exactly the same for the key (so we can find by that again too) */
+ uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
+ /* Store the key into {entries,indices}_keys */
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)],
GRPC_MDKEY(elem))) {
c->indices_keys[HASH_FRAGMENT_2(key_hash)] = new_index;
@@ -272,6 +256,63 @@ static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
}
}
+/* add an element to the decoder table */
+static void add_elem_with_index(grpc_exec_ctx *exec_ctx,
+ grpc_chttp2_hpack_compressor *c,
+ grpc_mdelem elem, uint32_t new_index) {
+ if (new_index == 0) {
+ return;
+ }
+ GPR_ASSERT(GRPC_MDELEM_IS_INTERNED(elem));
+
+ uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
+ uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
+ uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
+
+ /* Store this element into {entries,indices}_elem */
+ if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem)) {
+ /* already there: update with new index */
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
+ } else if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)],
+ elem)) {
+ /* already there (cuckoo): update with new index */
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_2(elem_hash)])) {
+ /* not there, but a free element: add */
+ c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
+ } else if (GRPC_MDISNULL(c->entries_elems[HASH_FRAGMENT_3(elem_hash)])) {
+ /* not there (cuckoo), but a free element: add */
+ c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ } else if (c->indices_elems[HASH_FRAGMENT_2(elem_hash)] <
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)]) {
+ /* not there: replace oldest */
+ GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_2(elem_hash)]);
+ c->entries_elems[HASH_FRAGMENT_2(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] = new_index;
+ } else {
+ /* not there: replace oldest */
+ GRPC_MDELEM_UNREF(exec_ctx, c->entries_elems[HASH_FRAGMENT_3(elem_hash)]);
+ c->entries_elems[HASH_FRAGMENT_3(elem_hash)] = GRPC_MDELEM_REF(elem);
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] = new_index;
+ }
+
+ add_key_with_index(exec_ctx, c, elem, new_index);
+}
+
+static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
+ grpc_mdelem elem, size_t elem_size) {
+ uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
+ add_elem_with_index(exec_ctx, c, elem, new_index);
+}
+
+static void add_key(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
+ grpc_mdelem elem, size_t elem_size) {
+ uint32_t new_index = prepare_space_for_new_elem(c, elem_size);
+ add_key_with_index(exec_ctx, c, elem, new_index);
+}
+
static void emit_indexed(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
framer_state *st) {
@@ -363,7 +404,9 @@ static void emit_lithdr_noidx(grpc_exec_ctx *exec_ctx,
static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem, framer_state *st) {
+ uint32_t unused_index, grpc_mdelem elem,
+ framer_state *st) {
+ GPR_ASSERT(unused_index == 0);
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V(exec_ctx);
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
@@ -385,7 +428,9 @@ static void emit_lithdr_incidx_v(grpc_exec_ctx *exec_ctx,
static void emit_lithdr_noidx_v(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_compressor *c,
- grpc_mdelem elem, framer_state *st) {
+ uint32_t unused_index, grpc_mdelem elem,
+ framer_state *st) {
+ GPR_ASSERT(unused_index == 0);
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V(exec_ctx);
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED(exec_ctx);
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
@@ -430,9 +475,14 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
"Reserved header (colon-prefixed) happening after regular ones.");
}
- if (GRPC_TRACER_ON(grpc_http_trace) && !GRPC_MDELEM_IS_INTERNED(elem)) {
+ if (GRPC_TRACER_ON(grpc_http_trace)) {
char *k = grpc_slice_to_c_string(GRPC_MDKEY(elem));
- char *v = grpc_slice_to_c_string(GRPC_MDVALUE(elem));
+ char *v = NULL;
+ if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
+ v = grpc_dump_slice(GRPC_MDVALUE(elem), GPR_DUMP_HEX);
+ } else {
+ v = grpc_slice_to_c_string(GRPC_MDVALUE(elem));
+ }
gpr_log(
GPR_DEBUG,
"Encode: '%s: %s', elem_interned=%d [%d], k_interned=%d, v_interned=%d",
@@ -442,64 +492,70 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
gpr_free(k);
gpr_free(v);
}
- if (!GRPC_MDELEM_IS_INTERNED(elem)) {
- emit_lithdr_noidx_v(exec_ctx, c, elem, st);
+
+ bool elem_interned = GRPC_MDELEM_IS_INTERNED(elem);
+ bool key_interned = elem_interned || grpc_slice_is_interned(GRPC_MDKEY(elem));
+
+ // Key is not interned, emit literals.
+ if (!key_interned) {
+ emit_lithdr_noidx_v(exec_ctx, c, 0, elem, st);
return;
}
- uint32_t key_hash;
- uint32_t value_hash;
- uint32_t elem_hash;
- size_t decoder_space_usage;
- uint32_t indices_key;
- int should_add_elem;
+ uint32_t key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
+ uint32_t elem_hash = 0;
- key_hash = grpc_slice_hash(GRPC_MDKEY(elem));
- value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
- elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
+ if (elem_interned) {
+ uint32_t value_hash = grpc_slice_hash(GRPC_MDVALUE(elem));
+ elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
- inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems);
+ inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum,
+ c->filter_elems);
- /* is this elem currently in the decoders table? */
+ /* is this elem currently in the decoders table? */
- if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
- c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
- /* HIT: complete element (first cuckoo hash) */
- emit_indexed(exec_ctx, c,
- dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st);
- return;
- }
+ if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_2(elem_hash)], elem) &&
+ c->indices_elems[HASH_FRAGMENT_2(elem_hash)] > c->tail_remote_index) {
+ /* HIT: complete element (first cuckoo hash) */
+ emit_indexed(exec_ctx, c,
+ dynidx(c, c->indices_elems[HASH_FRAGMENT_2(elem_hash)]), st);
+ return;
+ }
- if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
- c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
- /* HIT: complete element (second cuckoo hash) */
- emit_indexed(exec_ctx, c,
- dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), st);
- return;
+ if (grpc_mdelem_eq(c->entries_elems[HASH_FRAGMENT_3(elem_hash)], elem) &&
+ c->indices_elems[HASH_FRAGMENT_3(elem_hash)] > c->tail_remote_index) {
+ /* HIT: complete element (second cuckoo hash) */
+ emit_indexed(exec_ctx, c,
+ dynidx(c, c->indices_elems[HASH_FRAGMENT_3(elem_hash)]), st);
+ return;
+ }
}
+ uint32_t indices_key;
+
/* should this elem be in the table? */
- decoder_space_usage = grpc_mdelem_get_size_in_hpack_table(elem);
- should_add_elem = decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
- c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
- c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
+ size_t decoder_space_usage =
+ grpc_mdelem_get_size_in_hpack_table(elem, st->use_true_binary_metadata);
+ bool should_add_elem = elem_interned &&
+ decoder_space_usage < MAX_DECODER_SPACE_USAGE &&
+ c->filter_elems[HASH_FRAGMENT_1(elem_hash)] >=
+ c->filter_elems_sum / ONE_ON_ADD_PROBABILITY;
+ void (*maybe_add)(grpc_exec_ctx *, grpc_chttp2_hpack_compressor *,
+ grpc_mdelem, size_t) =
+ should_add_elem ? add_elem : add_nothing;
+ void (*emit)(grpc_exec_ctx *, grpc_chttp2_hpack_compressor *, uint32_t,
+ grpc_mdelem, framer_state *) =
+ should_add_elem ? emit_lithdr_incidx : emit_lithdr_noidx;
/* no hits for the elem... maybe there's a key? */
-
indices_key = c->indices_keys[HASH_FRAGMENT_2(key_hash)];
if (grpc_slice_eq(c->entries_keys[HASH_FRAGMENT_2(key_hash)],
GRPC_MDKEY(elem)) &&
indices_key > c->tail_remote_index) {
/* HIT: key (first cuckoo hash) */
- if (should_add_elem) {
- emit_lithdr_incidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- add_elem(exec_ctx, c, elem);
- return;
- } else {
- emit_lithdr_noidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- return;
- }
- GPR_UNREACHABLE_CODE(return );
+ emit(exec_ctx, c, dynidx(c, indices_key), elem, st);
+ maybe_add(exec_ctx, c, elem, decoder_space_usage);
+ return;
}
indices_key = c->indices_keys[HASH_FRAGMENT_3(key_hash)];
@@ -507,28 +563,20 @@ static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
GRPC_MDKEY(elem)) &&
indices_key > c->tail_remote_index) {
/* HIT: key (first cuckoo hash) */
- if (should_add_elem) {
- emit_lithdr_incidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- add_elem(exec_ctx, c, elem);
- return;
- } else {
- emit_lithdr_noidx(exec_ctx, c, dynidx(c, indices_key), elem, st);
- return;
- }
- GPR_UNREACHABLE_CODE(return );
+ emit(exec_ctx, c, dynidx(c, indices_key), elem, st);
+ maybe_add(exec_ctx, c, elem, decoder_space_usage);
+ return;
}
/* no elem, key in the table... fall back to literal emission */
-
- if (should_add_elem) {
- emit_lithdr_incidx_v(exec_ctx, c, elem, st);
- add_elem(exec_ctx, c, elem);
- return;
- } else {
- emit_lithdr_noidx_v(exec_ctx, c, elem, st);
- return;
- }
- GPR_UNREACHABLE_CODE(return );
+ bool should_add_key =
+ !elem_interned && decoder_space_usage < MAX_DECODER_SPACE_USAGE;
+ emit = (should_add_elem || should_add_key) ? emit_lithdr_incidx_v
+ : emit_lithdr_noidx_v;
+ maybe_add =
+ should_add_elem ? add_elem : (should_add_key ? add_key : add_nothing);
+ emit(exec_ctx, c, 0, elem, st);
+ maybe_add(exec_ctx, c, elem, decoder_space_usage);
}
#define STRLEN_LIT(x) (sizeof(x) - 1)
diff --git a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
index f52a424e36..7867105f56 100644
--- a/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
+++ b/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc
@@ -262,7 +262,7 @@ static bool oauth2_token_fetcher_get_request_metadata(
grpc_mdelem cached_access_token_md = GRPC_MDNULL;
gpr_mu_lock(&c->mu);
if (!GRPC_MDISNULL(c->access_token_md) &&
- (c->token_expiration + grpc_exec_ctx_now(exec_ctx) > refresh_threshold)) {
+ (c->token_expiration - grpc_exec_ctx_now(exec_ctx) > refresh_threshold)) {
cached_access_token_md = GRPC_MDELEM_REF(c->access_token_md);
}
if (!GRPC_MDISNULL(cached_access_token_md)) {
diff --git a/src/core/lib/support/cpu_linux.cc b/src/core/lib/support/cpu_linux.cc
index 2280668442..53619caa5f 100644
--- a/src/core/lib/support/cpu_linux.cc
+++ b/src/core/lib/support/cpu_linux.cc
@@ -38,8 +38,9 @@ static int ncpus = 0;
static void init_num_cpus() {
/* This must be signed. sysconf returns -1 when the number cannot be
determined */
+ int cpu = sched_getcpu();
ncpus = (int)sysconf(_SC_NPROCESSORS_ONLN);
- if (ncpus < 1) {
+ if (ncpus < 1 || cpu < 0) {
gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1");
ncpus = 1;
}
@@ -56,6 +57,9 @@ unsigned gpr_cpu_current_cpu(void) {
// sched_getcpu() is undefined on musl
return 0;
#else
+ if (gpr_cpu_num_cores() == 1) {
+ return 0;
+ }
int cpu = sched_getcpu();
if (cpu < 0) {
gpr_log(GPR_ERROR, "Error determining current CPU: %s\n", strerror(errno));
diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc
index 5455b2481b..2392f26c0b 100644
--- a/src/core/lib/transport/metadata.cc
+++ b/src/core/lib/transport/metadata.cc
@@ -352,11 +352,14 @@ static size_t get_base64_encoded_size(size_t raw_length) {
return raw_length / 3 * 4 + tail_xtra[raw_length % 3];
}
-size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem) {
+size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem,
+ bool use_true_binary_metadata) {
size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
size_t value_len = GRPC_SLICE_LENGTH(GRPC_MDVALUE(elem));
if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
- return overhead_and_key + get_base64_encoded_size(value_len);
+ return overhead_and_key + (use_true_binary_metadata
+ ? value_len + 1
+ : get_base64_encoded_size(value_len));
} else {
return overhead_and_key + value_len;
}
diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h
index 9f82225dc3..3f1032ab8a 100644
--- a/src/core/lib/transport/metadata.h
+++ b/src/core/lib/transport/metadata.h
@@ -132,7 +132,8 @@ grpc_mdelem grpc_mdelem_create(
bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b);
-size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem);
+size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem,
+ bool use_true_binary_metadata);
/* Mutator and accessor for grpc_mdelem user data. The destructor function
is used as a type tag and is checked during user_data fetch. */
diff --git a/src/cpp/client/create_channel.cc b/src/cpp/client/create_channel.cc
index e2893c8f3c..de67281dd4 100644
--- a/src/cpp/client/create_channel.cc
+++ b/src/cpp/client/create_channel.cc
@@ -38,8 +38,7 @@ std::shared_ptr<Channel> CreateCustomChannel(
const grpc::string& target,
const std::shared_ptr<ChannelCredentials>& creds,
const ChannelArguments& args) {
- internal::GrpcLibrary
- init_lib; // We need to call init in case of a bad creds.
+ GrpcLibraryCodegen init_lib; // We need to call init in case of a bad creds.
return creds
? creds->CreateChannel(target, args)
: CreateChannelInternal("", grpc_lame_client_channel_create(
diff --git a/templates/tools/run_tests/generated/tests.json.template b/templates/tools/run_tests/generated/tests.json.template
index 0c9f0a14c4..c5dc26faa7 100644
--- a/templates/tools/run_tests/generated/tests.json.template
+++ b/templates/tools/run_tests/generated/tests.json.template
@@ -9,6 +9,7 @@
"platforms": tgt.platforms,
"ci_platforms": tgt.ci_platforms,
"gtest": tgt.gtest,
+ "benchmark": tgt.get("benchmark", False),
"exclude_configs": tgt.get("exclude_configs", []),
"exclude_iomgrs": tgt.get("exclude_iomgrs", []),
"args": tgt.get("args", []),
diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c
index ed51dd1859..a2af83b6cb 100644
--- a/test/core/transport/chttp2/hpack_encoder_test.c
+++ b/test/core/transport/chttp2/hpack_encoder_test.c
@@ -43,10 +43,15 @@ void **to_delete = NULL;
size_t num_to_delete = 0;
size_t cap_to_delete = 0;
+typedef struct {
+ bool eof;
+ bool use_true_binary_metadata;
+ bool only_intern_key;
+} verify_params;
+
/* verify that the output generated by encoding the stream matches the
hexstring passed in */
-static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
- bool use_true_binary_metadata, size_t expect_window_used,
+static void verify(grpc_exec_ctx *exec_ctx, const verify_params params,
const char *expected, size_t nheaders, ...) {
grpc_slice_buffer output;
grpc_slice merged;
@@ -66,9 +71,13 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
e[i - 1].next = &e[i];
e[i].prev = &e[i - 1];
}
+ grpc_slice value_slice = grpc_slice_from_static_string(value);
+ if (!params.only_intern_key) {
+ value_slice = grpc_slice_intern(value_slice);
+ }
e[i].md = grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
- grpc_slice_intern(grpc_slice_from_static_string(value)));
+ value_slice);
}
e[0].prev = NULL;
e[nheaders - 1].next = NULL;
@@ -90,8 +99,8 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
memset(&stats, 0, sizeof(stats));
grpc_encode_header_options hopt = {
.stream_id = 0xdeadbeef,
- .is_eof = eof,
- .use_true_binary_metadata = use_true_binary_metadata,
+ .is_eof = params.eof,
+ .use_true_binary_metadata = params.use_true_binary_metadata,
.max_frame_size = 16384,
.stats = &stats,
};
@@ -119,28 +128,27 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof,
static void test_basic_headers(grpc_exec_ctx *exec_ctx) {
int i;
- verify(exec_ctx, 0, false, false, 0, "000005 0104 deadbeef 40 0161 0161", 1,
- "a", "a");
- verify(exec_ctx, 0, false, false, 0, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, 0, false, false, 0, "000001 0104 deadbeef be", 1, "a", "a");
- verify(exec_ctx, 0, false, false, 0, "000006 0104 deadbeef be 40 0162 0163",
- 2, "a", "a", "b", "c");
- verify(exec_ctx, 0, false, false, 0, "000002 0104 deadbeef bf be", 2, "a",
- "a", "b", "c");
- verify(exec_ctx, 0, false, false, 0, "000004 0104 deadbeef 7f 00 0164", 1,
- "a", "d");
+ verify_params params = {
+ .eof = false, .use_true_binary_metadata = false, .only_intern_key = false,
+ };
+ verify(exec_ctx, params, "000005 0104 deadbeef 40 0161 0161", 1, "a", "a");
+ verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(exec_ctx, params, "000001 0104 deadbeef be", 1, "a", "a");
+ verify(exec_ctx, params, "000006 0104 deadbeef be 40 0162 0163", 2, "a", "a",
+ "b", "c");
+ verify(exec_ctx, params, "000002 0104 deadbeef bf be", 2, "a", "a", "b", "c");
+ verify(exec_ctx, params, "000004 0104 deadbeef 7f 00 0164", 1, "a", "d");
/* flush out what's there to make a few values look very popular */
for (i = 0; i < 350; i++) {
- verify(exec_ctx, 0, false, false, 0, "000003 0104 deadbeef c0 bf be", 3,
- "a", "a", "b", "c", "a", "d");
+ verify(exec_ctx, params, "000003 0104 deadbeef c0 bf be", 3, "a", "a", "b",
+ "c", "a", "d");
}
- verify(exec_ctx, 0, false, false, 0, "000006 0104 deadbeef c0 00 016b 0176",
- 2, "a", "a", "k", "v");
+ verify(exec_ctx, params, "000006 0104 deadbeef c0 00 016b 0176", 2, "a", "a",
+ "k", "v");
/* this could be 000004 0104 deadbeef 0f 30 0176 also */
- verify(exec_ctx, 0, false, false, 0, "000004 0104 deadbeef 0f 2f 0176", 1,
- "a", "v");
+ verify(exec_ctx, params, "000004 0104 deadbeef 0f 2f 0176", 1, "a", "v");
}
static void encode_int_to_str(int i, char *p) {
@@ -156,6 +164,10 @@ static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) {
char key[3], value[3];
char *expect;
+ verify_params params = {
+ .eof = false, .use_true_binary_metadata = false, .only_intern_key = false,
+ };
+
for (i = 0; i < 114; i++) {
encode_int_to_str(i, key);
encode_int_to_str(i + 1, value);
@@ -174,27 +186,28 @@ static void test_decode_table_overflow(grpc_exec_ctx *exec_ctx) {
}
if (i > 0) {
- verify(exec_ctx, 0, false, false, 0, expect, 2, "aa", "ba", key, value);
+ verify(exec_ctx, params, expect, 2, "aa", "ba", key, value);
} else {
- verify(exec_ctx, 0, false, false, 0, expect, 1, key, value);
+ verify(exec_ctx, params, expect, 1, key, value);
}
gpr_free(expect);
}
/* if the above passes, then we must have just knocked this pair out of the
decoder stack, and so we'll be forced to re-encode it */
- verify(exec_ctx, 0, false, false, 0, "000007 0104 deadbeef 40 026161 026261",
- 1, "aa", "ba");
+ verify(exec_ctx, params, "000007 0104 deadbeef 40 026161 026261", 1, "aa",
+ "ba");
}
static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
const char *key,
- const char *value) {
+ const char *value,
+ bool use_true_binary) {
grpc_slice_buffer output;
grpc_mdelem elem = grpc_mdelem_from_slices(
exec_ctx, grpc_slice_intern(grpc_slice_from_static_string(key)),
grpc_slice_intern(grpc_slice_from_static_string(value)));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, use_true_binary);
size_t initial_table_size = g_compressor.table_size;
grpc_linked_mdelem *e = gpr_malloc(sizeof(*e));
grpc_metadata_batch b;
@@ -209,11 +222,12 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
grpc_transport_one_way_stats stats;
memset(&stats, 0, sizeof(stats));
- grpc_encode_header_options hopt = {.stream_id = 0xdeadbeef,
- .is_eof = false,
- .use_true_binary_metadata = false,
- .max_frame_size = 16384,
- .stats = &stats};
+ grpc_encode_header_options hopt = {
+ .stream_id = 0xdeadbeef,
+ .is_eof = false,
+ .use_true_binary_metadata = use_true_binary,
+ .max_frame_size = 16384,
+ .stats = &stats};
grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt,
&output);
grpc_slice_buffer_destroy_internal(exec_ctx, &output);
@@ -224,8 +238,24 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
}
static void test_encode_header_size(grpc_exec_ctx *exec_ctx) {
- verify_table_size_change_match_elem_size(exec_ctx, "hello", "world");
- verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world");
+ verify_table_size_change_match_elem_size(exec_ctx, "hello", "world", false);
+ verify_table_size_change_match_elem_size(exec_ctx, "hello-bin", "world",
+ false);
+ verify_table_size_change_match_elem_size(exec_ctx, "true-binary-bin",
+ "I_am_true_binary_value", true);
+}
+
+static void test_interned_key_indexed(grpc_exec_ctx *exec_ctx) {
+ int i;
+ verify_params params = {
+ .eof = false, .use_true_binary_metadata = false, .only_intern_key = true,
+ };
+ verify(exec_ctx, params, "000009 0104 deadbeef 40 0161 0162 0f2f 0163", 2,
+ "a", "b", "a", "c");
+ for (i = 0; i < 10; i++) {
+ verify(exec_ctx, params, "000008 0104 deadbeef 0f2f 0162 0f2f 0163", 2, "a",
+ "b", "a", "c");
+ }
}
static void run_test(void (*test)(grpc_exec_ctx *exec_ctx), const char *name) {
@@ -245,6 +275,7 @@ int main(int argc, char **argv) {
TEST(test_basic_headers);
TEST(test_decode_table_overflow);
TEST(test_encode_header_size);
+ TEST(test_interned_key_indexed);
grpc_shutdown();
for (i = 0; i < num_to_delete; i++) {
gpr_free(to_delete[i]);
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c
index cb06fce30b..f7124d29a7 100644
--- a/test/core/transport/metadata_test.c
+++ b/test/core/transport/metadata_test.c
@@ -302,7 +302,7 @@ static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key,
grpc_mdelem elem = grpc_mdelem_from_slices(
exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_string(value), intern_value));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
size_t expected_size = 32 + strlen(key) + strlen(value);
GPR_ASSERT(expected_size == elem_size);
GRPC_MDELEM_UNREF(exec_ctx, elem);
@@ -316,7 +316,7 @@ static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key,
maybe_intern(grpc_slice_from_static_buffer(value, value_len),
intern_value));
GPR_ASSERT(grpc_is_binary_header(GRPC_MDKEY(elem)));
- size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
+ size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem, false);
grpc_slice value_slice =
grpc_slice_from_copied_buffer((const char *)value, value_len);
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
index adbfa4d796..5428cc47e7 100644
--- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
+++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc
@@ -34,6 +34,15 @@ extern "C" {
auto &force_library_initialization = Library::get();
+static grpc_slice MakeSlice(std::vector<uint8_t> 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;
+}
+
////////////////////////////////////////////////////////////////////////////////
// HPACK encoder
//
@@ -52,6 +61,48 @@ static void BM_HpackEncoderInitDestroy(benchmark::State &state) {
}
BENCHMARK(BM_HpackEncoderInitDestroy);
+static void BM_HpackEncoderEncodeDeadline(benchmark::State &state) {
+ TrackCounters track_counters;
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_millis saved_now = grpc_exec_ctx_now(&exec_ctx);
+
+ grpc_metadata_batch b;
+ grpc_metadata_batch_init(&b);
+ b.deadline = saved_now + 30 * 1000;
+
+ 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_encode_header_options hopt = {
+ static_cast<uint32_t>(state.iterations()),
+ true,
+ false,
+ (size_t)1024,
+ &stats,
+ };
+ grpc_chttp2_encode_header(&exec_ctx, &c, NULL, 0, &b, &hopt, &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_slice_buffer_destroy_internal(&exec_ctx, &outbuf);
+ grpc_exec_ctx_finish(&exec_ctx);
+
+ std::ostringstream label;
+ label << "framing_bytes/iter:" << (static_cast<double>(stats.framing_bytes) /
+ static_cast<double>(state.iterations()))
+ << " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) /
+ static_cast<double>(state.iterations()));
+ track_counters.AddLabel(label.str());
+ track_counters.Finish(state);
+}
+BENCHMARK(BM_HpackEncoderEncodeDeadline);
+
template <class Fixture>
static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
TrackCounters track_counters;
@@ -104,7 +155,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) {
static_cast<double>(state.iterations()))
<< " header_bytes/iter:" << (static_cast<double>(stats.header_bytes) /
static_cast<double>(state.iterations()));
- state.SetLabel(label.str());
+ track_counters.AddLabel(label.str());
track_counters.Finish(state);
}
@@ -220,6 +271,45 @@ class RepresentativeClientInitialMetadata {
}
};
+// This fixture reflects how initial metadata are sent by a production client,
+// with non-indexed :path and binary headers. The metadata here are the same as
+// the corresponding parser benchmark below.
+class MoreRepresentativeClientInitialMetadata {
+ public:
+ static constexpr bool kEnableTrueBinary = true;
+ static std::vector<grpc_mdelem> 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(
+ "/grpc.test.FooService/BarMethod"))),
+ grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_AUTHORITY,
+ grpc_slice_intern(grpc_slice_from_static_string(
+ "foo.test.google.fr:1234"))),
+ grpc_mdelem_from_slices(
+ exec_ctx, GRPC_MDSTR_GRPC_TRACE_BIN,
+ grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13\x14\x15\x16\x17\x18"
+ "\x19\x1a\x1b\x1c\x1d\x1e\x1f"
+ "\x20\x21\x22\x23\x24\x25\x26\x27\x28"
+ "\x29\x2a\x2b\x2c\x2d\x2e\x2f"
+ "\x30")),
+ grpc_mdelem_from_slices(
+ exec_ctx, GRPC_MDSTR_GRPC_TAGS_BIN,
+ grpc_slice_from_static_string("\x00\x01\x02\x03\x04\x05\x06\x07\x08"
+ "\x09\x0a\x0b\x0c\x0d\x0e\x0f"
+ "\x10\x11\x12\x13")),
+ 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 constexpr bool kEnableTrueBinary = true;
@@ -317,6 +407,9 @@ BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
RepresentativeClientInitialMetadata)
->Args({0, 16384});
BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
+ MoreRepresentativeClientInitialMetadata)
+ ->Args({0, 16384});
+BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
RepresentativeServerInitialMetadata)
->Args({0, 16384});
BENCHMARK_TEMPLATE(BM_HpackEncoderEncodeHeader,
@@ -359,11 +452,13 @@ static void BM_HpackParserParseHeader(benchmark::State &state) {
p.on_header = UnrefHeader;
p.on_header_user_data = nullptr;
for (auto slice : init_slices) {
- grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice);
+ GPR_ASSERT(GRPC_ERROR_NONE ==
+ 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);
+ GPR_ASSERT(GRPC_ERROR_NONE ==
+ grpc_chttp2_hpack_parser_parse(&exec_ctx, &p, slice));
}
grpc_exec_ctx_flush(&exec_ctx);
}
@@ -376,15 +471,6 @@ static void BM_HpackParserParseHeader(benchmark::State &state) {
namespace hpack_parser_fixtures {
-static grpc_slice MakeSlice(std::vector<uint8_t> 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<grpc_slice> GetInitSlices() { return {}; }
@@ -572,6 +658,54 @@ class RepresentativeClientInitialMetadata {
}
};
+// This fixture reflects how initial metadata are sent by a production client,
+// with non-indexed :path and binary headers. The metadata here are the same as
+// the corresponding encoder benchmark above.
+class MoreRepresentativeClientInitialMetadata {
+ public:
+ static std::vector<grpc_slice> GetInitSlices() {
+ return {MakeSlice(
+ {0x40, 0x07, ':', 's', 'c', 'h', 'e', 'm', 'e', 0x04, 'h', 't',
+ 't', 'p', 0x40, 0x07, ':', 'm', 'e', 't', 'h', 'o', 'd', 0x04,
+ 'P', 'O', 'S', 'T', 0x40, 0x05, ':', 'p', 'a', 't', 'h', 0x1f,
+ '/', 'g', 'r', 'p', 'c', '.', 't', 'e', 's', 't', '.', 'F',
+ 'o', 'o', 'S', 'e', 'r', 'v', 'i', 'c', 'e', '/', 'B', 'a',
+ 'r', 'M', 'e', 't', 'h', 'o', 'd', 0x40, 0x0a, ':', 'a', 'u',
+ 't', 'h', 'o', 'r', 'i', 't', 'y', 0x09, 'l', 'o', 'c', 'a',
+ 'l', 'h', 'o', 's', 't', 0x40, 0x0e, 'g', 'r', 'p', 'c', '-',
+ 't', 'r', 'a', 'c', 'e', '-', 'b', 'i', 'n', 0x31, 0x00, 0x01,
+ 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
+ 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+ 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
+ 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x40,
+ 0x0d, 'g', 'r', 'p', 'c', '-', 't', 'a', 'g', 's', '-', 'b',
+ 'i', 'n', 0x14, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x40,
+ 0x0c, 'c', 'o', 'n', 't', 'e', 'n', 't', '-', 't', 'y', 'p',
+ 'e', 0x10, 'a', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o',
+ 'n', '/', 'g', 'r', 'p', 'c', 0x40, 0x14, 'g', 'r', 'p', 'c',
+ '-', 'a', 'c', 'c', 'e', 'p', 't', '-', 'e', 'n', 'c', 'o',
+ 'd', 'i', 'n', 'g', 0x15, 'i', 'd', 'e', 'n', 't', 'i', 't',
+ 'y', ',', 'd', 'e', 'f', 'l', 'a', 't', 'e', ',', 'g', 'z',
+ 'i', 'p', 0x40, 0x02, 't', 'e', 0x08, 't', 'r', 'a', 'i', 'l',
+ 'e', 'r', 's', 0x40, 0x0a, 'u', 's', 'e', 'r', '-', 'a', 'g',
+ 'e', 'n', 't', 0x22, 'b', 'a', 'd', '-', 'c', 'l', 'i', 'e',
+ 'n', 't', ' ', 'g', 'r', 'p', 'c', '-', 'c', '/', '0', '.',
+ '1', '2', '.', '0', '.', '0', ' ', '(', 'l', 'i', 'n', 'u',
+ 'x', ')'})};
+ }
+ static std::vector<grpc_slice> GetBenchmarkSlices() {
+ return {MakeSlice(
+ {0xc7, 0xc6, 0xc5, 0xc4, 0x7f, 0x04, 0x31, 0x00, 0x01, 0x02, 0x03, 0x04,
+ 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10,
+ 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c,
+ 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
+ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x7f, 0x03, 0x14, 0x00,
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c,
+ 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0xc1, 0xc0, 0xbf, 0xbe})};
+ }
+};
+
class RepresentativeServerInitialMetadata {
public:
static std::vector<grpc_slice> GetInitSlices() {
@@ -646,6 +780,8 @@ BENCHMARK_TEMPLATE(BM_HpackParserParseHeader, NonIndexedBinaryElem<100, true>);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
RepresentativeClientInitialMetadata);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
+ MoreRepresentativeClientInitialMetadata);
+BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
RepresentativeServerInitialMetadata);
BENCHMARK_TEMPLATE(BM_HpackParserParseHeader,
RepresentativeServerTrailingMetadata);
diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc
index b0caa48cd0..6802a0aa99 100644
--- a/test/cpp/microbenchmarks/helpers.cc
+++ b/test/cpp/microbenchmarks/helpers.cc
@@ -20,6 +20,9 @@
void TrackCounters::Finish(benchmark::State &state) {
std::ostringstream out;
+ for (const auto &l : labels_) {
+ out << l << ' ';
+ }
AddToLabel(out, state);
std::string label = out.str();
if (label.length() && label[0] == ' ') {
@@ -28,6 +31,10 @@ void TrackCounters::Finish(benchmark::State &state) {
state.SetLabel(label.c_str());
}
+void TrackCounters::AddLabel(const grpc::string &label) {
+ labels_.push_back(label);
+}
+
void TrackCounters::AddToLabel(std::ostream &out, benchmark::State &state) {
grpc_stats_data stats_end;
grpc_stats_collect(&stats_end);
diff --git a/test/cpp/microbenchmarks/helpers.h b/test/cpp/microbenchmarks/helpers.h
index 07dd611709..b6cea7c317 100644
--- a/test/cpp/microbenchmarks/helpers.h
+++ b/test/cpp/microbenchmarks/helpers.h
@@ -20,6 +20,7 @@
#define TEST_CPP_MICROBENCHMARKS_COUNTERS_H
#include <sstream>
+#include <vector>
extern "C" {
#include <grpc/support/port_platform.h>
@@ -65,10 +66,12 @@ class TrackCounters {
public:
TrackCounters() { grpc_stats_collect(&stats_begin_); }
virtual void Finish(benchmark::State& state);
+ virtual void AddLabel(const grpc::string& label);
virtual void AddToLabel(std::ostream& out, benchmark::State& state);
private:
grpc_stats_data stats_begin_;
+ std::vector<grpc::string> labels_;
#ifdef GPR_LOW_LEVEL_COUNTERS
const size_t mu_locks_at_start_ = gpr_atm_no_barrier_load(&gpr_mu_locks);
const size_t atm_cas_at_start_ =
diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json
index 64d5e18eee..d62f063b80 100644
--- a/tools/run_tests/generated/tests.json
+++ b/tools/run_tests/generated/tests.json
@@ -3,6 +3,7 @@
[
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -26,6 +27,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -49,6 +51,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -72,6 +75,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -95,6 +99,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -118,6 +123,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -141,6 +147,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -166,6 +173,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -189,6 +197,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -212,6 +221,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -235,6 +245,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -258,6 +269,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -281,6 +293,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -304,6 +317,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -327,6 +341,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -350,6 +365,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -373,6 +389,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -396,6 +413,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -419,6 +437,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -442,6 +461,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -465,6 +485,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -490,6 +511,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -513,6 +535,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -538,6 +561,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -561,6 +585,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -584,6 +609,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -609,6 +635,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -632,6 +659,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -651,6 +679,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -674,6 +703,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -695,6 +725,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -718,6 +749,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -741,6 +773,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -762,6 +795,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -783,6 +817,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -806,6 +841,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -829,6 +865,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -852,6 +889,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -875,6 +913,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -898,6 +937,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -921,6 +961,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -944,6 +985,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -967,6 +1009,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -990,6 +1033,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1013,6 +1057,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1036,6 +1081,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1059,6 +1105,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1082,6 +1129,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1105,6 +1153,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1128,6 +1177,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1151,6 +1201,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1174,6 +1225,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1197,6 +1249,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1220,6 +1273,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1243,6 +1297,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1266,6 +1321,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1289,6 +1345,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1312,6 +1369,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1335,6 +1393,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1360,6 +1419,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1383,6 +1443,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1406,6 +1467,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1427,6 +1489,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1450,6 +1513,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1473,6 +1537,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1492,6 +1557,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1511,6 +1577,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1534,6 +1601,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1557,6 +1625,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1580,6 +1649,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1603,6 +1673,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1624,6 +1695,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -1641,6 +1713,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1664,6 +1737,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1687,6 +1761,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1710,6 +1785,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1733,6 +1809,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1756,6 +1833,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1779,6 +1857,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1802,6 +1881,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1823,6 +1903,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1846,6 +1927,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1869,6 +1951,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1892,6 +1975,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1915,6 +1999,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1938,6 +2023,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1961,6 +2047,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -1986,6 +2073,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2009,6 +2097,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2032,6 +2121,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux"
],
@@ -2051,6 +2141,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2074,6 +2165,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2097,6 +2189,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2120,6 +2213,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2143,6 +2237,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2168,6 +2263,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2193,6 +2289,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2216,6 +2313,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2239,6 +2337,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2262,6 +2361,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2285,6 +2385,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2308,6 +2409,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2331,6 +2433,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2354,6 +2457,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2377,6 +2481,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2400,6 +2505,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2421,6 +2527,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2444,6 +2551,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2467,6 +2575,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2490,6 +2599,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2513,6 +2623,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2538,6 +2649,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2561,6 +2673,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2584,6 +2697,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2609,6 +2723,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2632,6 +2747,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2655,6 +2771,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2680,6 +2797,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2705,6 +2823,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2728,6 +2847,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2751,6 +2871,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2774,6 +2895,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2795,6 +2917,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2818,6 +2941,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2841,6 +2965,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2864,6 +2989,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2887,6 +3013,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2910,6 +3037,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2933,6 +3061,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -2958,6 +3087,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -2981,6 +3111,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3004,6 +3135,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3027,6 +3159,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3050,6 +3183,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3073,6 +3207,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3096,6 +3231,7 @@
"args": [
"--benchmark_min_time=4"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3119,6 +3255,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3142,6 +3279,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3170,6 +3308,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3198,6 +3337,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3226,6 +3366,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3254,6 +3395,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3277,6 +3419,7 @@
"args": [
"--benchmark_min_time=0"
],
+ "benchmark": true,
"ci_platforms": [
"linux",
"mac",
@@ -3298,6 +3441,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3321,6 +3465,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3344,6 +3489,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3367,6 +3513,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3388,6 +3535,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3415,6 +3563,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3438,6 +3587,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3461,6 +3611,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3484,6 +3635,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3507,6 +3659,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3530,6 +3683,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3553,6 +3707,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3576,6 +3731,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3599,6 +3755,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3622,6 +3779,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3645,6 +3803,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3670,6 +3829,7 @@
"args": [
"--generated_file_path=gens/src/proto/grpc/testing/"
],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3693,6 +3853,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3716,6 +3877,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3739,6 +3901,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3766,6 +3929,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3793,6 +3957,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3816,6 +3981,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3839,6 +4005,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3862,6 +4029,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3883,6 +4051,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3906,6 +4075,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3929,6 +4099,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3952,6 +4123,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3975,6 +4147,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -3998,6 +4171,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4019,6 +4193,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4042,6 +4217,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4063,6 +4239,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4086,6 +4263,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4109,6 +4287,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4132,6 +4311,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4153,6 +4333,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4176,6 +4357,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4199,6 +4381,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4222,6 +4405,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4245,6 +4429,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4266,6 +4451,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4289,6 +4475,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4313,6 +4500,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4334,6 +4522,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4357,6 +4546,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4382,6 +4572,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4407,6 +4598,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4432,6 +4624,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4457,6 +4650,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4482,6 +4676,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4507,6 +4702,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4532,6 +4728,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4557,6 +4754,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4582,6 +4780,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4607,6 +4806,7 @@
},
{
"args": [],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4631,6 +4831,7 @@
"--test_bin_name=resolver_component_test_unsecure",
"--running_under_bazel=false"
],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
@@ -4655,6 +4856,7 @@
"--test_bin_name=resolver_component_test",
"--running_under_bazel=false"
],
+ "benchmark": false,
"ci_platforms": [
"linux",
"mac",
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 5df2311320..588784353a 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -149,10 +149,8 @@ class Config(object):
for k, v in environ.items():
actual_environ[k] = v
if not flaky and shortname and shortname in flaky_tests:
- print('Setting %s to flaky' % shortname)
flaky = True
if shortname in shortname_to_cpu:
- print('Update CPU cost for %s: %f -> %f' % (shortname, cpu_cost, shortname_to_cpu[shortname]))
cpu_cost = shortname_to_cpu[shortname]
return jobset.JobSpec(cmdline=self.tool_prefix + cmdline,
shortname=shortname,
@@ -332,11 +330,29 @@ class CLanguage(object):
if cpu_cost == 'capacity':
cpu_cost = multiprocessing.cpu_count()
if os.path.isfile(binary):
- if 'gtest' in target and target['gtest']:
- # here we parse the output of --gtest_list_tests to build up a
- # complete list of the tests contained in a binary
- # for each test, we then add a job to run, filtering for just that
- # test
+ list_test_command = None
+ filter_test_command = None
+
+ # these are the flag defined by gtest and benchmark framework to list
+ # and filter test runs. We use them to split each individual test
+ # into its own JobSpec, and thus into its own process.
+ if 'benchmark' in target and target['benchmark']:
+ with open(os.devnull, 'w') as fnull:
+ tests = subprocess.check_output([binary, '--benchmark_list_tests'],
+ stderr=fnull)
+ base = None
+ for line in tests.split('\n'):
+ test = line.strip()
+ cmdline = [binary, '--benchmark_filter=%s$' % test] + target['args']
+ out.append(self.config.job_spec(cmdline,
+ shortname='%s:%s %s' % (binary, test, shortname_ext),
+ cpu_cost=cpu_cost,
+ timeout_seconds=_DEFAULT_TIMEOUT_SECONDS * timeout_scaling,
+ environ=env))
+ elif 'gtest' in target and target['gtest']:
+ # here we parse the output of --gtest_list_tests to build up a complete
+ # list of the tests contained in a binary for each test, we then
+ # add a job to run, filtering for just that test.
with open(os.devnull, 'w') as fnull:
tests = subprocess.check_output([binary, '--gtest_list_tests'],
stderr=fnull)