[cq] Track cq type to determine api usage (#30833)

* [cq] Track cq type to determine api usage

* Automated change: Fix sanity tests

* fix

Co-authored-by: ctiller <ctiller@users.noreply.github.com>
pull/30835/head
Craig Tiller 3 years ago committed by GitHub
parent 592bfb9c00
commit 0079382cfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/core/lib/debug/stats_data.cc
  2. 9
      src/core/lib/debug/stats_data.h
  3. 7
      src/core/lib/debug/stats_data.yaml
  4. 5
      src/core/lib/debug/stats_data_bq_schema.sql
  5. 13
      src/core/lib/surface/completion_queue.cc
  6. 5
      src/core/lib/surface/completion_queue_factory.cc
  7. 7
      tools/run_tests/performance/massage_qps_stats.py
  8. 30
      tools/run_tests/performance/scenario_result_schema.json

@ -35,7 +35,8 @@ const char* grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = {
"tcp_read_alloc_8k", "tcp_read_alloc_64k",
"http2_settings_writes", "http2_pings_sent",
"http2_writes_begun", "http2_transport_stalls",
"http2_stream_stalls",
"http2_stream_stalls", "cq_pluck_creates",
"cq_next_creates", "cq_callback_creates",
};
const char* grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"Number of client side calls created by this process",
@ -57,6 +58,12 @@ const char* grpc_stats_counter_doc[GRPC_STATS_COUNTER_COUNT] = {
"control window",
"Number of times sending was completely stalled by the stream flow control "
"window",
"Number of completion queues created for cq_pluck (indicates sync api "
"usage)",
"Number of completion queues created for cq_next (indicates cq async api "
"usage)",
"Number of completion queues created for cq_callback (indicates callback "
"api usage)",
};
const char* grpc_stats_histogram_name[GRPC_STATS_HISTOGRAM_COUNT] = {
"call_initial_size", "tcp_write_size", "tcp_write_iov_size",

@ -39,6 +39,9 @@ typedef enum {
GRPC_STATS_COUNTER_HTTP2_WRITES_BEGUN,
GRPC_STATS_COUNTER_HTTP2_TRANSPORT_STALLS,
GRPC_STATS_COUNTER_HTTP2_STREAM_STALLS,
GRPC_STATS_COUNTER_CQ_PLUCK_CREATES,
GRPC_STATS_COUNTER_CQ_NEXT_CREATES,
GRPC_STATS_COUNTER_CQ_CALLBACK_CREATES,
GRPC_STATS_COUNTER_COUNT
} grpc_stats_counters;
extern const char* grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT];
@ -102,6 +105,12 @@ typedef enum {
GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_TRANSPORT_STALLS)
#define GRPC_STATS_INC_HTTP2_STREAM_STALLS() \
GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_HTTP2_STREAM_STALLS)
#define GRPC_STATS_INC_CQ_PLUCK_CREATES() \
GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_PLUCK_CREATES)
#define GRPC_STATS_INC_CQ_NEXT_CREATES() \
GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_NEXT_CREATES)
#define GRPC_STATS_INC_CQ_CALLBACK_CREATES() \
GRPC_STATS_INC_COUNTER(GRPC_STATS_COUNTER_CQ_CALLBACK_CREATES)
#define GRPC_STATS_INC_CALL_INITIAL_SIZE(value) \
grpc_stats_inc_call_initial_size((int)(value))
void grpc_stats_inc_call_initial_size(int x);

@ -78,3 +78,10 @@
doc: Number of times sending was completely stalled by the transport flow control window
- counter: http2_stream_stalls
doc: Number of times sending was completely stalled by the stream flow control window
# completion queues
- counter: cq_pluck_creates
doc: Number of completion queues created for cq_pluck (indicates sync api usage)
- counter: cq_next_creates
doc: Number of completion queues created for cq_next (indicates cq async api usage)
- counter: cq_callback_creates
doc: Number of completion queues created for cq_callback (indicates callback api usage)

