From 6155df6e5c3f5a1df614d4470a6b823f7618457c Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 7 Sep 2017 13:26:32 -0700 Subject: [PATCH] Better TCP stats --- src/core/lib/debug/stats_data.c | 2 ++ src/core/lib/debug/stats_data.h | 7 +++++++ src/core/lib/debug/stats_data.yaml | 2 ++ src/core/lib/iomgr/tcp_posix.c | 2 ++ 4 files changed, 13 insertions(+) diff --git a/src/core/lib/debug/stats_data.c b/src/core/lib/debug/stats_data.c index 08b7740cc44..ec46878cedf 100644 --- a/src/core/lib/debug/stats_data.c +++ b/src/core/lib/debug/stats_data.c @@ -30,6 +30,8 @@ const char *grpc_stats_counter_name[GRPC_STATS_COUNTER_COUNT] = { "histogram_slow_lookups", "syscall_write", "syscall_read", + "tcp_backup_pollers_created", + "tcp_backup_poller_polls", "http2_op_batches", "http2_op_cancel", "http2_op_send_initial_metadata", diff --git a/src/core/lib/debug/stats_data.h b/src/core/lib/debug/stats_data.h index aa6d81cc7e7..1b89f580c14 100644 --- a/src/core/lib/debug/stats_data.h +++ b/src/core/lib/debug/stats_data.h @@ -32,6 +32,8 @@ typedef enum { GRPC_STATS_COUNTER_HISTOGRAM_SLOW_LOOKUPS, GRPC_STATS_COUNTER_SYSCALL_WRITE, GRPC_STATS_COUNTER_SYSCALL_READ, + GRPC_STATS_COUNTER_TCP_BACKUP_POLLERS_CREATED, + GRPC_STATS_COUNTER_TCP_BACKUP_POLLER_POLLS, GRPC_STATS_COUNTER_HTTP2_OP_BATCHES, GRPC_STATS_COUNTER_HTTP2_OP_CANCEL, GRPC_STATS_COUNTER_HTTP2_OP_SEND_INITIAL_METADATA, @@ -94,6 +96,11 @@ typedef enum { GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_WRITE) #define GRPC_STATS_INC_SYSCALL_READ(exec_ctx) \ GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_SYSCALL_READ) +#define GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx) \ + GRPC_STATS_INC_COUNTER((exec_ctx), \ + GRPC_STATS_COUNTER_TCP_BACKUP_POLLERS_CREATED) +#define GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx) \ + GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_TCP_BACKUP_POLLER_POLLS) #define GRPC_STATS_INC_HTTP2_OP_BATCHES(exec_ctx) \ GRPC_STATS_INC_COUNTER((exec_ctx), GRPC_STATS_COUNTER_HTTP2_OP_BATCHES) #define GRPC_STATS_INC_HTTP2_OP_CANCEL(exec_ctx) \ diff --git a/src/core/lib/debug/stats_data.yaml b/src/core/lib/debug/stats_data.yaml index f445a4b2bfe..4caa72f26ad 100644 --- a/src/core/lib/debug/stats_data.yaml +++ b/src/core/lib/debug/stats_data.yaml @@ -41,6 +41,8 @@ - histogram: tcp_read_iov_size max: 1024 buckets: 64 +- counter: tcp_backup_pollers_created +- counter: tcp_backup_poller_polls # chttp2 - counter: http2_op_batches - counter: http2_op_cancel diff --git a/src/core/lib/iomgr/tcp_posix.c b/src/core/lib/iomgr/tcp_posix.c index a891760706b..fba2bc017b5 100644 --- a/src/core/lib/iomgr/tcp_posix.c +++ b/src/core/lib/iomgr/tcp_posix.c @@ -138,6 +138,7 @@ static void run_poller(grpc_exec_ctx *exec_ctx, void *bp, gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec deadline = gpr_time_add(now, gpr_time_from_seconds(10, GPR_TIMESPAN)); + GRPC_STATS_INC_TCP_BACKUP_POLLER_POLLS(exec_ctx); GRPC_LOG_IF_ERROR("backup_poller:pollset_work", grpc_pollset_work(exec_ctx, BACKUP_POLLER_POLLSET(p), NULL, now, deadline)); @@ -186,6 +187,7 @@ static void cover_self(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { 2 + (int)old_count); } if (old_count == 0) { + GRPC_STATS_INC_TCP_BACKUP_POLLERS_CREATED(exec_ctx); p = (backup_poller *)gpr_malloc(sizeof(*p) + grpc_pollset_size()); if (GRPC_TRACER_ON(grpc_tcp_trace)) { gpr_log(GPR_DEBUG, "BACKUP_POLLER:%p create", p);