@ -12,4 +12,7 @@ http2_settings_writes_per_iteration:FLOAT,
http2_pings_sent_per_iteration:FLOAT,
http2_writes_begun_per_iteration:FLOAT,
http2_transport_stalls_per_iteration:FLOAT,
http2_stream_stalls_per_iteration:FLOAT
http2_stream_stalls_per_iteration:FLOAT,
cq_pluck_creates_per_iteration:FLOAT,
cq_next_creates_per_iteration:FLOAT,
cq_callback_creates_per_iteration:FLOAT

@ -40,6 +40,7 @@
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/debug/stats.h"
#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/gprpp/atomic_utils.h"
@ -509,6 +510,18 @@ grpc_completion_queue* grpc_completion_queue_create_internal(
"polling_type=%d)",
2, (completion_type, polling_type));
switch (completion_type) {
case GRPC_CQ_NEXT:
GRPC_STATS_INC_CQ_NEXT_CREATES();
break;
case GRPC_CQ_PLUCK:
GRPC_STATS_INC_CQ_PLUCK_CREATES();
break;
case GRPC_CQ_CALLBACK:
GRPC_STATS_INC_CQ_CALLBACK_CREATES();
break;
}
const cq_vtable* vtable = &g_cq_vtable[completion_type];
const cq_poller_vtable* poller_vtable =
&g_poller_vtable_by_poller_type[polling_type];

@ -23,6 +23,7 @@
#include <grpc/grpc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/surface/completion_queue.h"
/*
@ -60,6 +61,7 @@ const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup(
*/
grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
grpc_completion_queue_attributes attr = {1, GRPC_CQ_NEXT,
GRPC_CQ_DEFAULT_POLLING, nullptr};
@ -67,6 +69,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_next(void* reserved) {
}
grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
grpc_completion_queue_attributes attr = {1, GRPC_CQ_PLUCK,
GRPC_CQ_DEFAULT_POLLING, nullptr};
@ -75,6 +78,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_pluck(void* reserved) {
grpc_completion_queue* grpc_completion_queue_create_for_callback(
grpc_completion_queue_functor* shutdown_callback, void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
grpc_completion_queue_attributes attr = {
2, GRPC_CQ_CALLBACK, GRPC_CQ_DEFAULT_POLLING, shutdown_callback};
@ -84,6 +88,7 @@ grpc_completion_queue* grpc_completion_queue_create_for_callback(
grpc_completion_queue* grpc_completion_queue_create(
const grpc_completion_queue_factory* factory,
const grpc_completion_queue_attributes* attr, void* reserved) {
grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(!reserved);
return factory->vtable->create(factory, attr);
}

@ -65,6 +65,13 @@ def massage_qps_stats(scenario_result):
stats[
"core_http2_stream_stalls"] = massage_qps_stats_helpers.counter(
core_stats, "http2_stream_stalls")
stats["core_cq_pluck_creates"] = massage_qps_stats_helpers.counter(
core_stats, "cq_pluck_creates")
stats["core_cq_next_creates"] = massage_qps_stats_helpers.counter(
core_stats, "cq_next_creates")
stats[
"core_cq_callback_creates"] = massage_qps_stats_helpers.counter(
core_stats, "cq_callback_creates")
h = massage_qps_stats_helpers.histogram(core_stats,
"call_initial_size")
stats["core_call_initial_size"] = ",".join(

@ -185,6 +185,21 @@
"name": "core_http2_stream_stalls",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_cq_pluck_creates",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_cq_next_creates",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_cq_callback_creates",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_call_initial_size",
@ -462,6 +477,21 @@
"name": "core_http2_stream_stalls",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_cq_pluck_creates",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_cq_next_creates",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_cq_callback_creates",
"type": "INTEGER"
},
{
"mode": "NULLABLE",
"name": "core_call_initial_size",

Loading…
Cancel
Save