From 1f6759991dfa767e3610584bace99a444d7916ed Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Oct 2016 14:43:06 -0700 Subject: Initial flow control improvements: outgoing path --- .../transport/chttp2/transport/chttp2_transport.c | 44 ++++------------------ .../chttp2/transport/frame_window_update.c | 6 +-- src/core/ext/transport/chttp2/transport/internal.h | 36 +++++++++++------- .../ext/transport/chttp2/transport/stream_lists.c | 43 ++++++++++++++------- src/core/ext/transport/chttp2/transport/writing.c | 18 ++++++--- 5 files changed, 74 insertions(+), 73 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index b2fdf88a87..109e438ca6 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -480,8 +480,6 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, if (server_data) { s->id = (uint32_t)(uintptr_t)server_data; - s->outgoing_window = t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; s->incoming_window = s->max_recv_bytes = t->settings[GRPC_SENT_SETTINGS] [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; @@ -513,6 +511,7 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp, } grpc_chttp2_list_remove_stalled_by_transport(t, s); + grpc_chttp2_list_remove_stalled_by_stream(t, s); for (int i = 0; i < STREAM_LIST_COUNT; i++) { if (s->included[i]) { @@ -801,8 +800,6 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx, "no_more_stream_ids"); } - s->outgoing_window = t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; s->incoming_window = stream_incoming_window = t->settings[GRPC_SENT_SETTINGS] [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; @@ -1714,36 +1711,6 @@ static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, GRPC_ERROR_UNREF(error); } -/** update window from a settings change */ -typedef struct { - grpc_chttp2_transport *t; - grpc_exec_ctx *exec_ctx; -} update_global_window_args; - -static void update_global_window(void *args, uint32_t id, void *stream) { - update_global_window_args *a = args; - grpc_chttp2_transport *t = a->t; - grpc_chttp2_stream *s = stream; - int was_zero; - int is_zero; - int64_t initial_window_update = t->initial_window_update; - - if (initial_window_update > 0) { - was_zero = s->outgoing_window <= 0; - GRPC_CHTTP2_FLOW_CREDIT_STREAM("settings", t, s, outgoing_window, - initial_window_update); - is_zero = s->outgoing_window <= 0; - - if (was_zero && !is_zero) { - grpc_chttp2_become_writable(a->exec_ctx, t, s, true, - "update_global_window"); - } - } else { - GRPC_CHTTP2_FLOW_DEBIT_STREAM("settings", t, s, outgoing_window, - -initial_window_update); - } -} - /******************************************************************************* * INPUT PROCESSING - PARSING */ @@ -1827,9 +1794,12 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, GPR_TIMER_BEGIN("post_parse_locked", 0); if (t->initial_window_update != 0) { - update_global_window_args args = {t, exec_ctx}; - grpc_chttp2_stream_map_for_each(&t->stream_map, update_global_window, - &args); + if (t->initial_window_update > 0) { + grpc_chttp2_stream *s; + while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) { + grpc_chttp2_list_add_writable_stream(t, s); + } + } t->initial_window_update = 0; } /* handle higher level things */ diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.c b/src/core/ext/transport/chttp2/transport/frame_window_update.c index 418166a6df..1d1669beb2 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.c +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.c @@ -110,11 +110,9 @@ grpc_error *grpc_chttp2_window_update_parser_parse( if (t->incoming_stream_id != 0) { if (s != NULL) { - bool was_zero = s->outgoing_window <= 0; - GRPC_CHTTP2_FLOW_CREDIT_STREAM("parse", t, s, outgoing_window, + GRPC_CHTTP2_FLOW_CREDIT_STREAM("parse", t, s, outgoing_window_delta, received_update); - bool is_zero = s->outgoing_window <= 0; - if (was_zero && !is_zero) { + if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) { grpc_chttp2_become_writable(exec_ctx, t, s, false, "stream.read_flow_control"); } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index e0c4a1e925..acd19be876 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -59,6 +59,7 @@ typedef enum { GRPC_CHTTP2_LIST_WRITABLE, GRPC_CHTTP2_LIST_WRITING, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, + GRPC_CHTTP2_LIST_STALLED_BY_STREAM, /** streams that are waiting to start because there are too many concurrent streams on the connection */ GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, @@ -360,8 +361,10 @@ struct grpc_chttp2_stream { /** HTTP2 stream id for this stream, or zero if one has not been assigned */ uint32_t id; - /** window available for us to send to peer */ - int64_t outgoing_window; + /** window available for us to send to peer, over or under the initial window + * size of the transport... ie: + * outgoing_window = outgoing_window_delta + transport.initial_window_size */ + int64_t outgoing_window_delta; /** The number of bytes the upper layers have offered to receive. As the upper layer offers more bytes, this value increases. As bytes are read, this value decreases. */ @@ -472,34 +475,41 @@ bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); /** Get a writable stream returns non-zero if there was a stream available */ -int grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t, - grpc_chttp2_stream **s); +bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s); bool grpc_chttp2_list_remove_writable_stream( grpc_chttp2_transport *t, grpc_chttp2_stream *s) GRPC_MUST_USE_RESULT; bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); -int grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t); -int grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t, - grpc_chttp2_stream **s); +bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t); +bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s); void grpc_chttp2_list_add_written_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); -int grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport *t, - grpc_chttp2_stream **s); +bool grpc_chttp2_list_pop_written_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s); void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport *t, grpc_chttp2_stream *s); -int grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t, - grpc_chttp2_stream **s); +bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t, + grpc_chttp2_stream **s); void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport *t, grpc_chttp2_stream *s); -int grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t, - grpc_chttp2_stream **s); +bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t, + grpc_chttp2_stream **s); void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport *t, grpc_chttp2_stream *s); +void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream *s); +bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s); +bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream *s); + grpc_chttp2_stream *grpc_chttp2_parsing_lookup_stream(grpc_chttp2_transport *t, uint32_t id); grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx, diff --git a/src/core/ext/transport/chttp2/transport/stream_lists.c b/src/core/ext/transport/chttp2/transport/stream_lists.c index 6d25b3ae57..6ea60a012b 100644 --- a/src/core/ext/transport/chttp2/transport/stream_lists.c +++ b/src/core/ext/transport/chttp2/transport/stream_lists.c @@ -37,14 +37,14 @@ /* core list management */ -static int stream_list_empty(grpc_chttp2_transport *t, - grpc_chttp2_stream_list_id id) { +static bool stream_list_empty(grpc_chttp2_transport *t, + grpc_chttp2_stream_list_id id) { return t->lists[id].head == NULL; } -static int stream_list_pop(grpc_chttp2_transport *t, - grpc_chttp2_stream **stream, - grpc_chttp2_stream_list_id id) { +static bool stream_list_pop(grpc_chttp2_transport *t, + grpc_chttp2_stream **stream, + grpc_chttp2_stream_list_id id) { grpc_chttp2_stream *s = t->lists[id].head; if (s) { grpc_chttp2_stream *new_head = s->links[id].next; @@ -124,8 +124,8 @@ bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t, return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITABLE); } -int grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t, - grpc_chttp2_stream **s) { +bool grpc_chttp2_list_pop_writable_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s) { return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WRITABLE); } @@ -139,12 +139,12 @@ bool grpc_chttp2_list_add_writing_stream(grpc_chttp2_transport *t, return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITING); } -int grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t) { +bool grpc_chttp2_list_have_writing_streams(grpc_chttp2_transport *t) { return !stream_list_empty(t, GRPC_CHTTP2_LIST_WRITING); } -int grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t, - grpc_chttp2_stream **s) { +bool grpc_chttp2_list_pop_writing_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s) { return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WRITING); } @@ -153,8 +153,8 @@ void grpc_chttp2_list_add_waiting_for_concurrency(grpc_chttp2_transport *t, stream_list_add(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY); } -int grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t, - grpc_chttp2_stream **s) { +bool grpc_chttp2_list_pop_waiting_for_concurrency(grpc_chttp2_transport *t, + grpc_chttp2_stream **s) { return stream_list_pop(t, s, GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY); } @@ -163,8 +163,8 @@ void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport *t, stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT); } -int grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t, - grpc_chttp2_stream **s) { +bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport *t, + grpc_chttp2_stream **s) { return stream_list_pop(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT); } @@ -172,3 +172,18 @@ void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport *t, grpc_chttp2_stream *s) { stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT); } + +void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream *s) { + stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM); +} + +bool grpc_chttp2_list_pop_stalled_by_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream **s) { + return stream_list_pop(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM); +} + +bool grpc_chttp2_list_remove_stalled_by_stream(grpc_chttp2_transport *t, + grpc_chttp2_stream *s) { + return stream_list_maybe_remove(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM); +} diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index b39695a1a5..209e6dc602 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -138,10 +138,15 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, if (sent_initial_metadata) { /* send any body bytes, if allowed by flow control */ if (s->flow_controlled_buffer.length > 0) { - uint32_t max_outgoing = - (uint32_t)GPR_MIN(t->settings[GRPC_ACKED_SETTINGS] - [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], - GPR_MIN(s->outgoing_window, t->outgoing_window)); + uint32_t stream_outgoing_window = (uint32_t)GPR_MAX( + 0, + s->outgoing_window_delta + + (int64_t)t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); + uint32_t max_outgoing = (uint32_t)GPR_MIN( + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], + GPR_MIN(stream_outgoing_window, t->outgoing_window)); if (max_outgoing > 0) { uint32_t send_bytes = (uint32_t)GPR_MIN(max_outgoing, s->flow_controlled_buffer.length); @@ -154,7 +159,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_encode_data(s->id, &s->flow_controlled_buffer, send_bytes, is_last_frame, &s->stats.outgoing, &t->outbuf); - GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, outgoing_window, + GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, outgoing_window_delta, send_bytes); GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", t, outgoing_window, send_bytes); @@ -176,6 +181,9 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, } else if (t->outgoing_window == 0) { grpc_chttp2_list_add_stalled_by_transport(t, s); now_writing = true; + } else if (stream_outgoing_window == 0) { + grpc_chttp2_list_add_stalled_by_stream(t, s); + now_writing = true; } } if (s->send_trailing_metadata != NULL && -- cgit v1.2.3 From 0f099001658bb2b2c2be01a38437ab8bdd705ec0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Oct 2016 16:00:37 -0700 Subject: Make incoming stream window be a delta off initial_window_size --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 7 ++----- src/core/ext/transport/chttp2/transport/internal.h | 6 ++++-- src/core/ext/transport/chttp2/transport/parsing.c | 12 +++++++++--- src/core/ext/transport/chttp2/transport/writing.c | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 109e438ca6..8e7e2e0304 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -480,9 +480,6 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, if (server_data) { s->id = (uint32_t)(uintptr_t)server_data; - s->incoming_window = s->max_recv_bytes = - t->settings[GRPC_SENT_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; *t->accepting_stream = s; grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); post_destructive_reclaimer(exec_ctx, t); @@ -800,7 +797,7 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx, "no_more_stream_ids"); } - s->incoming_window = stream_incoming_window = + stream_incoming_window = t->settings[GRPC_SENT_SETTINGS] [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; s->max_recv_bytes = GPR_MAX(stream_incoming_window, s->max_recv_bytes); @@ -1917,7 +1914,7 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, s->max_recv_bytes < have_already; GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, max_recv_bytes, add_max_recv_bytes); - GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, incoming_window, + GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, incoming_window_delta, add_max_recv_bytes); GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, announce_window, add_max_recv_bytes); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index acd19be876..3dbcdbb78f 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -426,8 +426,10 @@ struct grpc_chttp2_stream { grpc_error *forced_close_error; /** how many header frames have we received? */ uint8_t header_frames_received; - /** window available for peer to send to us */ - int64_t incoming_window; + /** window available for peer to send to us (as a delta on + * transport.initial_window_size) + * incoming_window = incoming_window_delta + transport.initial_window_size */ + int64_t incoming_window_delta; /** parsing state for data frames */ grpc_chttp2_data_parser data_parser; /** number of bytes received - reset at end of parse thread execution */ diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 8005350ae7..eccff0db8a 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -379,17 +379,23 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, incoming_frame_size); if (s != NULL) { - if (incoming_frame_size > s->incoming_window) { + if (incoming_frame_size > + s->incoming_window_delta + + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]) { char *msg; gpr_asprintf(&msg, "frame of size %d overflows incoming window of %" PRId64, - t->incoming_frame_size, s->incoming_window); + t->incoming_frame_size, + s->incoming_window_delta + + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); grpc_error *err = GRPC_ERROR_CREATE(msg); gpr_free(msg); return err; } - GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window, + GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); s->received_bytes += incoming_frame_size; s->max_recv_bytes -= diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 209e6dc602..d9816e87e1 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -141,7 +141,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, uint32_t stream_outgoing_window = (uint32_t)GPR_MAX( 0, s->outgoing_window_delta + - (int64_t)t->settings[GRPC_ACKED_SETTINGS] + (int64_t)t->settings[GRPC_PEER_SETTINGS] [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); uint32_t max_outgoing = (uint32_t)GPR_MIN( t->settings[GRPC_ACKED_SETTINGS] -- cgit v1.2.3 From 6474272d13e23b1ab7156ebd20827ea1ac9c255a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Oct 2016 16:28:00 -0700 Subject: Eliminate extraneous variables now that initial window is 0 based --- .../transport/chttp2/transport/chttp2_transport.c | 73 +++++++++------------- src/core/ext/transport/chttp2/transport/internal.h | 7 --- src/core/ext/transport/chttp2/transport/parsing.c | 2 - 3 files changed, 30 insertions(+), 52 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 8e7e2e0304..cfa88af088 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -233,7 +233,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->is_client = is_client; t->outgoing_window = DEFAULT_WINDOW; t->incoming_window = DEFAULT_WINDOW; - t->stream_lookahead = DEFAULT_WINDOW; t->connection_window_target = DEFAULT_CONNECTION_WINDOW_TARGET; t->ping_counter = 1; t->pings.next = t->pings.prev = &t->pings; @@ -317,14 +316,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->next_stream_id = (uint32_t)value; } } - } else if (0 == strcmp(channel_args->args[i].key, - GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES)) { - const grpc_integer_options options = {-1, 5, INT_MAX}; - const int value = - grpc_channel_arg_get_integer(&channel_args->args[i], options); - if (value >= 0) { - t->stream_lookahead = (uint32_t)value; - } } else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_ENCODER)) { const grpc_integer_options options = {-1, 0, INT_MAX}; @@ -340,24 +331,26 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_setting_id setting_id; grpc_integer_options integer_options; bool availability[2] /* server, client */; - } settings_map[] = { - {GRPC_ARG_MAX_CONCURRENT_STREAMS, - GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, - {-1, 0, INT_MAX}, - {true, false}}, - {GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER, - GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE, - {-1, 0, INT_MAX}, - {true, true}}, - {GRPC_ARG_MAX_METADATA_SIZE, - GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, - {-1, 0, INT_MAX}, - {true, true}}, - {GRPC_ARG_HTTP2_MAX_FRAME_SIZE, - GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE, - {-1, 16384, 16777215}, - {true, true}}, - }; + } settings_map[] = {{GRPC_ARG_MAX_CONCURRENT_STREAMS, + GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, + {-1, 0, INT32_MAX}, + {true, false}}, + {GRPC_ARG_HTTP2_HPACK_TABLE_SIZE_DECODER, + GRPC_CHTTP2_SETTINGS_HEADER_TABLE_SIZE, + {-1, 0, INT32_MAX}, + {true, true}}, + {GRPC_ARG_MAX_METADATA_SIZE, + GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, + {-1, 0, INT32_MAX}, + {true, true}}, + {GRPC_ARG_HTTP2_MAX_FRAME_SIZE, + GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE, + {-1, 16384, 16777215}, + {true, true}}, + {GRPC_ARG_HTTP2_STREAM_LOOKAHEAD_BYTES, + GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, + {-1, 5, INT32_MAX}, + {true, true}}}; for (j = 0; j < (int)GPR_ARRAY_SIZE(settings_map); j++) { if (0 == strcmp(channel_args->args[i].key, settings_map[j].channel_arg_name)) { @@ -774,7 +767,6 @@ void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx, static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { grpc_chttp2_stream *s; - uint32_t stream_incoming_window; /* start streams where we have free grpc_chttp2_stream ids and free * concurrency */ while (t->next_stream_id <= MAX_CLIENT_STREAM_ID && @@ -797,10 +789,6 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx, "no_more_stream_ids"); } - stream_incoming_window = - t->settings[GRPC_SENT_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; - s->max_recv_bytes = GPR_MAX(stream_incoming_window, s->max_recv_bytes); grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); post_destructive_reclaimer(exec_ctx, t); grpc_chttp2_become_writable(exec_ctx, t, s, true, "new_stream"); @@ -1127,8 +1115,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, s->recv_message = op->recv_message; if (s->id != 0 && (s->incoming_frames.head == NULL || s->incoming_frames.head->is_tail)) { - incoming_byte_stream_update_flow_control(exec_ctx, t, s, - t->stream_lookahead, 0); + incoming_byte_stream_update_flow_control(exec_ctx, t, s, 5, 0); } grpc_chttp2_maybe_complete_recv_message(exec_ctx, t, s); } @@ -1890,10 +1877,12 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, size_t max_size_hint, size_t have_already) { uint32_t max_recv_bytes; + uint32_t initial_window_size = + t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; /* clamp max recv hint to an allowable size */ - if (max_size_hint >= UINT32_MAX - t->stream_lookahead) { - max_recv_bytes = UINT32_MAX - t->stream_lookahead; + if (max_size_hint >= UINT32_MAX - initial_window_size) { + max_recv_bytes = UINT32_MAX - initial_window_size; } else { max_recv_bytes = (uint32_t)max_size_hint; } @@ -1906,14 +1895,12 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, } /* add some small lookahead to keep pipelines flowing */ - GPR_ASSERT(max_recv_bytes <= UINT32_MAX - t->stream_lookahead); - max_recv_bytes += t->stream_lookahead; - if (s->max_recv_bytes < max_recv_bytes) { - uint32_t add_max_recv_bytes = max_recv_bytes - s->max_recv_bytes; + GPR_ASSERT(max_recv_bytes <= UINT32_MAX - initial_window_size); + if (s->incoming_window_delta < max_recv_bytes) { + uint32_t add_max_recv_bytes = + (uint32_t)(max_recv_bytes - s->incoming_window_delta); bool new_window_write_is_covered_by_poller = - s->max_recv_bytes < have_already; - GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, max_recv_bytes, - add_max_recv_bytes); + s->incoming_window_delta + initial_window_size < (int64_t)have_already; GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, incoming_window_delta, add_max_recv_bytes); GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, announce_window, diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 3dbcdbb78f..efc11357e9 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -271,9 +271,6 @@ struct grpc_chttp2_transport { copied to next_stream_id in parsing when parsing commences */ uint32_t next_stream_id; - /** how far to lookahead in a stream? */ - uint32_t stream_lookahead; - /** last new stream id */ uint32_t last_new_stream_id; @@ -365,10 +362,6 @@ struct grpc_chttp2_stream { * size of the transport... ie: * outgoing_window = outgoing_window_delta + transport.initial_window_size */ int64_t outgoing_window_delta; - /** The number of bytes the upper layers have offered to receive. - As the upper layer offers more bytes, this value increases. - As bytes are read, this value decreases. */ - uint32_t max_recv_bytes; /** things the upper layers would like to send */ grpc_metadata_batch *send_initial_metadata; grpc_closure *send_initial_metadata_finished; diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index eccff0db8a..086ed18560 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -398,8 +398,6 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); s->received_bytes += incoming_frame_size; - s->max_recv_bytes -= - (uint32_t)GPR_MIN(s->max_recv_bytes, incoming_frame_size); } return GRPC_ERROR_NONE; -- cgit v1.2.3 From 785c077e98df970a49d74cfd663467fa46894422 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 19 Oct 2016 17:24:19 -0700 Subject: Tie connection window to stream window --- .../transport/chttp2/transport/chttp2_transport.c | 41 ++++++++++++++++------ src/core/ext/transport/chttp2/transport/internal.h | 6 ++-- 2 files changed, 34 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index cfa88af088..26bcc822b1 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -233,7 +233,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->is_client = is_client; t->outgoing_window = DEFAULT_WINDOW; t->incoming_window = DEFAULT_WINDOW; - t->connection_window_target = DEFAULT_CONNECTION_WINDOW_TARGET; t->ping_counter = 1; t->pings.next = t->pings.prev = &t->pings; t->deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; @@ -511,6 +510,23 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp, } } + if (s->incoming_window_delta > 0) { + t->retract_incoming_window += s->incoming_window_delta; + } else if (s->incoming_window_delta < 0) { + int64_t give_back = -s->incoming_window_delta; + if (give_back > t->retract_incoming_window) { + give_back -= t->retract_incoming_window; + t->retract_incoming_window = 0; + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("destroy", t, announce_incoming_window, + give_back); + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("destroy", t, incoming_window, + give_back); + grpc_chttp2_initiate_write(exec_ctx, t, false, "destroy_stream"); + } else { + t->retract_incoming_window -= give_back; + } + } + GPR_ASSERT(s->send_initial_metadata_finished == NULL); GPR_ASSERT(s->fetching_send_message == NULL); GPR_ASSERT(s->send_trailing_metadata_finished == NULL); @@ -1786,16 +1802,6 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, } t->initial_window_update = 0; } - /* handle higher level things */ - if (t->incoming_window < t->connection_window_target * 3 / 4) { - int64_t announce_bytes = t->connection_window_target - t->incoming_window; - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parsed", t, announce_incoming_window, - announce_bytes); - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parsed", t, incoming_window, - announce_bytes); - grpc_chttp2_initiate_write(exec_ctx, t, false, "global incoming window"); - } - GPR_TIMER_END("post_parse_locked", 0); } @@ -1908,6 +1914,19 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, grpc_chttp2_become_writable(exec_ctx, t, s, new_window_write_is_covered_by_poller, "read_incoming_stream"); + if (t->retract_incoming_window >= add_max_recv_bytes) { + t->retract_incoming_window -= add_max_recv_bytes; + } else { + add_max_recv_bytes -= t->retract_incoming_window; + t->retract_incoming_window = 0; + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("op", t, announce_incoming_window, + add_max_recv_bytes); + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("op", t, incoming_window, + add_max_recv_bytes); + grpc_chttp2_initiate_write(exec_ctx, t, + new_window_write_is_covered_by_poller, + "read_incoming_stream"); + } } } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index efc11357e9..c16c1f61d9 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -250,8 +250,10 @@ struct grpc_chttp2_transport { /** window available to announce to peer */ int64_t announce_incoming_window; - /** how much window would we like to have for incoming_window */ - uint32_t connection_window_target; + /** how many bytes have been given out as transport window that we'd now like + to retract? (since we can't retract incoming window, instead we just dont + give out any more until this amount goes to zero) */ + int64_t retract_incoming_window; /** have we seen a goaway */ uint8_t seen_goaway; -- cgit v1.2.3 From f9540d1611d1d3488375b1919430a63b2a9ab6b6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 08:44:23 -0700 Subject: Fix potential flow control leak --- src/core/ext/transport/chttp2/transport/parsing.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 086ed18560..21e7d7927d 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -398,6 +398,12 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); s->received_bytes += incoming_frame_size; + } else { + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parse", t, announce_incoming_window, + incoming_frame_size); + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parse", t, incoming_window, + incoming_frame_size); + grpc_chttp2_initiate_write(exec_ctx, t, false, "destroy_stream"); } return GRPC_ERROR_NONE; -- cgit v1.2.3 From 82a4df01825ac10319662418a01bbe7f9f3966d1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 08:44:34 -0700 Subject: Better logging for mac --- src/core/lib/support/log_posix.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/lib/support/log_posix.c b/src/core/lib/support/log_posix.c index f972da0887..79458dd7a3 100644 --- a/src/core/lib/support/log_posix.c +++ b/src/core/lib/support/log_posix.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -93,10 +94,13 @@ void gpr_default_log(gpr_log_func_args *args) { strcpy(time_buffer, "error:strftime"); } - fprintf(stderr, "%s%s.%09d %7tu %s:%d] %s\n", - gpr_log_severity_string(args->severity), time_buffer, - (int)(now.tv_nsec), gettid(), display_file, args->line, - args->message); + char *prefix; + gpr_asprintf(&prefix, "%s%s.%09d %7tu %s:%d]", + gpr_log_severity_string(args->severity), time_buffer, + (int)(now.tv_nsec), gettid(), display_file, args->line); + + fprintf(stderr, "%-70s %s\n", prefix, args->message); + gpr_free(prefix); } #endif /* defined(GPR_POSIX_LOG) */ -- cgit v1.2.3 From 064db44e3bf7b7264f6a380796caab3f5d379135 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 09:34:58 -0700 Subject: Initial sketch of bdp estimator --- src/core/lib/transport/bdp_estimator.c | 65 ++++++++++++++++++++++++++++++++++ src/core/lib/transport/bdp_estimator.h | 62 ++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 src/core/lib/transport/bdp_estimator.c create mode 100644 src/core/lib/transport/bdp_estimator.h (limited to 'src/core') diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c new file mode 100644 index 0000000000..038054d4e4 --- /dev/null +++ b/src/core/lib/transport/bdp_estimator.c @@ -0,0 +1,65 @@ +/* + * + * Copyright 2016, 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. + * + */ + +#include "src/core/lib/transport/bdp_estimator.h" + +#include + +void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator) { + estimator->num_samples = 0; + estimator->first_sample_idx = 0; + estimator->sampling = false; +} + +static int compare_samples(const void *a, const void *b) { + return GPR_ICMP(*(int64_t *)a, *(int64_t *)b); +} + +bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, + int64_t *estimate) { + if (estimator->num_samples < GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE) { + return false; + } + + int64_t samples[GRPC_BDP_SAMPLES]; + for (uint8_t i = 0; i < estimator->num_samples; i++) { + samples[i] = + estimator + ->samples[(estimator->first_sample_idx + i) % GRPC_BDP_SAMPLES]; + } + qsort(samples, estimator->num_samples, sizeof(*samples), compare_samples); + + if (estimator->num_samples & 1) { + } else { + } +} diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h new file mode 100644 index 0000000000..9bbb3fffb5 --- /dev/null +++ b/src/core/lib/transport/bdp_estimator.h @@ -0,0 +1,62 @@ +/* + * + * Copyright 2016, 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. + * + */ + +#ifndef GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H +#define GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H + +#include +#include + +#define GRPC_BDP_SAMPLES 16 +#define GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE 3 + +typedef struct grpc_bdp_estimator { + int64_t samples[GRPC_BDP_SAMPLES]; + uint8_t num_samples; + uint8_t first_sample_idx; + bool sampling; +} grpc_bdp_estimator; + +void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator); +void grpc_bdp_estimator_destroy(grpc_bdp_estimator *estimator); + +// Returns true if a reasonable estimate could be obtained +bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, + int64_t *estimate); +// Returns true if the user should start a ping +bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, + int64_t num_bytes); +// Completes a previously started ping +void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator); + +#endif -- cgit v1.2.3 From 56331f7f6598a773b7f46bc2b9b85cfb66685c41 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 13:43:07 -0700 Subject: Complete code (no tests yet) --- src/core/lib/transport/bdp_estimator.c | 40 ++++++++++++++++++++++++++++++++++ src/core/lib/transport/bdp_estimator.h | 4 +++- 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index 038054d4e4..f397440cab 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -33,6 +33,9 @@ #include "src/core/lib/transport/bdp_estimator.h" +#include + +#include #include void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator) { @@ -60,6 +63,43 @@ bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, qsort(samples, estimator->num_samples, sizeof(*samples), compare_samples); if (estimator->num_samples & 1) { + *estimate = samples[estimator->num_samples / 2]; + } else { + *estimate = (samples[estimator->num_samples / 2] + + samples[estimator->num_samples / 2 + 1]) / + 2; + } + return true; +} + +static int64_t *sampling(grpc_bdp_estimator *estimator) { + return &estimator + ->samples[(estimator->first_sample_idx + estimator->num_samples) % + GRPC_BDP_SAMPLES]; +} + +bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, + int64_t num_bytes) { + if (estimator->sampling) { + *sampling(estimator) += num_bytes; + return false; } else { + return true; + } +} + +void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { + GPR_ASSERT(!estimator->sampling); + estimator->sampling = true; + if (estimator->num_samples == GRPC_BDP_SAMPLES) { + estimator->first_sample_idx++; + estimator->num_samples--; } + *sampling(estimator) = 0; +} + +void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { + GPR_ASSERT(estimator->sampling); + estimator->num_samples++; + estimator->sampling = false; } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 9bbb3fffb5..3149486c87 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -41,10 +41,10 @@ #define GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE 3 typedef struct grpc_bdp_estimator { - int64_t samples[GRPC_BDP_SAMPLES]; uint8_t num_samples; uint8_t first_sample_idx; bool sampling; + int64_t samples[GRPC_BDP_SAMPLES]; } grpc_bdp_estimator; void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator); @@ -56,6 +56,8 @@ bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, // Returns true if the user should start a ping bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes); +// Note that a ping is starting +void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator); // Completes a previously started ping void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator); -- cgit v1.2.3 From 9e0066b0c9a7e71e9b2ba14cf0049ca0dbfccc96 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 14:04:18 -0700 Subject: Add estimator test --- BUILD | 8 + CMakeLists.txt | 3 + Makefile | 40 +++ binding.gyp | 1 + build.yaml | 12 + config.m4 | 1 + gRPC-Core.podspec | 3 + grpc.gemspec | 2 + package.xml | 2 + src/core/lib/transport/bdp_estimator.h | 1 - src/python/grpcio/grpc_core_dependencies.py | 1 + tools/doxygen/Doxyfile.core.internal | 2 + tools/run_tests/sources_and_headers.json | 20 ++ tools/run_tests/tests.json | 333 +++++++++++---------- vsprojects/buildtests_c.sln | 27 ++ vsprojects/vcxproj/grpc/grpc.vcxproj | 3 + vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 6 + .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 3 + .../grpc_test_util/grpc_test_util.vcxproj.filters | 6 + .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 3 + .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 6 + 21 files changed, 326 insertions(+), 157 deletions(-) (limited to 'src/core') diff --git a/BUILD b/BUILD index 5c4333463c..76ce21c064 100644 --- a/BUILD +++ b/BUILD @@ -237,6 +237,7 @@ cc_library( "src/core/lib/surface/init.h", "src/core/lib/surface/lame_client.h", "src/core/lib/surface/server.h", + "src/core/lib/transport/bdp_estimator.h", "src/core/lib/transport/byte_stream.h", "src/core/lib/transport/connectivity_state.h", "src/core/lib/transport/mdstr_hash_table.h", @@ -409,6 +410,7 @@ cc_library( "src/core/lib/surface/server.c", "src/core/lib/surface/validate_metadata.c", "src/core/lib/surface/version.c", + "src/core/lib/transport/bdp_estimator.c", "src/core/lib/transport/byte_stream.c", "src/core/lib/transport/connectivity_state.c", "src/core/lib/transport/mdstr_hash_table.c", @@ -642,6 +644,7 @@ cc_library( "src/core/lib/surface/init.h", "src/core/lib/surface/lame_client.h", "src/core/lib/surface/server.h", + "src/core/lib/transport/bdp_estimator.h", "src/core/lib/transport/byte_stream.h", "src/core/lib/transport/connectivity_state.h", "src/core/lib/transport/mdstr_hash_table.h", @@ -799,6 +802,7 @@ cc_library( "src/core/lib/surface/server.c", "src/core/lib/surface/validate_metadata.c", "src/core/lib/surface/version.c", + "src/core/lib/transport/bdp_estimator.c", "src/core/lib/transport/byte_stream.c", "src/core/lib/transport/connectivity_state.c", "src/core/lib/transport/mdstr_hash_table.c", @@ -1002,6 +1006,7 @@ cc_library( "src/core/lib/surface/init.h", "src/core/lib/surface/lame_client.h", "src/core/lib/surface/server.h", + "src/core/lib/transport/bdp_estimator.h", "src/core/lib/transport/byte_stream.h", "src/core/lib/transport/connectivity_state.h", "src/core/lib/transport/mdstr_hash_table.h", @@ -1151,6 +1156,7 @@ cc_library( "src/core/lib/surface/server.c", "src/core/lib/surface/validate_metadata.c", "src/core/lib/surface/version.c", + "src/core/lib/transport/bdp_estimator.c", "src/core/lib/transport/byte_stream.c", "src/core/lib/transport/connectivity_state.c", "src/core/lib/transport/mdstr_hash_table.c", @@ -1916,6 +1922,7 @@ objc_library( "src/core/lib/surface/server.c", "src/core/lib/surface/validate_metadata.c", "src/core/lib/surface/version.c", + "src/core/lib/transport/bdp_estimator.c", "src/core/lib/transport/byte_stream.c", "src/core/lib/transport/connectivity_state.c", "src/core/lib/transport/mdstr_hash_table.c", @@ -2128,6 +2135,7 @@ objc_library( "src/core/lib/surface/init.h", "src/core/lib/surface/lame_client.h", "src/core/lib/surface/server.h", + "src/core/lib/transport/bdp_estimator.h", "src/core/lib/transport/byte_stream.h", "src/core/lib/transport/connectivity_state.h", "src/core/lib/transport/mdstr_hash_table.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 893aac36fb..78a4852bed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,6 +374,7 @@ add_library(grpc src/core/lib/surface/server.c src/core/lib/surface/validate_metadata.c src/core/lib/surface/version.c + src/core/lib/transport/bdp_estimator.c src/core/lib/transport/byte_stream.c src/core/lib/transport/connectivity_state.c src/core/lib/transport/mdstr_hash_table.c @@ -635,6 +636,7 @@ add_library(grpc_cronet src/core/lib/surface/server.c src/core/lib/surface/validate_metadata.c src/core/lib/surface/version.c + src/core/lib/transport/bdp_estimator.c src/core/lib/transport/byte_stream.c src/core/lib/transport/connectivity_state.c src/core/lib/transport/mdstr_hash_table.c @@ -868,6 +870,7 @@ add_library(grpc_unsecure src/core/lib/surface/server.c src/core/lib/surface/validate_metadata.c src/core/lib/surface/version.c + src/core/lib/transport/bdp_estimator.c src/core/lib/transport/byte_stream.c src/core/lib/transport/connectivity_state.c src/core/lib/transport/mdstr_hash_table.c diff --git a/Makefile b/Makefile index 38be9e658c..5c96a07477 100644 --- a/Makefile +++ b/Makefile @@ -905,6 +905,7 @@ alloc_test: $(BINDIR)/$(CONFIG)/alloc_test alpn_test: $(BINDIR)/$(CONFIG)/alpn_test api_fuzzer: $(BINDIR)/$(CONFIG)/api_fuzzer bad_server_response_test: $(BINDIR)/$(CONFIG)/bad_server_response_test +bdp_estimator_test: $(BINDIR)/$(CONFIG)/bdp_estimator_test bin_decoder_test: $(BINDIR)/$(CONFIG)/bin_decoder_test bin_encoder_test: $(BINDIR)/$(CONFIG)/bin_encoder_test census_context_test: $(BINDIR)/$(CONFIG)/census_context_test @@ -1242,6 +1243,7 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/alloc_test \ $(BINDIR)/$(CONFIG)/alpn_test \ $(BINDIR)/$(CONFIG)/bad_server_response_test \ + $(BINDIR)/$(CONFIG)/bdp_estimator_test \ $(BINDIR)/$(CONFIG)/bin_decoder_test \ $(BINDIR)/$(CONFIG)/bin_encoder_test \ $(BINDIR)/$(CONFIG)/census_context_test \ @@ -1561,6 +1563,8 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/alpn_test || ( echo test alpn_test failed ; exit 1 ) $(E) "[RUN] Testing bad_server_response_test" $(Q) $(BINDIR)/$(CONFIG)/bad_server_response_test || ( echo test bad_server_response_test failed ; exit 1 ) + $(E) "[RUN] Testing bdp_estimator_test" + $(Q) $(BINDIR)/$(CONFIG)/bdp_estimator_test || ( echo test bdp_estimator_test failed ; exit 1 ) $(E) "[RUN] Testing bin_decoder_test" $(Q) $(BINDIR)/$(CONFIG)/bin_decoder_test || ( echo test bin_decoder_test failed ; exit 1 ) $(E) "[RUN] Testing bin_encoder_test" @@ -2631,6 +2635,7 @@ LIBGRPC_SRC = \ src/core/lib/surface/server.c \ src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/version.c \ + src/core/lib/transport/bdp_estimator.c \ src/core/lib/transport/byte_stream.c \ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ @@ -2910,6 +2915,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/surface/server.c \ src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/version.c \ + src/core/lib/transport/bdp_estimator.c \ src/core/lib/transport/byte_stream.c \ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ @@ -3179,6 +3185,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/surface/server.c \ src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/version.c \ + src/core/lib/transport/bdp_estimator.c \ src/core/lib/transport/byte_stream.c \ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ @@ -3374,6 +3381,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/surface/server.c \ src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/version.c \ + src/core/lib/transport/bdp_estimator.c \ src/core/lib/transport/byte_stream.c \ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ @@ -6986,6 +6994,38 @@ endif endif +BDP_ESTIMATOR_TEST_SRC = \ + test/core/transport/bdp_estimator_test.c \ + +BDP_ESTIMATOR_TEST_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BDP_ESTIMATOR_TEST_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bdp_estimator_test: openssl_dep_error + +else + + + +$(BINDIR)/$(CONFIG)/bdp_estimator_test: $(BDP_ESTIMATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LD) $(LDFLAGS) $(BDP_ESTIMATOR_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/bdp_estimator_test + +endif + +$(OBJDIR)/$(CONFIG)/test/core/transport/bdp_estimator_test.o: $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_bdp_estimator_test: $(BDP_ESTIMATOR_TEST_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BDP_ESTIMATOR_TEST_OBJS:.o=.dep) +endif +endif + + BIN_DECODER_TEST_SRC = \ test/core/transport/chttp2/bin_decoder_test.c \ diff --git a/binding.gyp b/binding.gyp index 397bb1b639..d94f2fe2b4 100644 --- a/binding.gyp +++ b/binding.gyp @@ -649,6 +649,7 @@ 'src/core/lib/surface/server.c', 'src/core/lib/surface/validate_metadata.c', 'src/core/lib/surface/version.c', + 'src/core/lib/transport/bdp_estimator.c', 'src/core/lib/transport/byte_stream.c', 'src/core/lib/transport/connectivity_state.c', 'src/core/lib/transport/mdstr_hash_table.c', diff --git a/build.yaml b/build.yaml index 2a06653103..4237876d72 100644 --- a/build.yaml +++ b/build.yaml @@ -241,6 +241,7 @@ filegroups: - src/core/lib/surface/init.h - src/core/lib/surface/lame_client.h - src/core/lib/surface/server.h + - src/core/lib/transport/bdp_estimator.h - src/core/lib/transport/byte_stream.h - src/core/lib/transport/connectivity_state.h - src/core/lib/transport/mdstr_hash_table.h @@ -335,6 +336,7 @@ filegroups: - src/core/lib/surface/server.c - src/core/lib/surface/validate_metadata.c - src/core/lib/surface/version.c + - src/core/lib/transport/bdp_estimator.c - src/core/lib/transport/byte_stream.c - src/core/lib/transport/connectivity_state.c - src/core/lib/transport/mdstr_hash_table.c @@ -1337,6 +1339,16 @@ targets: - grpc - gpr_test_util - gpr +- name: bdp_estimator_test + build: test + language: c + src: + - test/core/transport/bdp_estimator_test.c + deps: + - grpc_test_util + - grpc + - gpr_test_util + - gpr - name: bin_decoder_test build: test language: c diff --git a/config.m4 b/config.m4 index d8716753b6..a2d480aead 100644 --- a/config.m4 +++ b/config.m4 @@ -168,6 +168,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/surface/server.c \ src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/version.c \ + src/core/lib/transport/bdp_estimator.c \ src/core/lib/transport/byte_stream.c \ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index bb1bbc5f0e..cf13b495cd 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -324,6 +324,7 @@ Pod::Spec.new do |s| 'src/core/lib/surface/init.h', 'src/core/lib/surface/lame_client.h', 'src/core/lib/surface/server.h', + 'src/core/lib/transport/bdp_estimator.h', 'src/core/lib/transport/byte_stream.h', 'src/core/lib/transport/connectivity_state.h', 'src/core/lib/transport/mdstr_hash_table.h', @@ -500,6 +501,7 @@ Pod::Spec.new do |s| 'src/core/lib/surface/server.c', 'src/core/lib/surface/validate_metadata.c', 'src/core/lib/surface/version.c', + 'src/core/lib/transport/bdp_estimator.c', 'src/core/lib/transport/byte_stream.c', 'src/core/lib/transport/connectivity_state.c', 'src/core/lib/transport/mdstr_hash_table.c', @@ -701,6 +703,7 @@ Pod::Spec.new do |s| 'src/core/lib/surface/init.h', 'src/core/lib/surface/lame_client.h', 'src/core/lib/surface/server.h', + 'src/core/lib/transport/bdp_estimator.h', 'src/core/lib/transport/byte_stream.h', 'src/core/lib/transport/connectivity_state.h', 'src/core/lib/transport/mdstr_hash_table.h', diff --git a/grpc.gemspec b/grpc.gemspec index 85172922cc..1698024065 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -244,6 +244,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/surface/init.h ) s.files += %w( src/core/lib/surface/lame_client.h ) s.files += %w( src/core/lib/surface/server.h ) + s.files += %w( src/core/lib/transport/bdp_estimator.h ) s.files += %w( src/core/lib/transport/byte_stream.h ) s.files += %w( src/core/lib/transport/connectivity_state.h ) s.files += %w( src/core/lib/transport/mdstr_hash_table.h ) @@ -420,6 +421,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/surface/server.c ) s.files += %w( src/core/lib/surface/validate_metadata.c ) s.files += %w( src/core/lib/surface/version.c ) + s.files += %w( src/core/lib/transport/bdp_estimator.c ) s.files += %w( src/core/lib/transport/byte_stream.c ) s.files += %w( src/core/lib/transport/connectivity_state.c ) s.files += %w( src/core/lib/transport/mdstr_hash_table.c ) diff --git a/package.xml b/package.xml index 31a2822a75..430be87f2d 100644 --- a/package.xml +++ b/package.xml @@ -251,6 +251,7 @@ + @@ -427,6 +428,7 @@ + diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 3149486c87..40128f1199 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -48,7 +48,6 @@ typedef struct grpc_bdp_estimator { } grpc_bdp_estimator; void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator); -void grpc_bdp_estimator_destroy(grpc_bdp_estimator *estimator); // Returns true if a reasonable estimate could be obtained bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index a40edfb090..e951222b09 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -162,6 +162,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/surface/server.c', 'src/core/lib/surface/validate_metadata.c', 'src/core/lib/surface/version.c', + 'src/core/lib/transport/bdp_estimator.c', 'src/core/lib/transport/byte_stream.c', 'src/core/lib/transport/connectivity_state.c', 'src/core/lib/transport/mdstr_hash_table.c', diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e5c91cbb13..7c9c07f8e9 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -861,6 +861,7 @@ src/core/lib/surface/event_string.h \ src/core/lib/surface/init.h \ src/core/lib/surface/lame_client.h \ src/core/lib/surface/server.h \ +src/core/lib/transport/bdp_estimator.h \ src/core/lib/transport/byte_stream.h \ src/core/lib/transport/connectivity_state.h \ src/core/lib/transport/mdstr_hash_table.h \ @@ -1037,6 +1038,7 @@ src/core/lib/surface/metadata_array.c \ src/core/lib/surface/server.c \ src/core/lib/surface/validate_metadata.c \ src/core/lib/surface/version.c \ +src/core/lib/transport/bdp_estimator.c \ src/core/lib/transport/byte_stream.c \ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 7cfb1d4c17..dbf4a9b7c5 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -102,6 +102,23 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "gpr", + "gpr_test_util", + "grpc", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c", + "name": "bdp_estimator_test", + "src": [ + "test/core/transport/bdp_estimator_test.c" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "grpc", @@ -6514,6 +6531,7 @@ "src/core/lib/surface/init.h", "src/core/lib/surface/lame_client.h", "src/core/lib/surface/server.h", + "src/core/lib/transport/bdp_estimator.h", "src/core/lib/transport/byte_stream.h", "src/core/lib/transport/connectivity_state.h", "src/core/lib/transport/mdstr_hash_table.h", @@ -6694,6 +6712,8 @@ "src/core/lib/surface/server.h", "src/core/lib/surface/validate_metadata.c", "src/core/lib/surface/version.c", + "src/core/lib/transport/bdp_estimator.c", + "src/core/lib/transport/bdp_estimator.h", "src/core/lib/transport/byte_stream.c", "src/core/lib/transport/byte_stream.h", "src/core/lib/transport/connectivity_state.c", diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 9ca4908eca..80de1a0bae 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -106,6 +106,27 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "flaky": false, + "gtest": false, + "language": "c", + "name": "bdp_estimator_test", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ @@ -17002,7 +17023,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17023,7 +17046,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17044,7 +17069,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17065,7 +17092,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17086,7 +17115,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17107,7 +17138,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17128,7 +17161,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17149,7 +17184,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17170,7 +17207,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17191,7 +17230,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17212,7 +17253,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17233,7 +17276,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17254,7 +17299,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17275,7 +17322,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17296,7 +17345,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17317,7 +17368,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17338,7 +17391,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17359,7 +17414,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17380,7 +17437,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17401,7 +17460,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17422,7 +17483,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17443,7 +17506,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17464,7 +17529,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17485,7 +17552,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17506,7 +17575,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17527,7 +17598,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17548,7 +17621,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17569,7 +17644,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17590,7 +17667,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17611,7 +17690,9 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17632,7 +17713,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17653,7 +17736,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17674,7 +17759,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17695,7 +17782,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17716,7 +17805,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17737,7 +17828,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17758,7 +17851,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17779,7 +17874,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17800,7 +17897,9 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [], + "exclude_configs": [ + "msan" + ], "flaky": false, "language": "c", "name": "h2_sockpair_1byte_test", @@ -17822,9 +17921,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17846,9 +17943,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17870,9 +17965,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17894,9 +17987,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17918,9 +18009,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17942,9 +18031,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17966,9 +18053,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -17990,9 +18075,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18014,9 +18097,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18038,9 +18119,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18128,9 +18207,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18152,9 +18229,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18176,9 +18251,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18200,9 +18273,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18224,9 +18295,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18248,9 +18317,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18272,9 +18339,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18318,9 +18383,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18342,9 +18405,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18366,9 +18427,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18390,9 +18449,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18414,9 +18471,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18438,9 +18493,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18462,9 +18515,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18486,9 +18537,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18510,9 +18559,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18534,9 +18581,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18558,9 +18603,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18582,9 +18625,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18606,9 +18647,7 @@ "posix" ], "cpu_cost": 0.1, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18630,9 +18669,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18654,9 +18691,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18678,9 +18713,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18702,9 +18735,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18726,9 +18757,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18772,9 +18801,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18796,9 +18823,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18820,9 +18845,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", @@ -18844,9 +18867,7 @@ "posix" ], "cpu_cost": 1.0, - "exclude_configs": [ - "msan" - ], + "exclude_configs": [], "flaky": false, "language": "c", "name": "h2_ssl_test", diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index 339b42f9d7..4a22345b12 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -80,6 +80,17 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "badreq_bad_client_test", "v {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bdp_estimator_test", "vcxproj\test\bdp_estimator_test\bdp_estimator_test.vcxproj", "{56314C05-7748-B7FD-F9DE-F975A0275427}" + ProjectSection(myProperties) = preProject + lib = "False" + EndProjectSection + ProjectSection(ProjectDependencies) = postProject + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} = {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + {29D16885-7228-4C31-81ED-5F9187C7F2A9} = {29D16885-7228-4C31-81ED-5F9187C7F2A9} + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} = {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + EndProjectSection +EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bin_decoder_test", "vcxproj\test\bin_decoder_test\bin_decoder_test.vcxproj", "{6BFAC6BA-3B9D-E8F5-BE35-91E8EFB9E25B}" ProjectSection(myProperties) = preProject lib = "False" @@ -1666,6 +1677,22 @@ Global {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|Win32.Build.0 = Release|Win32 {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|x64.ActiveCfg = Release|x64 {8A811C28-E04E-A444-E4C1-7588DF5B90AE}.Release-DLL|x64.Build.0 = Release|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug|Win32.ActiveCfg = Debug|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug|x64.ActiveCfg = Debug|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release|Win32.ActiveCfg = Release|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release|x64.ActiveCfg = Release|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug|Win32.Build.0 = Debug|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug|x64.Build.0 = Debug|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release|Win32.Build.0 = Release|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release|x64.Build.0 = Release|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug-DLL|Win32.ActiveCfg = Debug|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug-DLL|Win32.Build.0 = Debug|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug-DLL|x64.ActiveCfg = Debug|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Debug-DLL|x64.Build.0 = Debug|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release-DLL|Win32.ActiveCfg = Release|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release-DLL|Win32.Build.0 = Release|Win32 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release-DLL|x64.ActiveCfg = Release|x64 + {56314C05-7748-B7FD-F9DE-F975A0275427}.Release-DLL|x64.Build.0 = Release|x64 {6BFAC6BA-3B9D-E8F5-BE35-91E8EFB9E25B}.Debug|Win32.ActiveCfg = Debug|Win32 {6BFAC6BA-3B9D-E8F5-BE35-91E8EFB9E25B}.Debug|x64.ActiveCfg = Debug|x64 {6BFAC6BA-3B9D-E8F5-BE35-91E8EFB9E25B}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index b8c0049db5..fa271e150b 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -370,6 +370,7 @@ + @@ -633,6 +634,8 @@ + + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index fb1f904811..05c15791d9 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -256,6 +256,9 @@ src\core\lib\surface + + src\core\lib\transport + src\core\lib\transport @@ -899,6 +902,9 @@ src\core\lib\surface + + src\core\lib\transport + src\core\lib\transport diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index eb3a94df64..1d16ca42d3 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -263,6 +263,7 @@ + @@ -480,6 +481,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index fcc8e34db3..3b04cb2296 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -310,6 +310,9 @@ src\core\lib\surface + + src\core\lib\transport + src\core\lib\transport @@ -683,6 +686,9 @@ src\core\lib\surface + + src\core\lib\transport + src\core\lib\transport diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 519d7317ba..54fbbe8987 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -360,6 +360,7 @@ + @@ -601,6 +602,8 @@ + + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index d30df5c03d..4042b47ca0 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -259,6 +259,9 @@ src\core\lib\surface + + src\core\lib\transport + src\core\lib\transport @@ -809,6 +812,9 @@ src\core\lib\surface + + src\core\lib\transport + src\core\lib\transport -- cgit v1.2.3 From f7970ddc71dd369c6026c86bb6ab1ec6bc88cf27 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 16:49:13 -0700 Subject: Integrate bdp estimator with chttp2 --- .../transport/chttp2/transport/chttp2_transport.c | 95 +++++++++++++++++++--- .../ext/transport/chttp2/transport/frame_data.c | 2 + src/core/ext/transport/chttp2/transport/internal.h | 9 ++ 3 files changed, 95 insertions(+), 11 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 26bcc822b1..793d3cc578 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -133,6 +133,14 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx, static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_error *error); +static void finish_bdp_ping(grpc_exec_ctx *exec_ctx, void *tp, + grpc_error *error); +static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, + grpc_error *error); + +static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + grpc_error *error); + /******************************************************************************* * CONSTRUCTION/DESTRUCTION/REFCOUNTING */ @@ -164,16 +172,7 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx, grpc_combiner_destroy(exec_ctx, t->combiner); - /* callback remaining pings: they're not allowed to call into the transpot, - and maybe they hold resources that need to be freed */ - while (t->pings.next != &t->pings) { - grpc_chttp2_outstanding_ping *ping = t->pings.next; - grpc_exec_ctx_sched(exec_ctx, ping->on_recv, - GRPC_ERROR_CREATE("Transport closed"), NULL); - ping->next->prev = ping->prev; - ping->prev->next = ping->next; - gpr_free(ping); - } + cancel_pings(exec_ctx, t, GRPC_ERROR_CREATE("Transport destroyed")); while (t->write_cb_pool) { grpc_chttp2_write_cb *next = t->write_cb_pool->next; @@ -258,6 +257,11 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure_init(&t->benign_reclaimer_locked, benign_reclaimer_locked, t); grpc_closure_init(&t->destructive_reclaimer_locked, destructive_reclaimer_locked, t); + grpc_closure_init(&t->finish_bdp_ping, finish_bdp_ping, t); + grpc_closure_init(&t->finish_bdp_ping_locked, finish_bdp_ping_locked, t); + + grpc_bdp_estimator_init(&t->bdp_estimator); + t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(&t->hpack_parser); @@ -422,6 +426,7 @@ static void close_transport_locked(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:close"); } end_all_the_calls(exec_ctx, t, GRPC_ERROR_REF(error)); + cancel_pings(exec_ctx, t, GRPC_ERROR_REF(error)); } GRPC_ERROR_UNREF(error); } @@ -1173,6 +1178,20 @@ static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, GPR_TIMER_END("perform_stream_op", 0); } +static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + grpc_error *error) { + /* callback remaining pings: they're not allowed to call into the transpot, + and maybe they hold resources that need to be freed */ + while (t->pings.next != &t->pings) { + grpc_chttp2_outstanding_ping *ping = t->pings.next; + grpc_exec_ctx_sched(exec_ctx, ping->on_recv, GRPC_ERROR_REF(error), NULL); + ping->next->prev = ping->prev; + ping->prev->next = ping->next; + gpr_free(ping); + } + GRPC_ERROR_UNREF(error); +} + static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure *on_recv) { grpc_chttp2_outstanding_ping *p = gpr_malloc(sizeof(*p)); @@ -1761,6 +1780,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, GPR_TIMER_BEGIN("reading_action_locked", 0); grpc_chttp2_transport *t = tp; + bool need_bdp_ping = false; GRPC_ERROR_REF(error); @@ -1778,9 +1798,18 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *errors[3] = {GRPC_ERROR_REF(error), GRPC_ERROR_NONE, GRPC_ERROR_NONE}; for (; i < t->read_buffer.count && errors[1] == GRPC_ERROR_NONE; i++) { + if (grpc_bdp_estimator_add_incoming_bytes( + &t->bdp_estimator, + (int64_t)GPR_SLICE_LENGTH(t->read_buffer.slices[i]))) { + need_bdp_ping = true; + } errors[1] = grpc_chttp2_perform_read(exec_ctx, t, t->read_buffer.slices[i]); - }; + } + if (!t->parse_saw_data_frames) { + need_bdp_ping = false; + } + t->parse_saw_data_frames = false; if (errors[1] != GRPC_ERROR_NONE) { errors[2] = try_http_parsing(exec_ctx, t); GRPC_ERROR_UNREF(error); @@ -1821,6 +1850,16 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, if (keep_reading) { grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer, &t->read_action_begin); + + if (need_bdp_ping && + gpr_time_cmp(gpr_time_add(t->last_bdp_ping_finished, + gpr_time_from_millis(100, GPR_TIMESPAN)), + gpr_now(GPR_CLOCK_MONOTONIC)) < 0) { + GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping"); + grpc_bdp_estimator_start_ping(&t->bdp_estimator); + send_ping_locked(exec_ctx, t, &t->finish_bdp_ping); + } + GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); } else { GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action"); @@ -1833,6 +1872,40 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, GPR_TIMER_END("reading_action_locked", 0); } +static void finish_bdp_ping(grpc_exec_ctx *exec_ctx, void *tp, + grpc_error *error) { + grpc_chttp2_transport *t = tp; + grpc_combiner_execute(exec_ctx, t->combiner, &t->finish_bdp_ping_locked, + GRPC_ERROR_REF(error), false); +} + +static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, + grpc_error *error) { + grpc_chttp2_transport *t = tp; + grpc_bdp_estimator_complete_ping(&t->bdp_estimator); + + t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); + + int64_t estimate; + if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { + gpr_log( + GPR_DEBUG, "%s BDP estimate: %" PRId64 + " (%d %d) [%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d]", + t->peer_string, estimate, t->bdp_estimator.first_sample_idx, + t->bdp_estimator.num_samples, (int)t->bdp_estimator.samples[0], + (int)t->bdp_estimator.samples[1], (int)t->bdp_estimator.samples[2], + (int)t->bdp_estimator.samples[3], (int)t->bdp_estimator.samples[4], + (int)t->bdp_estimator.samples[5], (int)t->bdp_estimator.samples[6], + (int)t->bdp_estimator.samples[7], (int)t->bdp_estimator.samples[8], + (int)t->bdp_estimator.samples[9], (int)t->bdp_estimator.samples[10], + (int)t->bdp_estimator.samples[11], (int)t->bdp_estimator.samples[12], + (int)t->bdp_estimator.samples[13], (int)t->bdp_estimator.samples[14], + (int)t->bdp_estimator.samples[15]); + } + + GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping"); +} + /******************************************************************************* * CALLBACK LOOP */ diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.c index 8668816930..75c03ba228 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.c +++ b/src/core/ext/transport/chttp2/transport/frame_data.c @@ -155,6 +155,8 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, return GRPC_ERROR_NONE; } + t->parse_saw_data_frames = true; + switch (p->state) { case GRPC_CHTTP2_DATA_ERROR: p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index c16c1f61d9..2faeb9d25c 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -50,6 +50,7 @@ #include "src/core/ext/transport/chttp2/transport/stream_map.h" #include "src/core/lib/iomgr/combiner.h" #include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/transport/bdp_estimator.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/transport_impl.h" @@ -295,6 +296,8 @@ struct grpc_chttp2_transport { /** initial window change */ int64_t initial_window_update; + /** did the current parse see actual data bytes? */ + bool parse_saw_data_frames; /** window available for peer to send to us */ int64_t incoming_window; @@ -323,6 +326,12 @@ struct grpc_chttp2_transport { grpc_chttp2_write_cb *write_cb_pool; + /* bdp estimator */ + grpc_bdp_estimator bdp_estimator; + grpc_closure finish_bdp_ping; + grpc_closure finish_bdp_ping_locked; + gpr_timespec last_bdp_ping_finished; + /* if non-NULL, close the transport with this error when writes are finished */ grpc_error *close_transport_on_writes_finished; -- cgit v1.2.3 From 11a204c017c7c7a589b7b44a05fb25af1749f88b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 16:51:08 -0700 Subject: Use max(recent_samples) as bdp estimation --- src/core/lib/transport/bdp_estimator.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index f397440cab..d9129925b3 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -44,30 +44,18 @@ void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator) { estimator->sampling = false; } -static int compare_samples(const void *a, const void *b) { - return GPR_ICMP(*(int64_t *)a, *(int64_t *)b); -} - bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, int64_t *estimate) { if (estimator->num_samples < GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE) { return false; } - int64_t samples[GRPC_BDP_SAMPLES]; + *estimate = -1; for (uint8_t i = 0; i < estimator->num_samples; i++) { - samples[i] = + *estimate = GPR_MAX( + *estimate, estimator - ->samples[(estimator->first_sample_idx + i) % GRPC_BDP_SAMPLES]; - } - qsort(samples, estimator->num_samples, sizeof(*samples), compare_samples); - - if (estimator->num_samples & 1) { - *estimate = samples[estimator->num_samples / 2]; - } else { - *estimate = (samples[estimator->num_samples / 2] + - samples[estimator->num_samples / 2 + 1]) / - 2; + ->samples[(estimator->first_sample_idx + i) % GRPC_BDP_SAMPLES]); } return true; } -- cgit v1.2.3 From 8b34eca90bc25e505cef5d50aab483a62a2df373 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 21:13:31 -0700 Subject: Allow updating initial_window_size, connection_window based on observed bdp --- .../transport/chttp2/transport/chttp2_transport.c | 108 +++++++++++++++++---- .../transport/chttp2/transport/frame_settings.c | 7 +- src/core/ext/transport/chttp2/transport/internal.h | 4 + 3 files changed, 97 insertions(+), 22 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 793d3cc578..e9d5454c3c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -262,6 +262,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_bdp_estimator_init(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); + t->last_pid_update = t->last_bdp_ping_finished; + grpc_pid_controller_init(&t->pid_controller, 128, 64, 0); + t->bdp_guess = DEFAULT_WINDOW; grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(&t->hpack_parser); @@ -1734,6 +1737,39 @@ static void end_all_the_calls(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, * INPUT PROCESSING - PARSING */ +static void update_bdp(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + double bdp_dbl) { + uint32_t bdp; + if (bdp_dbl <= 0) { + bdp = 0; + } else if (bdp_dbl > UINT32_MAX) { + bdp = UINT32_MAX; + } else { + bdp = (uint32_t)(bdp_dbl); + } + int64_t delta = + (int64_t)bdp - + (int64_t)t->settings[GRPC_LOCAL_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; + if (delta == 0 || (bdp != 0 && delta > -1024 && delta < 1024)) { + return; + } + gpr_log(GPR_DEBUG, "%s: %d %" PRId64, t->peer_string, bdp, delta); + if (delta < 0) { + t->retract_incoming_window += -delta; + } else if (delta <= t->retract_incoming_window) { + t->retract_incoming_window -= delta; + } else { + delta -= t->retract_incoming_window; + t->retract_incoming_window = 0; + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("update_bdp", t, announce_incoming_window, + delta); + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("update_bdp", t, incoming_window, delta); + grpc_chttp2_initiate_write(exec_ctx, t, false, "update_bdp"); + } + push_setting(exec_ctx, t, GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, bdp); +} + static void read_action_begin(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { /* Control flow: @@ -1826,7 +1862,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, if (t->initial_window_update > 0) { grpc_chttp2_stream *s; while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) { - grpc_chttp2_list_add_writable_stream(t, s); + grpc_chttp2_become_writable(exec_ctx, t, s, false, "unstalled"); } } t->initial_window_update = 0; @@ -1860,6 +1896,58 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, send_ping_locked(exec_ctx, t, &t->finish_bdp_ping); } + int64_t estimate; + if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); + double dt = dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; + if (dt > 3) { + grpc_pid_controller_reset(&t->pid_controller); + } + double new_guess = t->bdp_guess + grpc_pid_controller_update( + &t->pid_controller, + 2.0 * estimate - t->bdp_guess, dt); + if (new_guess > t->bdp_guess * 2) { + grpc_pid_controller_reset(&t->pid_controller); + t->bdp_guess *= 2; + } else if (new_guess < t->bdp_guess * 0.5) { + grpc_pid_controller_reset(&t->pid_controller); + t->bdp_guess *= 0.5; + } else { + t->bdp_guess = new_guess; + } + update_bdp(exec_ctx, t, t->bdp_guess); + if (0) + gpr_log(GPR_DEBUG, "bdp guess %s: %lf (est=%" PRId64 " dt=%lf int=%lf)", + t->peer_string, t->bdp_guess, estimate, dt, + t->pid_controller.error_integral); + t->last_pid_update = now; + + /* + gpr_log( + GPR_DEBUG, "%s BDP estimate: %" PRId64 + " (%d %d) [%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d + %d]", + t->peer_string, estimate, t->bdp_estimator.first_sample_idx, + t->bdp_estimator.num_samples, (int)t->bdp_estimator.samples[0], + (int)t->bdp_estimator.samples[1], + (int)t->bdp_estimator.samples[2], + (int)t->bdp_estimator.samples[3], + (int)t->bdp_estimator.samples[4], + (int)t->bdp_estimator.samples[5], + (int)t->bdp_estimator.samples[6], + (int)t->bdp_estimator.samples[7], + (int)t->bdp_estimator.samples[8], + (int)t->bdp_estimator.samples[9], + (int)t->bdp_estimator.samples[10], + (int)t->bdp_estimator.samples[11], + (int)t->bdp_estimator.samples[12], + (int)t->bdp_estimator.samples[13], + (int)t->bdp_estimator.samples[14], + (int)t->bdp_estimator.samples[15]); + */ + } + GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); } else { GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action"); @@ -1883,26 +1971,8 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { grpc_chttp2_transport *t = tp; grpc_bdp_estimator_complete_ping(&t->bdp_estimator); - t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); - int64_t estimate; - if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { - gpr_log( - GPR_DEBUG, "%s BDP estimate: %" PRId64 - " (%d %d) [%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d]", - t->peer_string, estimate, t->bdp_estimator.first_sample_idx, - t->bdp_estimator.num_samples, (int)t->bdp_estimator.samples[0], - (int)t->bdp_estimator.samples[1], (int)t->bdp_estimator.samples[2], - (int)t->bdp_estimator.samples[3], (int)t->bdp_estimator.samples[4], - (int)t->bdp_estimator.samples[5], (int)t->bdp_estimator.samples[6], - (int)t->bdp_estimator.samples[7], (int)t->bdp_estimator.samples[8], - (int)t->bdp_estimator.samples[9], (int)t->bdp_estimator.samples[10], - (int)t->bdp_estimator.samples[11], (int)t->bdp_estimator.samples[12], - (int)t->bdp_estimator.samples[13], (int)t->bdp_estimator.samples[14], - (int)t->bdp_estimator.samples[15]); - } - GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping"); } diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.c b/src/core/ext/transport/chttp2/transport/frame_settings.c index 92022f90c9..340a145909 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.c +++ b/src/core/ext/transport/chttp2/transport/frame_settings.c @@ -236,7 +236,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, } if (parser->id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE && parser->incoming_settings[parser->id] != parser->value) { - t->initial_window_update = + t->initial_window_update += (int64_t)parser->value - parser->incoming_settings[parser->id]; if (grpc_http_trace) { gpr_log(GPR_DEBUG, "adding %d for initial_window change", @@ -245,8 +245,9 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, } parser->incoming_settings[parser->id] = parser->value; if (grpc_http_trace) { - gpr_log(GPR_DEBUG, "CHTTP2:%s: got setting %d = %d", - t->is_client ? "CLI" : "SVR", parser->id, parser->value); + gpr_log(GPR_DEBUG, "CHTTP2:%s:%s: got setting %d = %d", + t->is_client ? "CLI" : "SVR", t->peer_string, parser->id, + parser->value); } } else if (grpc_http_trace) { gpr_log(GPR_ERROR, "CHTTP2: Ignoring unknown setting %d (value %d)", diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 2faeb9d25c..6416ee820a 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -52,6 +52,7 @@ #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/transport/bdp_estimator.h" #include "src/core/lib/transport/connectivity_state.h" +#include "src/core/lib/transport/pid_controller.h" #include "src/core/lib/transport/transport_impl.h" /* streams are kept in various linked lists depending on what things need to @@ -328,9 +329,12 @@ struct grpc_chttp2_transport { /* bdp estimator */ grpc_bdp_estimator bdp_estimator; + grpc_pid_controller pid_controller; + double bdp_guess; grpc_closure finish_bdp_ping; grpc_closure finish_bdp_ping_locked; gpr_timespec last_bdp_ping_finished; + gpr_timespec last_pid_update; /* if non-NULL, close the transport with this error when writes are finished */ -- cgit v1.2.3 From ad04666c2d106085ab15daab3bf77905941e33c4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 20 Oct 2016 21:23:58 -0700 Subject: BW est fine tuning --- .../ext/transport/chttp2/transport/chttp2_transport.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index e9d5454c3c..d74ab0e768 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -263,7 +263,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_bdp_estimator_init(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); t->last_pid_update = t->last_bdp_ping_finished; - grpc_pid_controller_init(&t->pid_controller, 128, 64, 0); + grpc_pid_controller_init(&t->pid_controller, 16, 8, 0); t->bdp_guess = DEFAULT_WINDOW; grpc_chttp2_goaway_parser_init(&t->goaway_parser); @@ -1904,18 +1904,8 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, if (dt > 3) { grpc_pid_controller_reset(&t->pid_controller); } - double new_guess = t->bdp_guess + grpc_pid_controller_update( - &t->pid_controller, - 2.0 * estimate - t->bdp_guess, dt); - if (new_guess > t->bdp_guess * 2) { - grpc_pid_controller_reset(&t->pid_controller); - t->bdp_guess *= 2; - } else if (new_guess < t->bdp_guess * 0.5) { - grpc_pid_controller_reset(&t->pid_controller); - t->bdp_guess *= 0.5; - } else { - t->bdp_guess = new_guess; - } + t->bdp_guess += grpc_pid_controller_update( + &t->pid_controller, 2.0 * estimate - t->bdp_guess, dt); update_bdp(exec_ctx, t, t->bdp_guess); if (0) gpr_log(GPR_DEBUG, "bdp guess %s: %lf (est=%" PRId64 " dt=%lf int=%lf)", -- cgit v1.2.3 From b38bfc00bf53d6a42f9d3a15e4eb33be7e37c8b6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 24 Oct 2016 13:21:39 -0700 Subject: Make bdp estimation memory pressure aware --- .../transport/chttp2/transport/chttp2_transport.c | 15 ++++++++-- src/core/lib/iomgr/resource_quota.c | 32 +++++++++++++++++++++- src/core/lib/iomgr/resource_quota.h | 6 ++++ 3 files changed, 49 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 11f12941eb..b435937011 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1811,6 +1811,11 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx, return error; } +static double memory_pressure_to_error(double memory_pressure) { + if (memory_pressure < 0.8) return 0; + return (1.0 - memory_pressure) * 5 * 4096; +} + static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { GPR_TIMER_BEGIN("reading_action_locked", 0); @@ -1900,12 +1905,16 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); - double dt = dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; + double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; if (dt > 3) { grpc_pid_controller_reset(&t->pid_controller); } t->bdp_guess += grpc_pid_controller_update( - &t->pid_controller, 2.0 * estimate - t->bdp_guess, dt); + &t->pid_controller, + 2.0 * (double)estimate - t->bdp_guess - + memory_pressure_to_error(grpc_resource_quota_get_memory_pressure( + grpc_endpoint_get_resource_user(t->ep)->resource_quota)), + dt); update_bdp(exec_ctx, t, t->bdp_guess); if (0) gpr_log(GPR_DEBUG, "bdp guess %s: %lf (est=%" PRId64 " dt=%lf int=%lf)", @@ -2050,7 +2059,7 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, if (t->retract_incoming_window >= add_max_recv_bytes) { t->retract_incoming_window -= add_max_recv_bytes; } else { - add_max_recv_bytes -= t->retract_incoming_window; + add_max_recv_bytes -= (uint32_t)t->retract_incoming_window; t->retract_incoming_window = 0; GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("op", t, announce_incoming_window, add_max_recv_bytes); diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index 5466973408..a988ed5637 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -33,6 +33,8 @@ #include "src/core/lib/iomgr/resource_quota.h" +#include +#include #include #include @@ -44,11 +46,18 @@ int grpc_resource_quota_trace = 0; +#define MEMORY_USAGE_ESTIMATION_MAX 65536 + struct grpc_resource_quota { /* refcount */ gpr_refcount refs; - /* Master combiner lock: all activity on a quota executes under this combiner + /* estimate of current memory usage + scaled to the range [0..RESOURCE_USAGE_ESTIMATION_MAX] */ + gpr_atm memory_usage_estimation; + + /* Master combiner lock: all activity on a quota executes under this + * combiner */ grpc_combiner *combiner; /* Size of the resource quota */ @@ -181,6 +190,16 @@ static void rq_step_sched(grpc_exec_ctx *exec_ctx, GRPC_ERROR_NONE, false); } +/* update the atomically available resource estimate - use no barriers since + timeliness of delivery really doesn't matter much */ +static void rq_update_estimate(grpc_resource_quota *resource_quota) { + gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, + (gpr_atm)((1.0 - + ((double)resource_quota->free_pool) / + ((double)resource_quota->size)) * + MEMORY_USAGE_ESTIMATION_MAX)); +} + /* returns true if all allocations are completed */ static bool rq_alloc(grpc_exec_ctx *exec_ctx, grpc_resource_quota *resource_quota) { @@ -193,6 +212,7 @@ static bool rq_alloc(grpc_exec_ctx *exec_ctx, int64_t amt = -resource_user->free_pool; resource_user->free_pool = 0; resource_quota->free_pool -= amt; + rq_update_estimate(resource_quota); if (grpc_resource_quota_trace) { gpr_log(GPR_DEBUG, "BP %s %s: grant alloc %" PRId64 " bytes; rq_free_pool -> %" PRId64, @@ -227,6 +247,7 @@ static bool rq_scavenge(grpc_exec_ctx *exec_ctx, int64_t amt = resource_user->free_pool; resource_user->free_pool = 0; resource_quota->free_pool += amt; + rq_update_estimate(resource_quota); if (grpc_resource_quota_trace) { gpr_log(GPR_DEBUG, "BP %s %s: scavenge %" PRId64 " bytes; rq_free_pool -> %" PRId64, @@ -411,6 +432,7 @@ static void rq_resize(grpc_exec_ctx *exec_ctx, void *args, grpc_error *error) { int64_t delta = a->size - a->resource_quota->size; a->resource_quota->size += delta; a->resource_quota->free_pool += delta; + rq_update_estimate(a->resource_quota); if (delta < 0 && a->resource_quota->free_pool < 0) { rq_step_sched(exec_ctx, a->resource_quota); } else if (delta > 0 && @@ -442,6 +464,7 @@ grpc_resource_quota *grpc_resource_quota_create(const char *name) { resource_quota->size = INT64_MAX; resource_quota->step_scheduled = false; resource_quota->reclaiming = false; + gpr_atm_no_barrier_store(&resource_quota->memory_usage_estimation, 0); if (name != NULL) { resource_quota->name = gpr_strdup(name); } else { @@ -482,6 +505,13 @@ void grpc_resource_quota_ref(grpc_resource_quota *resource_quota) { grpc_resource_quota_internal_ref(resource_quota); } +double grpc_resource_quota_get_memory_pressure( + grpc_resource_quota *resource_quota) { + return ((double)(gpr_atm_no_barrier_load( + &resource_quota->memory_usage_estimation))) / + ((double)MEMORY_USAGE_ESTIMATION_MAX); +} + void grpc_resource_quota_resize(grpc_resource_quota *resource_quota, size_t size) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index af94a19911..d9e7d8fa90 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -78,6 +78,12 @@ void grpc_resource_quota_internal_unref(grpc_exec_ctx *exec_ctx, grpc_resource_quota *grpc_resource_quota_from_channel_args( const grpc_channel_args *channel_args); +/* Return a number indicating current memory pressure: + 0.0 ==> no memory usage + 1.0 ==> maximum memory usage */ +double grpc_resource_quota_get_memory_pressure( + grpc_resource_quota *resource_quota); + /* Resource users are kept in (potentially) several intrusive linked lists at once. These are the list names. */ typedef enum { -- cgit v1.2.3 From c4530e9d9d2836aad1577007bdbc5dede031957d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 24 Oct 2016 13:35:29 -0700 Subject: Comments --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index b435937011..2d06715571 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1813,7 +1813,8 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx, static double memory_pressure_to_error(double memory_pressure) { if (memory_pressure < 0.8) return 0; - return (1.0 - memory_pressure) * 5 * 4096; + return (1.0 - memory_pressure) * 5 /* 1/0.2 */ * + 4096 /* arbitrary scale factor */; } static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, -- cgit v1.2.3 From 53b0c9d77952cd8adf2230caf1647bf87a003e28 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 24 Oct 2016 17:10:31 -0700 Subject: Test refinement, shows deadlocks now --- .../transport/chttp2/transport/chttp2_transport.c | 111 +++--- src/core/lib/surface/call.c | 4 + test/core/end2end/tests/resource_quota_server.c | 383 +++++++++++---------- 3 files changed, 269 insertions(+), 229 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 2d06715571..f9733afaaf 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1754,7 +1754,7 @@ static void update_bdp(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, if (delta == 0 || (bdp != 0 && delta > -1024 && delta < 1024)) { return; } - gpr_log(GPR_DEBUG, "%s: %d %" PRId64, t->peer_string, bdp, delta); + gpr_log(GPR_DEBUG, "%s [%p]: %d %" PRId64, t->peer_string, t, bdp, delta); if (delta < 0) { t->retract_incoming_window += -delta; } else if (delta <= t->retract_incoming_window) { @@ -1811,12 +1811,6 @@ static grpc_error *try_http_parsing(grpc_exec_ctx *exec_ctx, return error; } -static double memory_pressure_to_error(double memory_pressure) { - if (memory_pressure < 0.8) return 0; - return (1.0 - memory_pressure) * 5 /* 1/0.2 */ * - 4096 /* arbitrary scale factor */; -} - static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { GPR_TIMER_BEGIN("reading_action_locked", 0); @@ -1903,50 +1897,59 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, } int64_t estimate; + double bdp_error = 0.0; if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); - double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; - if (dt > 3) { - grpc_pid_controller_reset(&t->pid_controller); - } - t->bdp_guess += grpc_pid_controller_update( - &t->pid_controller, - 2.0 * (double)estimate - t->bdp_guess - - memory_pressure_to_error(grpc_resource_quota_get_memory_pressure( - grpc_endpoint_get_resource_user(t->ep)->resource_quota)), - dt); - update_bdp(exec_ctx, t, t->bdp_guess); - if (0) - gpr_log(GPR_DEBUG, "bdp guess %s: %lf (est=%" PRId64 " dt=%lf int=%lf)", - t->peer_string, t->bdp_guess, estimate, dt, - t->pid_controller.error_integral); - t->last_pid_update = now; - - /* - gpr_log( - GPR_DEBUG, "%s BDP estimate: %" PRId64 - " (%d %d) [%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d - %d]", - t->peer_string, estimate, t->bdp_estimator.first_sample_idx, - t->bdp_estimator.num_samples, (int)t->bdp_estimator.samples[0], - (int)t->bdp_estimator.samples[1], - (int)t->bdp_estimator.samples[2], - (int)t->bdp_estimator.samples[3], - (int)t->bdp_estimator.samples[4], - (int)t->bdp_estimator.samples[5], - (int)t->bdp_estimator.samples[6], - (int)t->bdp_estimator.samples[7], - (int)t->bdp_estimator.samples[8], - (int)t->bdp_estimator.samples[9], - (int)t->bdp_estimator.samples[10], - (int)t->bdp_estimator.samples[11], - (int)t->bdp_estimator.samples[12], - (int)t->bdp_estimator.samples[13], - (int)t->bdp_estimator.samples[14], - (int)t->bdp_estimator.samples[15]); - */ + bdp_error = 2.0 * (double)estimate - t->bdp_guess; + } + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); + double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; + if (dt > 3) { + grpc_pid_controller_reset(&t->pid_controller); } + double memory_pressure = grpc_resource_quota_get_memory_pressure( + grpc_endpoint_get_resource_user(t->ep)->resource_quota); + if (memory_pressure > 0.8) { + bdp_error = -(memory_pressure - 0.8) * 5 * 32768; + } + if (t->bdp_guess < 1e-6 && bdp_error < 0) { + bdp_error = 0; + } + gpr_log(GPR_DEBUG, "memory_pressure = %lf, error = %lf", memory_pressure, + bdp_error); + t->bdp_guess += + grpc_pid_controller_update(&t->pid_controller, bdp_error, dt); + update_bdp(exec_ctx, t, t->bdp_guess); + if (1) + gpr_log(GPR_DEBUG, + "bdp guess %s: %lf (est=%" PRId64 " dt=%lf err=%lf int=%lf)", + t->peer_string, t->bdp_guess, estimate, dt, + t->pid_controller.last_error, t->pid_controller.error_integral); + t->last_pid_update = now; + + /* + gpr_log( + GPR_DEBUG, "%s BDP estimate: %" PRId64 + " (%d %d) [%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d + %d]", + t->peer_string, estimate, t->bdp_estimator.first_sample_idx, + t->bdp_estimator.num_samples, (int)t->bdp_estimator.samples[0], + (int)t->bdp_estimator.samples[1], + (int)t->bdp_estimator.samples[2], + (int)t->bdp_estimator.samples[3], + (int)t->bdp_estimator.samples[4], + (int)t->bdp_estimator.samples[5], + (int)t->bdp_estimator.samples[6], + (int)t->bdp_estimator.samples[7], + (int)t->bdp_estimator.samples[8], + (int)t->bdp_estimator.samples[9], + (int)t->bdp_estimator.samples[10], + (int)t->bdp_estimator.samples[11], + (int)t->bdp_estimator.samples[12], + (int)t->bdp_estimator.samples[13], + (int)t->bdp_estimator.samples[14], + (int)t->bdp_estimator.samples[15]); + */ GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); } else { @@ -2036,6 +2039,8 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, max_recv_bytes = (uint32_t)max_size_hint; } + uint32_t v1 = max_recv_bytes; + /* account for bytes already received but unknown to higher layers */ if (max_recv_bytes >= have_already) { max_recv_bytes -= (uint32_t)have_already; @@ -2043,6 +2048,14 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, max_recv_bytes = 0; } + gpr_log(GPR_DEBUG, + "update_flow_control %s s->id=%d hint=%" PRIdPTR " have=%" PRIdPTR + " mrb0=%d mrb1=%d, iwd=%" PRId64 " add=%d cur_retract=%d twin=%d", + t->is_client ? "CLI" : "SVR", s->id, max_size_hint, have_already, v1, + max_recv_bytes, s->incoming_window_delta, + (uint32_t)(max_recv_bytes - s->incoming_window_delta), + (int)t->retract_incoming_window, (int)t->incoming_window); + /* add some small lookahead to keep pipelines flowing */ GPR_ASSERT(max_recv_bytes <= UINT32_MAX - initial_window_size); if (s->incoming_window_delta < max_recv_bytes) { diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index ee94f274f8..129c7376dd 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -1072,6 +1072,10 @@ static void continue_receiving_slices(grpc_exec_ctx *exec_ctx, for (;;) { size_t remaining = call->receiving_stream->length - (*call->receiving_buffer)->data.raw.slice_buffer.length; + gpr_log(GPR_DEBUG, "%p len=%d, have=%d, rem=%d", bctl, + (int)call->receiving_stream->length, + (int)(*call->receiving_buffer)->data.raw.slice_buffer.length, + (int)remaining); if (remaining == 0) { call->receiving_message = 0; grpc_byte_stream_destroy(exec_ctx, call->receiving_stream); diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index a2431eed7e..d501e2dcc3 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -112,11 +112,13 @@ void resource_quota_server(grpc_end2end_test_config config) { grpc_resource_quota_create("test_server"); grpc_resource_quota_resize(resource_quota, 5 * 1024 * 1024); -#define NUM_CALLS 100 +#define NUM_CALLS 10 #define CLIENT_BASE_TAG 1000 #define SERVER_START_BASE_TAG 2000 #define SERVER_RECV_BASE_TAG 3000 #define SERVER_END_BASE_TAG 4000 +#define NUM_ROUNDS 1 +#define MAX_READING 4 grpc_arg arg; arg.key = GRPC_ARG_RESOURCE_QUOTA; @@ -132,132 +134,60 @@ void resource_quota_server(grpc_end2end_test_config config) { * multiple round trips to deliver to the peer, and their exact contents of * will be verified on completion. */ gpr_slice request_payload_slice = generate_random_slice(); - - grpc_call *client_calls[NUM_CALLS]; - grpc_call *server_calls[NUM_CALLS]; - grpc_metadata_array initial_metadata_recv[NUM_CALLS]; - grpc_metadata_array trailing_metadata_recv[NUM_CALLS]; - grpc_metadata_array request_metadata_recv[NUM_CALLS]; - grpc_call_details call_details[NUM_CALLS]; - grpc_status_code status[NUM_CALLS]; - char *details[NUM_CALLS]; - size_t details_capacity[NUM_CALLS]; - grpc_byte_buffer *request_payload_recv[NUM_CALLS]; - int was_cancelled[NUM_CALLS]; - grpc_call_error error; - int pending_client_calls = 0; - int pending_server_start_calls = 0; - int pending_server_recv_calls = 0; - int pending_server_end_calls = 0; - int cancelled_calls_on_client = 0; - int cancelled_calls_on_server = 0; - grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - grpc_op ops[6]; - grpc_op *op; - - for (int i = 0; i < NUM_CALLS; i++) { - grpc_metadata_array_init(&initial_metadata_recv[i]); - grpc_metadata_array_init(&trailing_metadata_recv[i]); - grpc_metadata_array_init(&request_metadata_recv[i]); - grpc_call_details_init(&call_details[i]); - details[i] = NULL; - details_capacity[i] = 0; - request_payload_recv[i] = NULL; - was_cancelled[i] = 0; - } - - for (int i = 0; i < NUM_CALLS; i++) { - error = grpc_server_request_call( - f.server, &server_calls[i], &call_details[i], &request_metadata_recv[i], - f.cq, f.cq, tag(SERVER_START_BASE_TAG + i)); - GPR_ASSERT(GRPC_CALL_OK == error); - - pending_server_start_calls++; - } - - for (int i = 0; i < NUM_CALLS; i++) { - client_calls[i] = grpc_channel_create_call( - f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", - "foo.test.google.fr", n_seconds_time(60), NULL); - - memset(ops, 0, sizeof(ops)); - op = ops; - op->op = GRPC_OP_SEND_INITIAL_METADATA; - op->data.send_initial_metadata.count = 0; - op->flags = 0; - op->reserved = NULL; - op++; - op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message = request_payload; - op->flags = 0; - op->reserved = NULL; - op++; - op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; - op->flags = 0; - op->reserved = NULL; - op++; - op->op = GRPC_OP_RECV_INITIAL_METADATA; - op->data.recv_initial_metadata = &initial_metadata_recv[i]; - op->flags = 0; - op->reserved = NULL; - op++; - op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; - op->data.recv_status_on_client.trailing_metadata = - &trailing_metadata_recv[i]; - op->data.recv_status_on_client.status = &status[i]; - op->data.recv_status_on_client.status_details = &details[i]; - op->data.recv_status_on_client.status_details_capacity = - &details_capacity[i]; - op->flags = 0; - op->reserved = NULL; - op++; - error = grpc_call_start_batch(client_calls[i], ops, (size_t)(op - ops), - tag(CLIENT_BASE_TAG + i), NULL); - GPR_ASSERT(GRPC_CALL_OK == error); - - pending_client_calls++; - } + for (int r = 0; r < NUM_ROUNDS; r++) { + grpc_call *client_calls[NUM_CALLS]; + grpc_call *server_calls[NUM_CALLS]; + grpc_metadata_array initial_metadata_recv[NUM_CALLS]; + grpc_metadata_array trailing_metadata_recv[NUM_CALLS]; + grpc_metadata_array request_metadata_recv[NUM_CALLS]; + grpc_call_details call_details[NUM_CALLS]; + grpc_status_code status[NUM_CALLS]; + char *details[NUM_CALLS]; + size_t details_capacity[NUM_CALLS]; + grpc_byte_buffer *request_payload_recv[NUM_CALLS]; + int was_cancelled[NUM_CALLS]; + grpc_call_error error; + int pending_client_calls = 0; + int pending_server_start_calls = 0; + int pending_server_recv_calls = 0; + int pending_server_end_calls = 0; + int cancelled_calls_on_client = 0; + int cancelled_calls_on_server = 0; + int num_ready_for_reading_on_server = 0; + int num_currently_reading_on_server = 0; + int ready_for_reading[NUM_CALLS]; + + grpc_op ops[6]; + grpc_op *op; + + for (int i = 0; i < NUM_CALLS; i++) { + grpc_metadata_array_init(&initial_metadata_recv[i]); + grpc_metadata_array_init(&trailing_metadata_recv[i]); + grpc_metadata_array_init(&request_metadata_recv[i]); + grpc_call_details_init(&call_details[i]); + details[i] = NULL; + details_capacity[i] = 0; + request_payload_recv[i] = NULL; + was_cancelled[i] = 0; + } - while (pending_client_calls + pending_server_recv_calls + - pending_server_end_calls > - 0) { - grpc_event ev = grpc_completion_queue_next(f.cq, n_seconds_time(10), NULL); - GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); - - int ev_tag = (int)(intptr_t)ev.tag; - if (ev_tag < CLIENT_BASE_TAG) { - abort(); /* illegal tag */ - } else if (ev_tag < SERVER_START_BASE_TAG) { - /* client call finished */ - int call_id = ev_tag - CLIENT_BASE_TAG; - GPR_ASSERT(call_id >= 0); - GPR_ASSERT(call_id < NUM_CALLS); - switch (status[call_id]) { - case GRPC_STATUS_RESOURCE_EXHAUSTED: - cancelled_calls_on_client++; - break; - case GRPC_STATUS_OK: - break; - default: - gpr_log(GPR_ERROR, "Unexpected status code: %d", status[call_id]); - abort(); - } - GPR_ASSERT(pending_client_calls > 0); + for (int i = 0; i < NUM_CALLS; i++) { + error = + grpc_server_request_call(f.server, &server_calls[i], &call_details[i], + &request_metadata_recv[i], f.cq, f.cq, + tag(SERVER_START_BASE_TAG + i)); + GPR_ASSERT(GRPC_CALL_OK == error); - grpc_metadata_array_destroy(&initial_metadata_recv[call_id]); - grpc_metadata_array_destroy(&trailing_metadata_recv[call_id]); - grpc_call_destroy(client_calls[call_id]); - gpr_free(details[call_id]); + pending_server_start_calls++; + } - pending_client_calls--; - } else if (ev_tag < SERVER_RECV_BASE_TAG) { - /* new incoming call to the server */ - int call_id = ev_tag - SERVER_START_BASE_TAG; - GPR_ASSERT(call_id >= 0); - GPR_ASSERT(call_id < NUM_CALLS); + for (int i = 0; i < NUM_CALLS; i++) { + client_calls[i] = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + "foo.test.google.fr", n_seconds_time(60), NULL); memset(ops, 0, sizeof(ops)); op = ops; @@ -266,81 +196,174 @@ void resource_quota_server(grpc_end2end_test_config config) { op->flags = 0; op->reserved = NULL; op++; - op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message = &request_payload_recv[call_id]; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message = request_payload; op->flags = 0; op->reserved = NULL; op++; - error = - grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops), - tag(SERVER_RECV_BASE_TAG + call_id), NULL); - GPR_ASSERT(GRPC_CALL_OK == error); - - GPR_ASSERT(pending_server_start_calls > 0); - pending_server_start_calls--; - pending_server_recv_calls++; - - grpc_call_details_destroy(&call_details[call_id]); - grpc_metadata_array_destroy(&request_metadata_recv[call_id]); - } else if (ev_tag < SERVER_END_BASE_TAG) { - /* finished read on the server */ - int call_id = ev_tag - SERVER_RECV_BASE_TAG; - GPR_ASSERT(call_id >= 0); - GPR_ASSERT(call_id < NUM_CALLS); - - if (ev.success) { - if (request_payload_recv[call_id] != NULL) { - grpc_byte_buffer_destroy(request_payload_recv[call_id]); - request_payload_recv[call_id] = NULL; - } - } else { - GPR_ASSERT(request_payload_recv[call_id] == NULL); - } - - memset(ops, 0, sizeof(ops)); - op = ops; - op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; - op->data.recv_close_on_server.cancelled = &was_cancelled[call_id]; + op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; op->flags = 0; op->reserved = NULL; op++; - op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; - op->data.send_status_from_server.trailing_metadata_count = 0; - op->data.send_status_from_server.status = GRPC_STATUS_OK; - op->data.send_status_from_server.status_details = "xyz"; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata = &initial_metadata_recv[i]; op->flags = 0; op->reserved = NULL; op++; - error = - grpc_call_start_batch(server_calls[call_id], ops, (size_t)(op - ops), - tag(SERVER_END_BASE_TAG + call_id), NULL); + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = + &trailing_metadata_recv[i]; + op->data.recv_status_on_client.status = &status[i]; + op->data.recv_status_on_client.status_details = &details[i]; + op->data.recv_status_on_client.status_details_capacity = + &details_capacity[i]; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(client_calls[i], ops, (size_t)(op - ops), + tag(CLIENT_BASE_TAG + i), NULL); GPR_ASSERT(GRPC_CALL_OK == error); - GPR_ASSERT(pending_server_recv_calls > 0); - pending_server_recv_calls--; - pending_server_end_calls++; - } else { - int call_id = ev_tag - SERVER_END_BASE_TAG; - GPR_ASSERT(call_id >= 0); - GPR_ASSERT(call_id < NUM_CALLS); + pending_client_calls++; + } - if (was_cancelled[call_id]) { - cancelled_calls_on_server++; + while (pending_client_calls + pending_server_recv_calls + + pending_server_end_calls > + 0) { + gpr_log(GPR_DEBUG, "cur=%d ready=%d", num_currently_reading_on_server, + num_ready_for_reading_on_server); + while (num_currently_reading_on_server < MAX_READING && + num_ready_for_reading_on_server > 0) { + int call_id = ready_for_reading[--num_ready_for_reading_on_server]; + + gpr_log(GPR_DEBUG, "start reading %d", call_id); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message = &request_payload_recv[call_id]; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch( + server_calls[call_id], ops, (size_t)(op - ops), + tag(SERVER_RECV_BASE_TAG + call_id), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + num_currently_reading_on_server++; + + gpr_log(GPR_DEBUG, "> cur=%d ready=%d", num_currently_reading_on_server, + num_ready_for_reading_on_server); } - GPR_ASSERT(pending_server_end_calls > 0); - pending_server_end_calls--; - grpc_call_destroy(server_calls[call_id]); - } - } + grpc_event ev = + grpc_completion_queue_next(f.cq, n_seconds_time(10), NULL); + GPR_ASSERT(ev.type == GRPC_OP_COMPLETE); + + int ev_tag = (int)(intptr_t)ev.tag; + if (ev_tag < CLIENT_BASE_TAG) { + abort(); /* illegal tag */ + } else if (ev_tag < SERVER_START_BASE_TAG) { + /* client call finished */ + int call_id = ev_tag - CLIENT_BASE_TAG; + GPR_ASSERT(call_id >= 0); + GPR_ASSERT(call_id < NUM_CALLS); + switch (status[call_id]) { + case GRPC_STATUS_RESOURCE_EXHAUSTED: + cancelled_calls_on_client++; + break; + case GRPC_STATUS_OK: + break; + default: + gpr_log(GPR_ERROR, "Unexpected status code: %d", status[call_id]); + abort(); + } + GPR_ASSERT(pending_client_calls > 0); + + grpc_metadata_array_destroy(&initial_metadata_recv[call_id]); + grpc_metadata_array_destroy(&trailing_metadata_recv[call_id]); + grpc_call_destroy(client_calls[call_id]); + gpr_free(details[call_id]); + + pending_client_calls--; + } else if (ev_tag < SERVER_RECV_BASE_TAG) { + /* new incoming call to the server */ + int call_id = ev_tag - SERVER_START_BASE_TAG; + GPR_ASSERT(call_id >= 0); + GPR_ASSERT(call_id < NUM_CALLS); + + ready_for_reading[num_ready_for_reading_on_server++] = call_id; + gpr_log(GPR_DEBUG, "queue read %d", call_id); + + GPR_ASSERT(pending_server_start_calls > 0); + pending_server_start_calls--; + pending_server_recv_calls++; + + grpc_call_details_destroy(&call_details[call_id]); + grpc_metadata_array_destroy(&request_metadata_recv[call_id]); + } else if (ev_tag < SERVER_END_BASE_TAG) { + /* finished read on the server */ + int call_id = ev_tag - SERVER_RECV_BASE_TAG; + GPR_ASSERT(call_id >= 0); + GPR_ASSERT(call_id < NUM_CALLS); + + if (ev.success) { + if (request_payload_recv[call_id] != NULL) { + grpc_byte_buffer_destroy(request_payload_recv[call_id]); + request_payload_recv[call_id] = NULL; + } + } else { + GPR_ASSERT(request_payload_recv[call_id] == NULL); + } - gpr_log( - GPR_INFO, - "Done. %d total calls: %d cancelled at server, %d cancelled at client.", - NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client); + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled[call_id]; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; + op->data.send_status_from_server.trailing_metadata_count = 0; + op->data.send_status_from_server.status = GRPC_STATUS_OK; + op->data.send_status_from_server.status_details = "xyz"; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(server_calls[call_id], ops, + (size_t)(op - ops), + tag(SERVER_END_BASE_TAG + call_id), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + GPR_ASSERT(pending_server_recv_calls > 0); + pending_server_recv_calls--; + pending_server_end_calls++; + num_currently_reading_on_server--; + } else { + int call_id = ev_tag - SERVER_END_BASE_TAG; + GPR_ASSERT(call_id >= 0); + GPR_ASSERT(call_id < NUM_CALLS); + + if (was_cancelled[call_id]) { + cancelled_calls_on_server++; + } + GPR_ASSERT(pending_server_end_calls > 0); + pending_server_end_calls--; - GPR_ASSERT(cancelled_calls_on_client >= cancelled_calls_on_server); - GPR_ASSERT(cancelled_calls_on_server >= 0.9 * cancelled_calls_on_client); + grpc_call_destroy(server_calls[call_id]); + } + } + + gpr_log( + GPR_INFO, + "Done. %d total calls: %d cancelled at server, %d cancelled at client.", + NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client); + } grpc_byte_buffer_destroy(request_payload); gpr_slice_unref(request_payload_slice); -- cgit v1.2.3 From 079f2e6147d0d7224e0d7e4f50f7bf59fea3662d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Oct 2016 06:46:31 -0700 Subject: BDP based transport window --- .../transport/chttp2/transport/chttp2_transport.c | 42 ---------------------- src/core/ext/transport/chttp2/transport/internal.h | 7 ---- src/core/ext/transport/chttp2/transport/parsing.c | 7 +--- src/core/ext/transport/chttp2/transport/writing.c | 12 ++++--- 4 files changed, 8 insertions(+), 60 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 2d06715571..bddd118eab 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -518,23 +518,6 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp, } } - if (s->incoming_window_delta > 0) { - t->retract_incoming_window += s->incoming_window_delta; - } else if (s->incoming_window_delta < 0) { - int64_t give_back = -s->incoming_window_delta; - if (give_back > t->retract_incoming_window) { - give_back -= t->retract_incoming_window; - t->retract_incoming_window = 0; - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("destroy", t, announce_incoming_window, - give_back); - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("destroy", t, incoming_window, - give_back); - grpc_chttp2_initiate_write(exec_ctx, t, false, "destroy_stream"); - } else { - t->retract_incoming_window -= give_back; - } - } - GPR_ASSERT(s->send_initial_metadata_finished == NULL); GPR_ASSERT(s->fetching_send_message == NULL); GPR_ASSERT(s->send_trailing_metadata_finished == NULL); @@ -1755,18 +1738,6 @@ static void update_bdp(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, return; } gpr_log(GPR_DEBUG, "%s: %d %" PRId64, t->peer_string, bdp, delta); - if (delta < 0) { - t->retract_incoming_window += -delta; - } else if (delta <= t->retract_incoming_window) { - t->retract_incoming_window -= delta; - } else { - delta -= t->retract_incoming_window; - t->retract_incoming_window = 0; - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("update_bdp", t, announce_incoming_window, - delta); - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("update_bdp", t, incoming_window, delta); - grpc_chttp2_initiate_write(exec_ctx, t, false, "update_bdp"); - } push_setting(exec_ctx, t, GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, bdp); } @@ -2057,19 +2028,6 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, grpc_chttp2_become_writable(exec_ctx, t, s, new_window_write_is_covered_by_poller, "read_incoming_stream"); - if (t->retract_incoming_window >= add_max_recv_bytes) { - t->retract_incoming_window -= add_max_recv_bytes; - } else { - add_max_recv_bytes -= (uint32_t)t->retract_incoming_window; - t->retract_incoming_window = 0; - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("op", t, announce_incoming_window, - add_max_recv_bytes); - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("op", t, incoming_window, - add_max_recv_bytes); - grpc_chttp2_initiate_write(exec_ctx, t, - new_window_write_is_covered_by_poller, - "read_incoming_stream"); - } } } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 6416ee820a..98ad119287 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -250,13 +250,6 @@ struct grpc_chttp2_transport { /** data to write next write */ gpr_slice_buffer qbuf; - /** window available to announce to peer */ - int64_t announce_incoming_window; - /** how many bytes have been given out as transport window that we'd now like - to retract? (since we can't retract incoming window, instead we just dont - give out any more until this amount goes to zero) */ - int64_t retract_incoming_window; - /** have we seen a goaway */ uint8_t seen_goaway; /** have we sent a goaway */ diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 21e7d7927d..fc01ad9186 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -377,6 +377,7 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("parse", t, incoming_window, incoming_frame_size); + grpc_chttp2_initiate_write(exec_ctx, t, false, "flow_control"); if (s != NULL) { if (incoming_frame_size > @@ -398,12 +399,6 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); s->received_bytes += incoming_frame_size; - } else { - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parse", t, announce_incoming_window, - incoming_frame_size); - GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("parse", t, incoming_window, - incoming_frame_size); - grpc_chttp2_initiate_write(exec_ctx, t, false, "destroy_stream"); } return GRPC_ERROR_NONE; diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index d9816e87e1..b7caac00e2 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -222,11 +222,13 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, /* if the grpc_chttp2_transport is ready to send a window update, do so here also; 3/4 is a magic number that will likely get tuned soon */ - if (t->announce_incoming_window > 0) { - uint32_t announced = - (uint32_t)GPR_MIN(t->announce_incoming_window, UINT32_MAX); - GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", t, announce_incoming_window, - announced); + uint32_t target_incoming_window = GPR_MAX( + t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], + 1024); + if (t->incoming_window < 3 * target_incoming_window / 4) { + uint32_t announced = (uint32_t)GPR_CLAMP( + target_incoming_window - t->incoming_window, 0, UINT32_MAX); + GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("write", t, incoming_window, announced); grpc_transport_one_way_stats throwaway_stats; gpr_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( 0, announced, &throwaway_stats)); -- cgit v1.2.3 From ad2a11fc3d21765d89b4f86106de9c497dae92c9 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 28 Dec 2016 13:05:00 -0800 Subject: Cleanup ping story: part 0 --- .../transport/chttp2/transport/chttp2_transport.c | 90 +++++++++++----------- .../ext/transport/chttp2/transport/frame_ping.h | 4 +- src/core/ext/transport/chttp2/transport/internal.h | 30 ++++---- src/core/lib/transport/bdp_estimator.h | 5 +- 4 files changed, 68 insertions(+), 61 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index fddf2f846d..103a7ac861 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -138,6 +138,10 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_error *error); +static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + grpc_chttp2_ping_type ping_type, + grpc_closure *on_initiate, + grpc_closure *on_complete); /******************************************************************************* * CONSTRUCTION/DESTRUCTION/REFCOUNTING @@ -230,8 +234,6 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->is_client = is_client; t->outgoing_window = DEFAULT_WINDOW; t->incoming_window = DEFAULT_WINDOW; - t->ping_counter = 1; - t->pings.next = t->pings.prev = &t->pings; t->deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; t->is_first_frame = true; grpc_connectivity_state_init( @@ -1214,53 +1216,48 @@ static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_error *error) { /* callback remaining pings: they're not allowed to call into the transpot, and maybe they hold resources that need to be freed */ - while (t->pings.next != &t->pings) { - grpc_chttp2_outstanding_ping *ping = t->pings.next; - grpc_exec_ctx_sched(exec_ctx, ping->on_recv, GRPC_ERROR_REF(error), NULL); - ping->next->prev = ping->prev; - ping->prev->next = ping->next; - gpr_free(ping); + for (size_t i = 0; i < GRPC_CHTTP2_PING_TYPE_COUNT; i++) { + grpc_chttp2_ping_queue *pq = &t->ping_queues[i]; + grpc_closure_list_fail_all(&pq->next_queue, GRPC_ERROR_REF(error)); + grpc_closure_list_fail_all(&pq->initiate_queue, GRPC_ERROR_REF(error)); + grpc_closure_list_fail_all(&pq->inflight_queue, GRPC_ERROR_REF(error)); + grpc_exec_ctx_enqueue_list(exec_ctx, &pq->next_queue, NULL); + grpc_exec_ctx_enqueue_list(exec_ctx, &pq->initiate_queue, NULL); + grpc_exec_ctx_enqueue_list(exec_ctx, &pq->inflight_queue, NULL); } GRPC_ERROR_UNREF(error); } -static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - grpc_closure *on_recv) { - grpc_chttp2_outstanding_ping *p = gpr_malloc(sizeof(*p)); - p->next = &t->pings; - p->prev = p->next->prev; - p->prev->next = p->next->prev = p; - p->id[0] = (uint8_t)((t->ping_counter >> 56) & 0xff); - p->id[1] = (uint8_t)((t->ping_counter >> 48) & 0xff); - p->id[2] = (uint8_t)((t->ping_counter >> 40) & 0xff); - p->id[3] = (uint8_t)((t->ping_counter >> 32) & 0xff); - p->id[4] = (uint8_t)((t->ping_counter >> 24) & 0xff); - p->id[5] = (uint8_t)((t->ping_counter >> 16) & 0xff); - p->id[6] = (uint8_t)((t->ping_counter >> 8) & 0xff); - p->id[7] = (uint8_t)(t->ping_counter & 0xff); - t->ping_counter++; - p->on_recv = on_recv; - grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_ping_create(0, p->id)); - grpc_chttp2_initiate_write(exec_ctx, t, true, "send_ping"); +static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, + grpc_chttp2_transport *t, + grpc_chttp2_ping_type ping_type, + grpc_slice_buffer *buf) { + grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type]; + if (grpc_closure_list_empty(pq->next_queue)) { + /* no ping needed: wait */ + return; + } + if (!grpc_closure_list_empty(pq->inflight_queue)) { + /* ping already in-flight: wait */ + return; + } + pq->inflight_id = t->ping_ctr * GRPC_CHTTP2_PING_TYPE_COUNT + ping_type; + t->ping_ctr++; + grpc_exec_ctx_enqueue_list(exec_ctx, &pq->initiate_queue, NULL); + grpc_slice_buffer_add(buf, grpc_chttp2_ping_create(false, pq->inflight_id)); } void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - const uint8_t *opaque_8bytes) { - grpc_chttp2_outstanding_ping *ping; - for (ping = t->pings.next; ping != &t->pings; ping = ping->next) { - if (0 == memcmp(opaque_8bytes, ping->id, 8)) { - grpc_exec_ctx_sched(exec_ctx, ping->on_recv, GRPC_ERROR_NONE, NULL); - ping->next->prev = ping->prev; - ping->prev->next = ping->next; - gpr_free(ping); - return; - } + uint64_t id) { + grpc_chttp2_ping_queue *pq = + &t->ping_queues[id % GRPC_CHTTP2_PING_TYPE_COUNT]; + if (pq->inflight_id != id) { + char *from = grpc_endpoint_get_peer(t->ep); + gpr_log(GPR_DEBUG, "Unknown ping response from %s: %" PRIx64, from, id); + gpr_free(from); + return; } - char *msg = gpr_dump((const char *)opaque_8bytes, 8, GPR_DUMP_HEX); - char *from = grpc_endpoint_get_peer(t->ep); - gpr_log(GPR_DEBUG, "Unknown ping response from %s: %s", from, msg); - gpr_free(from); - gpr_free(msg); + grpc_exec_ctx_enqueue_list(exec_ctx, &pq->inflight_queue, NULL); } static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, @@ -1305,7 +1302,8 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx, } if (op->send_ping) { - send_ping_locked(exec_ctx, t, op->send_ping); + send_ping_locked(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, NULL, + op->send_ping); } if (close_transport != GRPC_ERROR_NONE) { @@ -1915,8 +1913,10 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, gpr_time_from_millis(100, GPR_TIMESPAN)), gpr_now(GPR_CLOCK_MONOTONIC)) < 0) { GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping"); - grpc_bdp_estimator_start_ping(&t->bdp_estimator); - send_ping_locked(exec_ctx, t, &t->finish_bdp_ping); + grpc_bdp_estimator_schedule_ping(&t->bdp_estimator); + send_ping_locked(exec_ctx, t, + GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE, + &t->start_bdp_ping, &t->finish_bdp_ping); } int64_t estimate = -1; @@ -1933,7 +1933,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, double memory_pressure = grpc_resource_quota_get_memory_pressure( grpc_resource_user_get_quota(grpc_endpoint_get_resource_user(t->ep))); if (memory_pressure > 0.8) { - bdp_error = -(memory_pressure - 0.8) * 5 * 32768; + bdp_error -= GPR_MAX(0, t->bdp_guess) * (memory_pressure - 0.8) / 0.2; } if (t->bdp_guess < 1e-6 && bdp_error < 0) { bdp_error = 0; diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index b9889e2d11..ef642465d7 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -41,10 +41,10 @@ typedef struct { uint8_t byte; uint8_t is_ack; - uint8_t opaque_8bytes[8]; + uint64_t opaque_8bytes; } grpc_chttp2_ping_parser; -grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes); +grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes); grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 221f3b1bca..8497bc84b0 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -75,6 +75,19 @@ typedef enum { GRPC_CHTTP2_WRITE_STATE_WRITING_WITH_MORE_AND_COVERED_BY_POLLER, } grpc_chttp2_write_state; +typedef enum { + GRPC_CHTTP2_PING_ON_NEXT_WRITE = 0, + GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE, + GRPC_CHTTP2_PING_TYPE_COUNT /* must be last */ +} grpc_chttp2_ping_type; + +typedef struct { + grpc_closure_list next_queue; + grpc_closure_list initiate_queue; + grpc_closure_list inflight_queue; + uint64_t inflight_id; +} grpc_chttp2_ping_queue; + /* deframer state for the overall http2 stream of bytes */ typedef enum { /* prefix: one entry per http2 connection prefix byte */ @@ -147,14 +160,6 @@ typedef enum { GRPC_CHTTP2_GOAWAY_SENT, } grpc_chttp2_sent_goaway_state; -/* Outstanding ping request data */ -typedef struct grpc_chttp2_outstanding_ping { - uint8_t id[8]; - grpc_closure *on_recv; - struct grpc_chttp2_outstanding_ping *next; - struct grpc_chttp2_outstanding_ping *prev; -} grpc_chttp2_outstanding_ping; - typedef struct grpc_chttp2_write_cb { int64_t call_at_byte; grpc_closure *closure; @@ -271,10 +276,9 @@ struct grpc_chttp2_transport { /** last new stream id */ uint32_t last_new_stream_id; - /** pings awaiting responses */ - grpc_chttp2_outstanding_ping pings; - /** next payload for an outgoing ping */ - uint64_t ping_counter; + /** ping queues for various ping insertion points */ + grpc_chttp2_ping_queue ping_queues[GRPC_CHTTP2_PING_TYPE_COUNT]; + uint64_t ping_ctr; /* unique id for pings */ /** parser for headers */ grpc_chttp2_hpack_parser hpack_parser; @@ -684,7 +688,7 @@ void grpc_chttp2_incoming_byte_stream_finished( grpc_error *error); void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - const uint8_t *opaque_8bytes); + uint64_t id); /** add a ref to the stream and add it to the writable list; ref will be dropped in writing.c */ diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index 40128f1199..e81699cbee 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -43,6 +43,7 @@ typedef struct grpc_bdp_estimator { uint8_t num_samples; uint8_t first_sample_idx; + bool scheduled; bool sampling; int64_t samples[GRPC_BDP_SAMPLES]; } grpc_bdp_estimator; @@ -55,7 +56,9 @@ bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, // Returns true if the user should start a ping bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes); -// Note that a ping is starting +// Schedule a ping +void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator); +// Start a ping void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator); // Completes a previously started ping void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator); -- cgit v1.2.3 From e9c2d4e9ffda8a0cd6ad4f0d9b977d550bb8e134 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 29 Dec 2016 12:17:48 -0800 Subject: Update cronet --- .../transport/cronet/transport/cronet_transport.c | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 6f94ccbc87..df0a769f6c 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -850,16 +850,16 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, CRONET_LOG(GPR_DEBUG, "running: %p OP_RECV_INITIAL_METADATA", oas); if (stream_state->state_op_done[OP_CANCEL_ERROR]) { grpc_closure_sched(exec_ctx, stream_op->recv_initial_metadata_ready, - GRPC_ERROR_CANCELLED, NULL); + GRPC_ERROR_CANCELLED); } else if (stream_state->state_callback_received[OP_FAILED]) { grpc_closure_sched( exec_ctx, stream_op->recv_initial_metadata_ready, - make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."), NULL); + make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable.")); } else { grpc_chttp2_incoming_metadata_buffer_publish( &oas->s->state.rs.initial_metadata, stream_op->recv_initial_metadata); grpc_closure_sched(exec_ctx, stream_op->recv_initial_metadata_ready, - GRPC_ERROR_NONE, NULL); + GRPC_ERROR_NONE); } stream_state->state_op_done[OP_RECV_INITIAL_METADATA] = true; result = ACTION_TAKEN_NO_CALLBACK; @@ -911,21 +911,21 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, if (stream_state->state_op_done[OP_CANCEL_ERROR]) { CRONET_LOG(GPR_DEBUG, "Stream is cancelled."); grpc_closure_sched(exec_ctx, stream_op->recv_message_ready, - GRPC_ERROR_CANCELLED, NULL); + GRPC_ERROR_CANCELLED); stream_state->state_op_done[OP_RECV_MESSAGE] = true; result = ACTION_TAKEN_NO_CALLBACK; } else if (stream_state->state_callback_received[OP_FAILED]) { CRONET_LOG(GPR_DEBUG, "Stream failed."); grpc_closure_sched( exec_ctx, stream_op->recv_message_ready, - make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."), NULL); + make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable.")); stream_state->state_op_done[OP_RECV_MESSAGE] = true; result = ACTION_TAKEN_NO_CALLBACK; } else if (stream_state->rs.read_stream_closed == true) { /* No more data will be received */ CRONET_LOG(GPR_DEBUG, "read stream closed"); grpc_closure_sched(exec_ctx, stream_op->recv_message_ready, - GRPC_ERROR_NONE, NULL); + GRPC_ERROR_NONE); stream_state->state_op_done[OP_RECV_MESSAGE] = true; oas->state.state_op_done[OP_RECV_MESSAGE] = true; result = ACTION_TAKEN_NO_CALLBACK; @@ -959,7 +959,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, *((grpc_byte_buffer **)stream_op->recv_message) = (grpc_byte_buffer *)&stream_state->rs.sbs; grpc_closure_sched(exec_ctx, stream_op->recv_message_ready, - GRPC_ERROR_NONE, NULL); + GRPC_ERROR_NONE); stream_state->state_op_done[OP_RECV_MESSAGE] = true; oas->state.state_op_done[OP_RECV_MESSAGE] = true; result = ACTION_TAKEN_NO_CALLBACK; @@ -994,7 +994,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, *((grpc_byte_buffer **)stream_op->recv_message) = (grpc_byte_buffer *)&stream_state->rs.sbs; grpc_closure_sched(exec_ctx, stream_op->recv_message_ready, - GRPC_ERROR_NONE, NULL); + GRPC_ERROR_NONE); stream_state->state_op_done[OP_RECV_MESSAGE] = true; oas->state.state_op_done[OP_RECV_MESSAGE] = true; /* Do an extra read to trigger on_succeeded() callback in case connection @@ -1056,17 +1056,16 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, CRONET_LOG(GPR_DEBUG, "running: %p OP_ON_COMPLETE", oas); if (stream_state->state_op_done[OP_CANCEL_ERROR]) { grpc_closure_sched(exec_ctx, stream_op->on_complete, - GRPC_ERROR_REF(stream_state->cancel_error), NULL); + GRPC_ERROR_REF(stream_state->cancel_error)); } else if (stream_state->state_callback_received[OP_FAILED]) { grpc_closure_sched( exec_ctx, stream_op->on_complete, - make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable."), NULL); + make_error_with_desc(GRPC_STATUS_UNAVAILABLE, "Unavailable.")); } else { /* All actions in this stream_op are complete. Call the on_complete * callback */ - grpc_closure_sched(exec_ctx, stream_op->on_complete, GRPC_ERROR_NONE, - NULL); + grpc_closure_sched(exec_ctx, stream_op->on_complete, GRPC_ERROR_NONE); } oas->state.state_op_done[OP_ON_COMPLETE] = true; oas->done = true; -- cgit v1.2.3 From c0118b494ec2df10d7945925e9b1c9da6b868919 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 29 Dec 2016 12:17:57 -0800 Subject: Ping progress --- .../transport/chttp2/transport/chttp2_transport.c | 46 +++++++++++----------- .../ext/transport/chttp2/transport/frame_ping.c | 14 +++++-- src/core/ext/transport/chttp2/transport/internal.h | 11 ++++-- src/core/ext/transport/chttp2/transport/writing.c | 43 ++++++++++++++++++++ src/core/lib/iomgr/closure.c | 8 ++-- src/core/lib/iomgr/closure.h | 5 ++- src/core/lib/transport/bdp_estimator.c | 29 +++++++++----- src/core/lib/transport/bdp_estimator.h | 18 ++++++--- 8 files changed, 126 insertions(+), 48 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 04a8e727d1..6d302b0f11 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -244,6 +244,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure_init(&t->destructive_reclaimer_locked, destructive_reclaimer_locked, t, grpc_combiner_scheduler(t->combiner, false)); + grpc_closure_init(&t->start_bdp_ping_locked, start_bdp_ping_locked, t, + grpc_combiner_scheduler(t->combiner, false)); grpc_closure_init(&t->finish_bdp_ping_locked, finish_bdp_ping_locked, t, grpc_combiner_scheduler(t->combiner, false)); @@ -1204,33 +1206,24 @@ static void cancel_pings(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, and maybe they hold resources that need to be freed */ for (size_t i = 0; i < GRPC_CHTTP2_PING_TYPE_COUNT; i++) { grpc_chttp2_ping_queue *pq = &t->ping_queues[i]; - grpc_closure_list_fail_all(&pq->next_queue, GRPC_ERROR_REF(error)); - grpc_closure_list_fail_all(&pq->initiate_queue, GRPC_ERROR_REF(error)); - grpc_closure_list_fail_all(&pq->inflight_queue, GRPC_ERROR_REF(error)); - grpc_closure_list_sched(exec_ctx, &pq->next_queue); - grpc_closure_list_sched(exec_ctx, &pq->initiate_queue); - grpc_closure_list_sched(exec_ctx, &pq->inflight_queue); + for (size_t j = 0; j < GRPC_CHTTP2_PCL_COUNT; j++) { + grpc_closure_list_fail_all(&pq->lists[j], GRPC_ERROR_REF(error)); + grpc_closure_list_sched(exec_ctx, &pq->lists[j]); + } } GRPC_ERROR_UNREF(error); } -static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, - grpc_chttp2_ping_type ping_type, - grpc_slice_buffer *buf) { +static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, + grpc_chttp2_ping_type ping_type, + grpc_closure *on_initiate, grpc_closure *on_ack) { grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type]; - if (grpc_closure_list_empty(pq->next_queue)) { - /* no ping needed: wait */ - return; - } - if (!grpc_closure_list_empty(pq->inflight_queue)) { - /* ping already in-flight: wait */ - return; + grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_INITIATE], on_initiate, + GRPC_ERROR_NONE); + if (grpc_closure_list_append(&pq->lists[GRPC_CHTTP2_PCL_NEXT], on_ack, + GRPC_ERROR_NONE)) { + grpc_chttp2_initiate_write(exec_ctx, t, false, "send_ping"); } - pq->inflight_id = t->ping_ctr * GRPC_CHTTP2_PING_TYPE_COUNT + ping_type; - t->ping_ctr++; - grpc_closure_list_sched(exec_ctx, &pq->initiate_queue); - grpc_slice_buffer_add(buf, grpc_chttp2_ping_create(false, pq->inflight_id)); } void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, @@ -1243,7 +1236,10 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, gpr_free(from); return; } - grpc_closure_list_sched(exec_ctx, &pq->inflight_queue); + grpc_closure_list_sched(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); + if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) { + grpc_chttp2_initiate_write(exec_ctx, t, false, "continue_pings"); + } } static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, @@ -1942,6 +1938,12 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping"); } +static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, + grpc_error *error) { + grpc_chttp2_transport *t = tp; + grpc_bdp_estimator_start_ping(&t->bdp_estimator); +} + /******************************************************************************* * CALLBACK LOOP */ diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 7de5f6362d..66a9bc0966 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -40,7 +40,7 @@ #include #include -grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) { +grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint64_t opaque_8bytes) { grpc_slice slice = grpc_slice_malloc(9 + 8); uint8_t *p = GRPC_SLICE_START_PTR(slice); @@ -53,7 +53,14 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) { *p++ = 0; *p++ = 0; *p++ = 0; - memcpy(p, opaque_8bytes, 8); + *p++ = (uint8_t)(opaque_8bytes >> 56); + *p++ = (uint8_t)(opaque_8bytes >> 48); + *p++ = (uint8_t)(opaque_8bytes >> 40); + *p++ = (uint8_t)(opaque_8bytes >> 32); + *p++ = (uint8_t)(opaque_8bytes >> 24); + *p++ = (uint8_t)(opaque_8bytes >> 16); + *p++ = (uint8_t)(opaque_8bytes >> 8); + *p++ = (uint8_t)(opaque_8bytes); return slice; } @@ -70,6 +77,7 @@ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser, } parser->byte = 0; parser->is_ack = flags; + parser->opaque_8bytes = 0; return GRPC_ERROR_NONE; } @@ -83,7 +91,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_ping_parser *p = parser; while (p->byte != 8 && cur != end) { - p->opaque_8bytes[p->byte] = *cur; + p->opaque_8bytes |= (((uint64_t)*cur) << (8 * p->byte)); cur++; p->byte++; } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 1a6a1d8b2a..90abf386c7 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -81,10 +81,15 @@ typedef enum { GRPC_CHTTP2_PING_TYPE_COUNT /* must be last */ } grpc_chttp2_ping_type; +typedef enum { + GRPC_CHTTP2_PCL_NEXT = 0, + GRPC_CHTTP2_PCL_INITIATE, + GRPC_CHTTP2_PCL_INFLIGHT, + GRPC_CHTTP2_PCL_COUNT /* must be last */ +} grpc_chttp2_ping_closure_list; + typedef struct { - grpc_closure_list next_queue; - grpc_closure_list initiate_queue; - grpc_closure_list inflight_queue; + grpc_closure_list lists[GRPC_CHTTP2_PCL_COUNT]; uint64_t inflight_id; } grpc_chttp2_ping_queue; diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index bbf5c0b1b4..43205a82f6 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -55,6 +55,45 @@ static void finish_write_cb(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->write_cb_pool = cb; } +static void collapse_pings_from_into(grpc_chttp2_transport *t, + grpc_chttp2_ping_type ping_type, + grpc_chttp2_ping_queue *pq) { + for (size_t i = 0; i < GRPC_CHTTP2_PCL_COUNT; i++) { + grpc_closure_list_move(&t->ping_queues[ping_type].lists[i], &pq->lists[i]); + } +} + +static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, + grpc_chttp2_transport *t, + grpc_chttp2_ping_type ping_type) { + grpc_chttp2_ping_queue *pq = &t->ping_queues[ping_type]; + if (grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_NEXT])) { + /* no ping needed: wait */ + return; + } + if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { + /* ping already in-flight: wait */ + return; + } + /* coalesce equivalent pings into this one */ + switch (ping_type) { + case GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE: + collapse_pings_from_into(t, GRPC_CHTTP2_PING_ON_NEXT_WRITE, pq); + break; + case GRPC_CHTTP2_PING_ON_NEXT_WRITE: + break; + case GRPC_CHTTP2_PING_TYPE_COUNT: + GPR_UNREACHABLE_CODE(break); + } + pq->inflight_id = t->ping_ctr * GRPC_CHTTP2_PING_TYPE_COUNT + ping_type; + t->ping_ctr++; + grpc_closure_list_sched(exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INITIATE]); + grpc_closure_list_move(&pq->lists[GRPC_CHTTP2_PCL_NEXT], + &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(false, pq->inflight_id)); +} + static void update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, int64_t send_bytes, grpc_chttp2_write_cb **list, grpc_error *error) { @@ -226,6 +265,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], 1024); if (t->incoming_window < 3 * target_incoming_window / 4) { + maybe_initiate_ping(exec_ctx, t, + GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); uint32_t announced = (uint32_t)GPR_CLAMP( target_incoming_window - t->incoming_window, 0, UINT32_MAX); GRPC_CHTTP2_FLOW_CREDIT_TRANSPORT("write", t, incoming_window, announced); @@ -234,6 +275,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, 0, announced, &throwaway_stats)); } + maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); + GPR_TIMER_END("grpc_chttp2_begin_write", 0); return t->outbuf.count > 0; diff --git a/src/core/lib/iomgr/closure.c b/src/core/lib/iomgr/closure.c index da0ec878a3..ec197c7d82 100644 --- a/src/core/lib/iomgr/closure.c +++ b/src/core/lib/iomgr/closure.c @@ -50,20 +50,22 @@ void grpc_closure_list_init(grpc_closure_list *closure_list) { closure_list->head = closure_list->tail = NULL; } -void grpc_closure_list_append(grpc_closure_list *closure_list, +bool grpc_closure_list_append(grpc_closure_list *closure_list, grpc_closure *closure, grpc_error *error) { if (closure == NULL) { GRPC_ERROR_UNREF(error); - return; + return false; } closure->error_data.error = error; closure->next_data.next = NULL; - if (closure_list->head == NULL) { + bool was_empty = (closure_list->head == NULL); + if (was_empty) { closure_list->head = closure; } else { closure_list->tail->next_data.next = closure; } closure_list->tail = closure; + return was_empty; } void grpc_closure_list_fail_all(grpc_closure_list *list, diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index 1b5d9b20a0..1a4ebbd360 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -117,8 +117,9 @@ grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg, void grpc_closure_list_init(grpc_closure_list *list); /** add \a closure to the end of \a list - and set \a closure's result to \a error */ -void grpc_closure_list_append(grpc_closure_list *list, grpc_closure *closure, + and set \a closure's result to \a error + Returns true if \a list becomes non-empty */ +bool grpc_closure_list_append(grpc_closure_list *list, grpc_closure *closure, grpc_error *error); /** force all success bits in \a list to false */ diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index d9129925b3..4c2c1d3e8c 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -41,7 +41,7 @@ void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator) { estimator->num_samples = 0; estimator->first_sample_idx = 0; - estimator->sampling = false; + estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; } bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, @@ -68,17 +68,26 @@ static int64_t *sampling(grpc_bdp_estimator *estimator) { bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes) { - if (estimator->sampling) { - *sampling(estimator) += num_bytes; - return false; - } else { - return true; + switch (estimator->ping_state) { + case GRPC_BDP_PING_UNSCHEDULED: + return true; + case GRPC_BDP_PING_SCHEDULED: + return false; + case GRPC_BDP_PING_STARTED: + *sampling(estimator) += num_bytes; + return false; } + GPR_UNREACHABLE_CODE(return false); +} + +void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator) { + GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_UNSCHEDULED); + estimator->ping_state = GRPC_BDP_PING_SCHEDULED; } void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { - GPR_ASSERT(!estimator->sampling); - estimator->sampling = true; + GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_SCHEDULED); + estimator->ping_state = GRPC_BDP_PING_STARTED; if (estimator->num_samples == GRPC_BDP_SAMPLES) { estimator->first_sample_idx++; estimator->num_samples--; @@ -87,7 +96,7 @@ void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { } void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { - GPR_ASSERT(estimator->sampling); + GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_STARTED); estimator->num_samples++; - estimator->sampling = false; + estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index e81699cbee..d812f90a35 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -40,11 +40,16 @@ #define GRPC_BDP_SAMPLES 16 #define GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE 3 +typedef enum { + GRPC_BDP_PING_UNSCHEDULED, + GRPC_BDP_PING_SCHEDULED, + GRPC_BDP_PING_STARTED +} grpc_bdp_estimator_ping_state; + typedef struct grpc_bdp_estimator { uint8_t num_samples; uint8_t first_sample_idx; - bool scheduled; - bool sampling; + grpc_bdp_estimator_ping_state ping_state; int64_t samples[GRPC_BDP_SAMPLES]; } grpc_bdp_estimator; @@ -53,12 +58,15 @@ void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator); // Returns true if a reasonable estimate could be obtained bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, int64_t *estimate); -// Returns true if the user should start a ping +// Returns true if the user should schedule a ping bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes); -// Schedule a ping +// Schedule a ping: call in response to receiving a true from +// grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a +// transport (but not necessarily started) void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator); -// Start a ping +// Start a ping: call after calling grpc_bdp_estimator_schedule_ping and once +// the ping is on the wire void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator); // Completes a previously started ping void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator); -- cgit v1.2.3 From 91f77eacce6342329bb1995e600d39fe16720fa4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 29 Dec 2016 16:59:43 -0800 Subject: PID controller stabilization --- .../transport/chttp2/transport/chttp2_transport.c | 59 ++++++++++++---------- src/core/ext/transport/chttp2/transport/internal.h | 6 +-- src/core/lib/transport/bdp_estimator.c | 34 +++---------- src/core/lib/transport/bdp_estimator.h | 5 +- 4 files changed, 45 insertions(+), 59 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 6d302b0f11..8cce283b7a 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -252,8 +252,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_bdp_estimator_init(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); t->last_pid_update = t->last_bdp_ping_finished; - grpc_pid_controller_init(&t->pid_controller, 16, 8, 0); - t->bdp_guess = DEFAULT_WINDOW; + grpc_pid_controller_init(&t->pid_controller, 4, 4, 0); + t->log2_bdp_guess = log2(DEFAULT_WINDOW); grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(&t->hpack_parser); @@ -1897,26 +1897,29 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, int64_t estimate = -1; double bdp_error = 0.0; if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { - bdp_error = 2.0 * (double)estimate - t->bdp_guess; - } - gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); - double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; - if (dt > 3) { - grpc_pid_controller_reset(&t->pid_controller); - } - double memory_pressure = grpc_resource_quota_get_memory_pressure( - grpc_resource_user_get_quota(grpc_endpoint_get_resource_user(t->ep))); - if (memory_pressure > 0.8) { - bdp_error -= GPR_MAX(0, t->bdp_guess) * (memory_pressure - 0.8) / 0.2; - } - if (t->bdp_guess < 1e-6 && bdp_error < 0) { - bdp_error = 0; + double target = (double)estimate; + double memory_pressure = grpc_resource_quota_get_memory_pressure( + grpc_resource_user_get_quota(grpc_endpoint_get_resource_user(t->ep))); + if (memory_pressure > 0.8) { + target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1); + } + bdp_error = target > 0 ? log2(target) - t->log2_bdp_guess + : GPR_MIN(0, -t->log2_bdp_guess); + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); + double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; + if (dt > 3) { + grpc_pid_controller_reset(&t->pid_controller); + } + t->log2_bdp_guess += + grpc_pid_controller_update(&t->pid_controller, bdp_error, dt); + t->log2_bdp_guess = GPR_CLAMP(t->log2_bdp_guess, -5, 21); + gpr_log(GPR_DEBUG, "%s: err=%lf cur=%lf pressure=%lf target=%lf", + t->peer_string, bdp_error, t->log2_bdp_guess, memory_pressure, + target); + update_bdp(exec_ctx, t, pow(2, t->log2_bdp_guess)); + t->last_pid_update = now; } - t->bdp_guess += - grpc_pid_controller_update(&t->pid_controller, bdp_error, dt); - update_bdp(exec_ctx, t, t->bdp_guess); - t->last_pid_update = now; GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); } else { GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "reading_action"); @@ -1929,21 +1932,23 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, GPR_TIMER_END("reading_action_locked", 0); } +static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, + grpc_error *error) { + grpc_chttp2_transport *t = tp; + gpr_log(GPR_DEBUG, "%s: Start BDP ping", t->peer_string); + grpc_bdp_estimator_start_ping(&t->bdp_estimator); +} + static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { grpc_chttp2_transport *t = tp; + gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string); grpc_bdp_estimator_complete_ping(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping"); } -static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, - grpc_error *error) { - grpc_chttp2_transport *t = tp; - grpc_bdp_estimator_start_ping(&t->bdp_estimator); -} - /******************************************************************************* * CALLBACK LOOP */ diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 90abf386c7..e320dd091d 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -82,8 +82,8 @@ typedef enum { } grpc_chttp2_ping_type; typedef enum { - GRPC_CHTTP2_PCL_NEXT = 0, - GRPC_CHTTP2_PCL_INITIATE, + GRPC_CHTTP2_PCL_INITIATE = 0, + GRPC_CHTTP2_PCL_NEXT, GRPC_CHTTP2_PCL_INFLIGHT, GRPC_CHTTP2_PCL_COUNT /* must be last */ } grpc_chttp2_ping_closure_list; @@ -330,7 +330,7 @@ struct grpc_chttp2_transport { /* bdp estimator */ grpc_bdp_estimator bdp_estimator; grpc_pid_controller pid_controller; - double bdp_guess; + double log2_bdp_guess; grpc_closure start_bdp_ping_locked; grpc_closure finish_bdp_ping_locked; gpr_timespec last_bdp_ping_finished; diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index 4c2c1d3e8c..90e4332023 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -39,33 +39,16 @@ #include void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator) { - estimator->num_samples = 0; - estimator->first_sample_idx = 0; + estimator->estimate = 65536; estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; } bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, int64_t *estimate) { - if (estimator->num_samples < GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE) { - return false; - } - - *estimate = -1; - for (uint8_t i = 0; i < estimator->num_samples; i++) { - *estimate = GPR_MAX( - *estimate, - estimator - ->samples[(estimator->first_sample_idx + i) % GRPC_BDP_SAMPLES]); - } + *estimate = estimator->estimate; return true; } -static int64_t *sampling(grpc_bdp_estimator *estimator) { - return &estimator - ->samples[(estimator->first_sample_idx + estimator->num_samples) % - GRPC_BDP_SAMPLES]; -} - bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes) { switch (estimator->ping_state) { @@ -74,7 +57,7 @@ bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, case GRPC_BDP_PING_SCHEDULED: return false; case GRPC_BDP_PING_STARTED: - *sampling(estimator) += num_bytes; + estimator->accumulator += num_bytes; return false; } GPR_UNREACHABLE_CODE(return false); @@ -88,15 +71,14 @@ void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator) { void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_SCHEDULED); estimator->ping_state = GRPC_BDP_PING_STARTED; - if (estimator->num_samples == GRPC_BDP_SAMPLES) { - estimator->first_sample_idx++; - estimator->num_samples--; - } - *sampling(estimator) = 0; + estimator->accumulator = 0; } void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_STARTED); - estimator->num_samples++; + if (estimator->accumulator > 2 * estimator->estimate / 3) { + estimator->estimate *= 2; + gpr_log(GPR_DEBUG, "est --> %" PRId64, estimator->estimate); + } estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index d812f90a35..ea74f2b5d5 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -47,10 +47,9 @@ typedef enum { } grpc_bdp_estimator_ping_state; typedef struct grpc_bdp_estimator { - uint8_t num_samples; - uint8_t first_sample_idx; grpc_bdp_estimator_ping_state ping_state; - int64_t samples[GRPC_BDP_SAMPLES]; + int64_t accumulator; + int64_t estimate; } grpc_bdp_estimator; void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator); -- cgit v1.2.3 From 95234e1baa12c61aa6fbfefb7010e2ea54b52368 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Jan 2017 10:48:10 -0800 Subject: Increase stability of integration for PID controller --- .../transport/chttp2/transport/chttp2_transport.c | 16 +++++++-------- src/core/ext/transport/chttp2/transport/internal.h | 1 - src/core/lib/transport/pid_controller.c | 24 +++++++++++++++++----- src/core/lib/transport/pid_controller.h | 10 +++++++-- test/core/transport/pid_controller_test.c | 11 +++++----- 5 files changed, 40 insertions(+), 22 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 8cce283b7a..5f3f3d855b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -252,8 +252,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_bdp_estimator_init(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); t->last_pid_update = t->last_bdp_ping_finished; - grpc_pid_controller_init(&t->pid_controller, 4, 4, 0); - t->log2_bdp_guess = log2(DEFAULT_WINDOW); + grpc_pid_controller_init(&t->pid_controller, log2(DEFAULT_WINDOW), 4, 4, 0); grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(&t->hpack_parser); @@ -1903,21 +1902,22 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, if (memory_pressure > 0.8) { target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1); } - bdp_error = target > 0 ? log2(target) - t->log2_bdp_guess - : GPR_MIN(0, -t->log2_bdp_guess); + bdp_error = + target > 0 + ? log2(target) - grpc_pid_controller_last(&t->pid_controller) + : GPR_MIN(0, -grpc_pid_controller_last(&t->pid_controller)); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; if (dt > 3) { grpc_pid_controller_reset(&t->pid_controller); } - t->log2_bdp_guess += + double log2_bdp_guess = grpc_pid_controller_update(&t->pid_controller, bdp_error, dt); - t->log2_bdp_guess = GPR_CLAMP(t->log2_bdp_guess, -5, 21); gpr_log(GPR_DEBUG, "%s: err=%lf cur=%lf pressure=%lf target=%lf", - t->peer_string, bdp_error, t->log2_bdp_guess, memory_pressure, + t->peer_string, bdp_error, log2_bdp_guess, memory_pressure, target); - update_bdp(exec_ctx, t, pow(2, t->log2_bdp_guess)); + update_bdp(exec_ctx, t, pow(2, log2_bdp_guess)); t->last_pid_update = now; } GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "keep_reading"); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index e320dd091d..8b7c040358 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -330,7 +330,6 @@ struct grpc_chttp2_transport { /* bdp estimator */ grpc_bdp_estimator bdp_estimator; grpc_pid_controller pid_controller; - double log2_bdp_guess; grpc_closure start_bdp_ping_locked; grpc_closure finish_bdp_ping_locked; gpr_timespec last_bdp_ping_finished; diff --git a/src/core/lib/transport/pid_controller.c b/src/core/lib/transport/pid_controller.c index 3cef225d4b..ba56874503 100644 --- a/src/core/lib/transport/pid_controller.c +++ b/src/core/lib/transport/pid_controller.c @@ -34,7 +34,9 @@ #include "src/core/lib/transport/pid_controller.h" void grpc_pid_controller_init(grpc_pid_controller *pid_controller, - double gain_p, double gain_i, double gain_d) { + double initial_control_value, double gain_p, + double gain_i, double gain_d) { + pid_controller->last_control_value = initial_control_value; pid_controller->gain_p = gain_p; pid_controller->gain_i = gain_i; pid_controller->gain_d = gain_d; @@ -48,10 +50,22 @@ void grpc_pid_controller_reset(grpc_pid_controller *pid_controller) { double grpc_pid_controller_update(grpc_pid_controller *pid_controller, double error, double dt) { - pid_controller->error_integral += error * dt; + /* integrate error using the trapezoid rule */ + pid_controller->error_integral += + dt * (pid_controller->last_error + error) * 0.5; double diff_error = (error - pid_controller->last_error) / dt; + /* calculate derivative of control value vs time */ + double dc_dt = pid_controller->gain_p * error + + pid_controller->gain_i * pid_controller->error_integral + + pid_controller->gain_d * diff_error; + double new_control_value = pid_controller->last_control_value + + dt * (pid_controller->last_dc_dt + dc_dt) * 0.5; pid_controller->last_error = error; - return dt * (pid_controller->gain_p * error + - pid_controller->gain_i * pid_controller->error_integral + - pid_controller->gain_d * diff_error); + pid_controller->last_dc_dt = dc_dt; + pid_controller->last_control_value = new_control_value; + return new_control_value; +} + +double grpc_pid_controller_last(grpc_pid_controller *pid_controller) { + return pid_controller->last_control_value; } diff --git a/src/core/lib/transport/pid_controller.h b/src/core/lib/transport/pid_controller.h index 059b5b0834..dd2b120052 100644 --- a/src/core/lib/transport/pid_controller.h +++ b/src/core/lib/transport/pid_controller.h @@ -47,18 +47,24 @@ typedef struct { double gain_d; double last_error; double error_integral; + double last_control_value; + double last_dc_dt; } grpc_pid_controller; /** Initialize the controller */ void grpc_pid_controller_init(grpc_pid_controller *pid_controller, - double gain_p, double gain_i, double gain_d); + double initial_control_value, double gain_p, + double gain_i, double gain_d); /** Reset the controller: useful when things have changed significantly */ void grpc_pid_controller_reset(grpc_pid_controller *pid_controller); /** Update the controller: given a current error estimate, and the time since - the last update, returns a delta to the control value */ + the last update, returns a new control value */ double grpc_pid_controller_update(grpc_pid_controller *pid_controller, double error, double dt); +/** Returns the last control value calculated */ +double grpc_pid_controller_last(grpc_pid_controller *pid_controller); + #endif diff --git a/test/core/transport/pid_controller_test.c b/test/core/transport/pid_controller_test.c index 9614983b00..3935a25322 100644 --- a/test/core/transport/pid_controller_test.c +++ b/test/core/transport/pid_controller_test.c @@ -45,7 +45,7 @@ static void test_noop(void) { gpr_log(GPR_INFO, "test_noop"); grpc_pid_controller pid; - grpc_pid_controller_init(&pid, 1, 1, 1); + grpc_pid_controller_init(&pid, 0, 1, 1, 1); } static void test_simple_convergence(double gain_p, double gain_i, double gain_d, @@ -55,15 +55,14 @@ static void test_simple_convergence(double gain_p, double gain_i, double gain_d, "start=%lf", gain_p, gain_i, gain_d, dt, set_point, start); grpc_pid_controller pid; - grpc_pid_controller_init(&pid, 0.2, 0.1, 0.1); - - double current = start; + grpc_pid_controller_init(&pid, start, 0.2, 0.1, 0.1); for (int i = 0; i < 1000; i++) { - current += grpc_pid_controller_update(&pid, set_point - current, 1); + grpc_pid_controller_update(&pid, set_point - grpc_pid_controller_last(&pid), + 1); } - GPR_ASSERT(fabs(set_point - current) < 0.1); + GPR_ASSERT(fabs(set_point - grpc_pid_controller_last(&pid)) < 0.1); GPR_ASSERT(fabs(pid.error_integral) < 0.1); } -- cgit v1.2.3 From 5ed702b78ce405cc33a7bdf69d2a35eabd5f61f8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Jan 2017 11:14:50 -0800 Subject: Simplify math --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 5f3f3d855b..9be77a432e 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1894,18 +1894,14 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, } int64_t estimate = -1; - double bdp_error = 0.0; if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { - double target = (double)estimate; + double target = log2(estimate); double memory_pressure = grpc_resource_quota_get_memory_pressure( grpc_resource_user_get_quota(grpc_endpoint_get_resource_user(t->ep))); if (memory_pressure > 0.8) { target *= 1 - GPR_MIN(1, (memory_pressure - 0.8) / 0.1); } - bdp_error = - target > 0 - ? log2(target) - grpc_pid_controller_last(&t->pid_controller) - : GPR_MIN(0, -grpc_pid_controller_last(&t->pid_controller)); + double bdp_error = target - grpc_pid_controller_last(&t->pid_controller); gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; -- cgit v1.2.3 From 88d81bffd181d047eefd131acde8b018ee85671b Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Jan 2017 11:16:06 -0800 Subject: Fix cast --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 9be77a432e..816b76cb83 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1895,7 +1895,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, int64_t estimate = -1; if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { - double target = log2(estimate); + double target = log2((double)estimate); double memory_pressure = grpc_resource_quota_get_memory_pressure( grpc_resource_user_get_quota(grpc_endpoint_get_resource_user(t->ep))); if (memory_pressure > 0.8) { -- cgit v1.2.3 From 68c9dbe69414bb19e0d810304c48dc417d82a4c8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Jan 2017 11:31:34 -0800 Subject: Add clamping to pid controller, make arguments more readable --- .../transport/chttp2/transport/chttp2_transport.c | 10 +++++++++- src/core/lib/transport/pid_controller.c | 23 +++++++++++++--------- src/core/lib/transport/pid_controller.h | 11 +++++++++-- test/core/transport/pid_controller_test.c | 19 ++++++++++++++++-- 4 files changed, 49 insertions(+), 14 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 816b76cb83..c07b51d35f 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -252,7 +252,15 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_bdp_estimator_init(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); t->last_pid_update = t->last_bdp_ping_finished; - grpc_pid_controller_init(&t->pid_controller, log2(DEFAULT_WINDOW), 4, 4, 0); + grpc_pid_controller_init( + &t->pid_controller, + (grpc_pid_controller_args){.gain_p = 4, + .gain_i = 8, + .gain_d = 0, + .initial_control_value = log2(DEFAULT_WINDOW), + .min_control_value = -1, + .max_control_value = 22, + .integral_range = 10}); grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(&t->hpack_parser); diff --git a/src/core/lib/transport/pid_controller.c b/src/core/lib/transport/pid_controller.c index ba56874503..3a4845d7ef 100644 --- a/src/core/lib/transport/pid_controller.c +++ b/src/core/lib/transport/pid_controller.c @@ -32,14 +32,12 @@ */ #include "src/core/lib/transport/pid_controller.h" +#include void grpc_pid_controller_init(grpc_pid_controller *pid_controller, - double initial_control_value, double gain_p, - double gain_i, double gain_d) { - pid_controller->last_control_value = initial_control_value; - pid_controller->gain_p = gain_p; - pid_controller->gain_i = gain_i; - pid_controller->gain_d = gain_d; + grpc_pid_controller_args args) { + pid_controller->args = args; + pid_controller->last_control_value = args.initial_control_value; grpc_pid_controller_reset(pid_controller); } @@ -53,13 +51,20 @@ double grpc_pid_controller_update(grpc_pid_controller *pid_controller, /* integrate error using the trapezoid rule */ pid_controller->error_integral += dt * (pid_controller->last_error + error) * 0.5; + pid_controller->error_integral = GPR_CLAMP( + pid_controller->error_integral, -pid_controller->args.integral_range, + pid_controller->args.integral_range); double diff_error = (error - pid_controller->last_error) / dt; /* calculate derivative of control value vs time */ - double dc_dt = pid_controller->gain_p * error + - pid_controller->gain_i * pid_controller->error_integral + - pid_controller->gain_d * diff_error; + double dc_dt = pid_controller->args.gain_p * error + + pid_controller->args.gain_i * pid_controller->error_integral + + pid_controller->args.gain_d * diff_error; + /* and perform trapezoidal integration */ double new_control_value = pid_controller->last_control_value + dt * (pid_controller->last_dc_dt + dc_dt) * 0.5; + new_control_value = + GPR_CLAMP(new_control_value, pid_controller->args.min_control_value, + pid_controller->args.max_control_value); pid_controller->last_error = error; pid_controller->last_dc_dt = dc_dt; pid_controller->last_control_value = new_control_value; diff --git a/src/core/lib/transport/pid_controller.h b/src/core/lib/transport/pid_controller.h index dd2b120052..1bf2fbc564 100644 --- a/src/core/lib/transport/pid_controller.h +++ b/src/core/lib/transport/pid_controller.h @@ -45,16 +45,23 @@ typedef struct { double gain_p; double gain_i; double gain_d; + double initial_control_value; + double min_control_value; + double max_control_value; + double integral_range; +} grpc_pid_controller_args; + +typedef struct { double last_error; double error_integral; double last_control_value; double last_dc_dt; + grpc_pid_controller_args args; } grpc_pid_controller; /** Initialize the controller */ void grpc_pid_controller_init(grpc_pid_controller *pid_controller, - double initial_control_value, double gain_p, - double gain_i, double gain_d); + grpc_pid_controller_args args); /** Reset the controller: useful when things have changed significantly */ void grpc_pid_controller_reset(grpc_pid_controller *pid_controller); diff --git a/test/core/transport/pid_controller_test.c b/test/core/transport/pid_controller_test.c index 3935a25322..af53d5b8cb 100644 --- a/test/core/transport/pid_controller_test.c +++ b/test/core/transport/pid_controller_test.c @@ -33,6 +33,7 @@ #include "src/core/lib/transport/pid_controller.h" +#include #include #include @@ -45,7 +46,14 @@ static void test_noop(void) { gpr_log(GPR_INFO, "test_noop"); grpc_pid_controller pid; - grpc_pid_controller_init(&pid, 0, 1, 1, 1); + grpc_pid_controller_init( + &pid, (grpc_pid_controller_args){.gain_p = 1, + .gain_i = 1, + .gain_d = 1, + .initial_control_value = 1, + .min_control_value = DBL_MIN, + .max_control_value = DBL_MAX, + .integral_range = DBL_MAX}); } static void test_simple_convergence(double gain_p, double gain_i, double gain_d, @@ -55,7 +63,14 @@ static void test_simple_convergence(double gain_p, double gain_i, double gain_d, "start=%lf", gain_p, gain_i, gain_d, dt, set_point, start); grpc_pid_controller pid; - grpc_pid_controller_init(&pid, start, 0.2, 0.1, 0.1); + grpc_pid_controller_init( + &pid, (grpc_pid_controller_args){.gain_p = gain_p, + .gain_i = gain_i, + .gain_d = gain_d, + .initial_control_value = start, + .min_control_value = DBL_MIN, + .max_control_value = DBL_MAX, + .integral_range = DBL_MAX}); for (int i = 0; i < 1000; i++) { grpc_pid_controller_update(&pid, set_point - grpc_pid_controller_last(&pid), -- cgit v1.2.3 From 1b36a7d4ed2cba1e2cb1b1b0f9d545b55790c688 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Jan 2017 16:19:16 -0800 Subject: Ping rate limiting for HTTP2 --- include/grpc/impl/codegen/grpc_types.h | 9 ++++++++ .../transport/chttp2/transport/chttp2_transport.c | 26 ++++++++++++++++++++-- src/core/ext/transport/chttp2/transport/internal.h | 12 ++++++++++ src/core/ext/transport/chttp2/transport/writing.c | 18 +++++++++++++++ 4 files changed, 63 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 4471ccf745..626668b1c2 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -179,6 +179,15 @@ typedef struct { Larger values give lower CPU usage for large messages, but more head of line blocking for small messages. */ #define GRPC_ARG_HTTP2_MAX_FRAME_SIZE "grpc.http2.max_frame_size" +/** Minimum time (in milliseconds) between successive ping frames being sent */ +#define GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS \ + "grpc.http2.min_time_between_pings_ms" +/** How many pings can we send before needing to send a data frame or header + frame? + (0 indicates that an infinite number of pings can be sent without sending + a data frame or header frame) */ +#define GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA \ + "grpc.http2.max_pings_without_data" /** Default authority to pass if none specified on call construction. A string. * */ #define GRPC_ARG_DEFAULT_AUTHORITY "grpc.default_authority" diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index c07b51d35f..558d588b40 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -133,6 +133,9 @@ static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure *on_initiate, grpc_closure *on_complete); +#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 100 +#define DEFAULT_MAX_PINGS_BETWEEN_DATA 1 + /******************************************************************************* * CONSTRUCTION/DESTRUCTION/REFCOUNTING */ @@ -302,6 +305,12 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, push_setting(exec_ctx, t, GRPC_CHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE, DEFAULT_MAX_HEADER_LIST_SIZE); + t->ping_policy = (grpc_chttp2_repeated_ping_policy){ + .max_pings_without_data = DEFAULT_MAX_PINGS_BETWEEN_DATA, + .min_time_between_pings = + gpr_time_from_millis(DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, GPR_TIMESPAN), + }; + if (channel_args) { for (i = 0; i < channel_args->num_args; i++) { if (0 == strcmp(channel_args->args[i].key, @@ -327,6 +336,19 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_hpack_compressor_set_max_usable_size(&t->hpack_compressor, (uint32_t)value); } + } else if (0 == strcmp(channel_args->args[i].key, + GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA)) { + t->ping_policy.max_pings_without_data = grpc_channel_arg_get_integer( + &channel_args->args[i], + (grpc_integer_options){DEFAULT_MAX_PINGS_BETWEEN_DATA, 0, INT_MAX}); + } else if (0 == strcmp(channel_args->args[i].key, + GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS)) { + t->ping_policy.min_time_between_pings = gpr_time_from_millis( + grpc_channel_arg_get_integer( + &channel_args->args[i], + (grpc_integer_options){DEFAULT_MIN_TIME_BETWEEN_PINGS_MS, 0, + INT_MAX}), + GPR_TIMESPAN); } else { static const struct { const char *channel_arg_name; @@ -1913,8 +1935,8 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); gpr_timespec dt_timespec = gpr_time_sub(now, t->last_pid_update); double dt = (double)dt_timespec.tv_sec + dt_timespec.tv_nsec * 1e-9; - if (dt > 3) { - grpc_pid_controller_reset(&t->pid_controller); + if (dt > 0.1) { + dt = 0.1; } double log2_bdp_guess = grpc_pid_controller_update(&t->pid_controller, bdp_error, dt); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 8b7c040358..3088aa7417 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -93,6 +93,16 @@ typedef struct { uint64_t inflight_id; } grpc_chttp2_ping_queue; +typedef struct { + gpr_timespec min_time_between_pings; + int max_pings_without_data; +} grpc_chttp2_repeated_ping_policy; + +typedef struct { + gpr_timespec last_ping_sent_time; + int pings_before_data_required; +} grpc_chttp2_repeated_ping_state; + /* deframer state for the overall http2 stream of bytes */ typedef enum { /* prefix: one entry per http2 connection prefix byte */ @@ -281,6 +291,8 @@ struct grpc_chttp2_transport { /** ping queues for various ping insertion points */ grpc_chttp2_ping_queue ping_queues[GRPC_CHTTP2_PING_TYPE_COUNT]; + grpc_chttp2_repeated_ping_policy ping_policy; + grpc_chttp2_repeated_ping_state ping_state; uint64_t ping_ctr; /* unique id for pings */ /** parser for headers */ diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 43205a82f6..57648a704d 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -75,6 +75,17 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, /* ping already in-flight: wait */ return; } + if (t->ping_state.pings_before_data_required > 0 && + t->ping_policy.max_pings_without_data != 0) { + /* need to send something of substance before sending a ping again */ + return; + } + gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); + if (gpr_time_cmp(gpr_time_sub(now, t->ping_state.last_ping_sent_time), + t->ping_policy.min_time_between_pings) < 0) { + /* not enough elapsed time between successive pings */ + return; + } /* coalesce equivalent pings into this one */ switch (ping_type) { case GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE: @@ -92,6 +103,9 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, &pq->lists[GRPC_CHTTP2_PCL_INFLIGHT]); grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_ping_create(false, pq->inflight_id)); + t->ping_state.last_ping_sent_time = now; + t->ping_state.pings_before_data_required -= + (t->ping_state.pings_before_data_required != 0); } static void update_list(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, @@ -165,6 +179,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, s->sent_initial_metadata = true; sent_initial_metadata = true; now_writing = true; + t->ping_state.pings_before_data_required = + t->ping_policy.max_pings_without_data; } /* send any window updates */ if (s->announce_window > 0) { @@ -202,6 +218,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, send_bytes); GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", t, outgoing_window, send_bytes); + t->ping_state.pings_before_data_required = + t->ping_policy.max_pings_without_data; if (is_last_frame) { s->send_trailing_metadata = NULL; s->sent_trailing_metadata = true; -- cgit v1.2.3 From c5235d783250d3389d35d36f9894bbe678ccd1cd Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 20 Jan 2017 14:12:30 -0800 Subject: Spam cleanup --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 022f97daf7..13d3fc1c2b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1921,9 +1921,6 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, } double log2_bdp_guess = grpc_pid_controller_update(&t->pid_controller, bdp_error, dt); - gpr_log(GPR_DEBUG, "%s: err=%lf cur=%lf pressure=%lf target=%lf", - t->peer_string, bdp_error, log2_bdp_guess, memory_pressure, - target); update_bdp(exec_ctx, t, pow(2, log2_bdp_guess)); t->last_pid_update = now; } @@ -1942,14 +1939,18 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { grpc_chttp2_transport *t = tp; - gpr_log(GPR_DEBUG, "%s: Start BDP ping", t->peer_string); + if (grpc_http_trace) { + gpr_log(GPR_DEBUG, "%s: Start BDP ping", t->peer_string); + } grpc_bdp_estimator_start_ping(&t->bdp_estimator); } static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_error *error) { grpc_chttp2_transport *t = tp; - gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string); + if (grpc_http_trace) { + gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string); + } grpc_bdp_estimator_complete_ping(&t->bdp_estimator); t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); -- cgit v1.2.3 From 13a875d13eda8d885acd515dab12f8eb6e40f756 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 20 Jan 2017 15:15:13 -0800 Subject: Fix simple tests --- src/core/lib/transport/pid_controller.c | 1 + test/core/transport/bdp_estimator_test.c | 30 ++++++++++++++++++++++++------ test/core/transport/pid_controller_test.c | 6 ++++-- 3 files changed, 29 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/lib/transport/pid_controller.c b/src/core/lib/transport/pid_controller.c index 3a4845d7ef..19cb1c0b36 100644 --- a/src/core/lib/transport/pid_controller.c +++ b/src/core/lib/transport/pid_controller.c @@ -43,6 +43,7 @@ void grpc_pid_controller_init(grpc_pid_controller *pid_controller, void grpc_pid_controller_reset(grpc_pid_controller *pid_controller) { pid_controller->last_error = 0.0; + pid_controller->last_dc_dt = 0.0; pid_controller->error_integral = 0.0; } diff --git a/test/core/transport/bdp_estimator_test.c b/test/core/transport/bdp_estimator_test.c index af011abf8f..1272c74b51 100644 --- a/test/core/transport/bdp_estimator_test.c +++ b/test/core/transport/bdp_estimator_test.c @@ -51,12 +51,14 @@ static void test_get_estimate_no_samples(void) { gpr_log(GPR_INFO, "test_get_estimate_no_samples"); grpc_bdp_estimator est; grpc_bdp_estimator_init(&est); - GPR_ASSERT(!grpc_bdp_estimator_get_estimate(&est, NULL)); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); } static void add_samples(grpc_bdp_estimator *estimator, int64_t *samples, size_t n) { GPR_ASSERT(grpc_bdp_estimator_add_incoming_bytes(estimator, 1234567) == true); + grpc_bdp_estimator_schedule_ping(estimator); grpc_bdp_estimator_start_ping(estimator); for (size_t i = 0; i < n; i++) { GPR_ASSERT(grpc_bdp_estimator_add_incoming_bytes(estimator, samples[i]) == @@ -74,7 +76,8 @@ static void test_get_estimate_1_sample(void) { grpc_bdp_estimator est; grpc_bdp_estimator_init(&est); add_sample(&est, 100); - GPR_ASSERT(!grpc_bdp_estimator_get_estimate(&est, NULL)); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); } static void test_get_estimate_2_samples(void) { @@ -83,7 +86,8 @@ static void test_get_estimate_2_samples(void) { grpc_bdp_estimator_init(&est); add_sample(&est, 100); add_sample(&est, 100); - GPR_ASSERT(!grpc_bdp_estimator_get_estimate(&est, NULL)); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); } static int64_t get_estimate(grpc_bdp_estimator *estimator) { @@ -99,7 +103,20 @@ static void test_get_estimate_3_samples(void) { add_sample(&est, 100); add_sample(&est, 100); add_sample(&est, 100); - GPR_ASSERT(get_estimate(&est) == 100); + int64_t estimate; + grpc_bdp_estimator_get_estimate(&est, &estimate); +} + +static int64_t next_pow_2(int64_t v) { + v--; + v |= v >> 1; + v |= v >> 2; + v |= v >> 4; + v |= v >> 8; + v |= v >> 16; + v |= v >> 32; + v++; + return v; } static void test_get_estimate_random_values(size_t n) { @@ -114,8 +131,9 @@ static void test_get_estimate_random_values(size_t n) { if (sample > max) max = sample; add_sample(&est, sample); if (i >= 3) { - GPR_ASSERT(get_estimate(&est) <= max); - GPR_ASSERT(get_estimate(&est) >= min); + gpr_log(GPR_DEBUG, "est:%" PRId64 " min:%d max:%d", get_estimate(&est), + min, max); + GPR_ASSERT(get_estimate(&est) <= 2 * next_pow_2(max)); } } } diff --git a/test/core/transport/pid_controller_test.c b/test/core/transport/pid_controller_test.c index af53d5b8cb..831343c815 100644 --- a/test/core/transport/pid_controller_test.c +++ b/test/core/transport/pid_controller_test.c @@ -72,13 +72,15 @@ static void test_simple_convergence(double gain_p, double gain_i, double gain_d, .max_control_value = DBL_MAX, .integral_range = DBL_MAX}); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100000; i++) { grpc_pid_controller_update(&pid, set_point - grpc_pid_controller_last(&pid), 1); } GPR_ASSERT(fabs(set_point - grpc_pid_controller_last(&pid)) < 0.1); - GPR_ASSERT(fabs(pid.error_integral) < 0.1); + if (gain_i > 0) { + GPR_ASSERT(fabs(pid.error_integral) < 0.1); + } } int main(int argc, char **argv) { -- cgit v1.2.3 From 52e5f68f87fcc05d84be55d88afc6bfe146d36e6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 26 Jan 2017 16:47:25 -0800 Subject: Be more lazy about stream flow control updates --- .../ext/transport/chttp2/transport/chttp2_transport.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index d617ecd52b..faab87bf4c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -135,8 +135,8 @@ static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure *on_initiate, grpc_closure *on_complete); -#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 100 -#define DEFAULT_MAX_PINGS_BETWEEN_DATA 1 +#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 10 +#define DEFAULT_MAX_PINGS_BETWEEN_DATA 3 /******************************************************************************* * CONSTRUCTION/DESTRUCTION/REFCOUNTING @@ -2071,13 +2071,20 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, (uint32_t)(max_recv_bytes - s->incoming_window_delta); bool new_window_write_is_covered_by_poller = s->incoming_window_delta + initial_window_size < (int64_t)have_already; + bool force_send = (s->incoming_window_delta - s->announce_window < + -(int64_t)initial_window_size / 2); + /* gpr_log(GPR_DEBUG, "%d %d %d", + (int)(s->incoming_window_delta - s->announce_window), + (int)(-(int64_t)initial_window_size / 2), force_send); */ GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, incoming_window_delta, add_max_recv_bytes); GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, announce_window, add_max_recv_bytes); - grpc_chttp2_become_writable(exec_ctx, t, s, - new_window_write_is_covered_by_poller, - "read_incoming_stream"); + if (force_send) { + grpc_chttp2_become_writable(exec_ctx, t, s, + new_window_write_is_covered_by_poller, + "read_incoming_stream"); + } } } -- cgit v1.2.3 From 277eb9ea3ba6059873cf6b5cede2fc3306c14bae Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Jan 2017 06:51:09 -0800 Subject: Be more lazy about stream flow control updates --- src/core/ext/transport/chttp2/transport/parsing.c | 7 ++++++- src/core/ext/transport/chttp2/transport/writing.c | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 4373391e44..08472a46ab 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -375,9 +375,14 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, return err; } + uint32_t target_incoming_window = GPR_MAX( + t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], + 1024); GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("parse", t, incoming_window, incoming_frame_size); - grpc_chttp2_initiate_write(exec_ctx, t, false, "flow_control"); + if (t->incoming_window < target_incoming_window / 2) { + grpc_chttp2_initiate_write(exec_ctx, t, false, "flow_control"); + } if (s != NULL) { if (incoming_frame_size > diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 3f25eca239..5df979d59a 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -295,7 +295,10 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, uint32_t target_incoming_window = GPR_MAX( t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], 1024); - if (t->incoming_window < 3 * target_incoming_window / 4) { + uint32_t threshold_to_send_transport_window_update = + t->outbuf.count > 0 ? target_incoming_window + : 3 * target_incoming_window / 4; + if (t->incoming_window < threshold_to_send_transport_window_update) { maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); uint32_t announced = (uint32_t)GPR_CLAMP( -- cgit v1.2.3 From 80ccebb2e16355666809eb5368751683149eb6a8 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Jan 2017 09:04:21 -0800 Subject: Target 2x BDP --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index faab87bf4c..17ed3a2dcb 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -135,7 +135,7 @@ static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure *on_initiate, grpc_closure *on_complete); -#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 10 +#define DEFAULT_MIN_TIME_BETWEEN_PINGS_MS 0 #define DEFAULT_MAX_PINGS_BETWEEN_DATA 3 /******************************************************************************* @@ -1946,7 +1946,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, int64_t estimate = -1; if (grpc_bdp_estimator_get_estimate(&t->bdp_estimator, &estimate)) { - double target = log2((double)estimate); + double target = 1 + log2((double)estimate); double memory_pressure = grpc_resource_quota_get_memory_pressure( grpc_resource_user_quota(grpc_endpoint_get_resource_user(t->ep))); if (memory_pressure > 0.8) { -- cgit v1.2.3 From 1d7d12370edbb31e77dbed28e785aac748d99f90 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Jan 2017 10:44:05 -0800 Subject: Better ping mgmt --- src/core/ext/transport/chttp2/transport/frame_ping.c | 7 +++++-- src/core/ext/transport/chttp2/transport/internal.h | 5 +++++ src/core/ext/transport/chttp2/transport/writing.c | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 66a9bc0966..20bc3107ce 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -101,8 +101,11 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, if (p->is_ack) { grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes); } else { - grpc_slice_buffer_add(&t->qbuf, - grpc_chttp2_ping_create(1, p->opaque_8bytes)); + if (t->ping_ack_count == t->ping_ack_capacity) { + t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3); + t->ping_acks = gpr_realloc(t->ping_acks, t->ping_ack_capacity); + } + t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes; grpc_chttp2_initiate_write(exec_ctx, t, false, "ping response"); } } diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index dfcb296ba3..6003eebe8d 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -303,6 +303,11 @@ struct grpc_chttp2_transport { grpc_chttp2_repeated_ping_state ping_state; uint64_t ping_ctr; /* unique id for pings */ + /** ping acks */ + size_t ping_ack_count; + size_t ping_ack_capacity; + uint64_t *ping_acks; + /** parser for headers */ grpc_chttp2_hpack_parser hpack_parser; /** simple one shot parsers */ diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 5df979d59a..343bc7aaae 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -74,17 +74,22 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, } if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { /* ping already in-flight: wait */ + gpr_log(GPR_DEBUG, "already pinging"); return; } - if (t->ping_state.pings_before_data_required > 0 && + if (t->ping_state.pings_before_data_required == 0 && t->ping_policy.max_pings_without_data != 0) { /* need to send something of substance before sending a ping again */ + gpr_log(GPR_DEBUG, "too many pings: %d/%d", + t->ping_state.pings_before_data_required, + t->ping_policy.max_pings_without_data); return; } gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); if (gpr_time_cmp(gpr_time_sub(now, t->ping_state.last_ping_sent_time), t->ping_policy.min_time_between_pings) < 0) { /* not enough elapsed time between successive pings */ + gpr_log(GPR_DEBUG, "not enough time"); return; } /* coalesce equivalent pings into this one */ @@ -201,6 +206,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( s->id, s->announce_window, &s->stats.outgoing)); + t->ping_state.pings_before_data_required = + t->ping_policy.max_pings_without_data; GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, announce_window, announce); } if (sent_initial_metadata) { @@ -290,6 +297,12 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, } } + for (size_t i = 0; i < t->ping_ack_count; i++) { + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(1, t->ping_acks[i])); + } + t->ping_ack_count = 0; + /* if the grpc_chttp2_transport is ready to send a window update, do so here also; 3/4 is a magic number that will likely get tuned soon */ uint32_t target_incoming_window = GPR_MAX( @@ -307,6 +320,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, grpc_transport_one_way_stats throwaway_stats; grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( 0, announced, &throwaway_stats)); + t->ping_state.pings_before_data_required = + t->ping_policy.max_pings_without_data; } maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); -- cgit v1.2.3 From efbd7c2a0f82af841ad79998645e3729dee9676d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Jan 2017 14:07:44 -0800 Subject: Bug fixes, tracing for bdp estimation --- doc/environment_variables.md | 5 ++- .../transport/chttp2/transport/chttp2_transport.c | 15 ++------ .../ext/transport/chttp2/transport/frame_data.c | 2 - src/core/ext/transport/chttp2/transport/internal.h | 3 -- src/core/ext/transport/chttp2/transport/writing.c | 45 ++++++++++++++-------- src/core/lib/surface/init.c | 2 + src/core/lib/transport/bdp_estimator.c | 26 +++++++++++-- src/core/lib/transport/bdp_estimator.h | 5 ++- test/core/util/passthru_endpoint.c | 4 +- 9 files changed, 67 insertions(+), 40 deletions(-) (limited to 'src/core') diff --git a/doc/environment_variables.md b/doc/environment_variables.md index 832762a5f5..3bcbd82130 100644 --- a/doc/environment_variables.md +++ b/doc/environment_variables.md @@ -35,6 +35,7 @@ some configuration as environment variables that can be set. A comma separated list of tracers that provide additional insight into how gRPC C core is processing requests via debug logs. Available tracers include: - api - traces api calls to the C core + - bdp_estimator - traces behavior of bdp estimation logic - channel - traces operations on the C core channel stack - combiner - traces combiner lock state - compression - traces compression operations @@ -55,10 +56,10 @@ some configuration as environment variables that can be set. - secure_endpoint - traces bytes flowing through encrypted channels - transport_security - traces metadata about secure channel establishment - tcp - traces bytes in and out of a channel - + 'all' can additionally be used to turn all traces on. Individual traces can be disabled by prefixing them with '-'. - + Example: export GRPC_TRACE=all,-pending_tags diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 17ed3a2dcb..f60256ae2d 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -254,9 +254,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_closure_init(&t->finish_bdp_ping_locked, finish_bdp_ping_locked, t, grpc_combiner_scheduler(t->combiner, false)); - grpc_bdp_estimator_init(&t->bdp_estimator); - t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); - t->last_pid_update = t->last_bdp_ping_finished; + grpc_bdp_estimator_init(&t->bdp_estimator, t->peer_string); + t->last_pid_update = gpr_now(GPR_CLOCK_MONOTONIC); grpc_pid_controller_init( &t->pid_controller, (grpc_pid_controller_args){.gain_p = 4, @@ -1887,10 +1886,6 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, errors[1] = grpc_chttp2_perform_read(exec_ctx, t, t->read_buffer.slices[i]); } - if (!t->parse_saw_data_frames) { - need_bdp_ping = false; - } - t->parse_saw_data_frames = false; if (errors[1] != GRPC_ERROR_NONE) { errors[2] = try_http_parsing(exec_ctx, t); GRPC_ERROR_UNREF(error); @@ -1933,10 +1928,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer, &t->read_action_locked); - if (need_bdp_ping && - gpr_time_cmp(gpr_time_add(t->last_bdp_ping_finished, - gpr_time_from_millis(100, GPR_TIMESPAN)), - gpr_now(GPR_CLOCK_MONOTONIC)) < 0) { + if (need_bdp_ping) { GRPC_CHTTP2_REF_TRANSPORT(t, "bdp_ping"); grpc_bdp_estimator_schedule_ping(&t->bdp_estimator); send_ping_locked(exec_ctx, t, @@ -1992,7 +1984,6 @@ static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp, gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string); } grpc_bdp_estimator_complete_ping(&t->bdp_estimator); - t->last_bdp_ping_finished = gpr_now(GPR_CLOCK_MONOTONIC); GRPC_CHTTP2_UNREF_TRANSPORT(exec_ctx, t, "bdp_ping"); } diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.c index 4562983e7c..f9b9e1b309 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.c +++ b/src/core/ext/transport/chttp2/transport/frame_data.c @@ -156,8 +156,6 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, return GRPC_ERROR_NONE; } - t->parse_saw_data_frames = true; - switch (p->state) { case GRPC_CHTTP2_DATA_ERROR: p->state = GRPC_CHTTP2_DATA_ERROR; diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 6003eebe8d..b9474a92e7 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -322,8 +322,6 @@ struct grpc_chttp2_transport { /** initial window change */ int64_t initial_window_update; - /** did the current parse see actual data bytes? */ - bool parse_saw_data_frames; /** window available for peer to send to us */ int64_t incoming_window; @@ -357,7 +355,6 @@ struct grpc_chttp2_transport { grpc_pid_controller pid_controller; grpc_closure start_bdp_ping_locked; grpc_closure finish_bdp_ping_locked; - gpr_timespec last_bdp_ping_finished; gpr_timespec last_pid_update; /* if non-NULL, close the transport with this error when writes are finished diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 343bc7aaae..438a062d10 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -74,22 +74,33 @@ static void maybe_initiate_ping(grpc_exec_ctx *exec_ctx, } if (!grpc_closure_list_empty(pq->lists[GRPC_CHTTP2_PCL_INFLIGHT])) { /* ping already in-flight: wait */ - gpr_log(GPR_DEBUG, "already pinging"); + if (grpc_http_trace || grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, "Ping delayed [%p]: already pinging", t->peer_string); + } return; } if (t->ping_state.pings_before_data_required == 0 && t->ping_policy.max_pings_without_data != 0) { /* need to send something of substance before sending a ping again */ - gpr_log(GPR_DEBUG, "too many pings: %d/%d", - t->ping_state.pings_before_data_required, - t->ping_policy.max_pings_without_data); + if (grpc_http_trace || grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, "Ping delayed [%p]: too many recent pings: %d/%d", + t->peer_string, t->ping_state.pings_before_data_required, + t->ping_policy.max_pings_without_data); + } return; } gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); - if (gpr_time_cmp(gpr_time_sub(now, t->ping_state.last_ping_sent_time), - t->ping_policy.min_time_between_pings) < 0) { + gpr_timespec elapsed = gpr_time_sub(now, t->ping_state.last_ping_sent_time); + /*gpr_log(GPR_DEBUG, "elapsed:%d.%09d min:%d.%09d", (int)elapsed.tv_sec, + elapsed.tv_nsec, (int)t->ping_policy.min_time_between_pings.tv_sec, + (int)t->ping_policy.min_time_between_pings.tv_nsec);*/ + if (gpr_time_cmp(elapsed, t->ping_policy.min_time_between_pings) < 0) { /* not enough elapsed time between successive pings */ - gpr_log(GPR_DEBUG, "not enough time"); + if (grpc_http_trace || grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, + "Ping delayed [%p]: not enough time elapsed since last ping", + t->peer_string); + } return; } /* coalesce equivalent pings into this one */ @@ -297,20 +308,14 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, } } - for (size_t i = 0; i < t->ping_ack_count; i++) { - grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_ping_create(1, t->ping_acks[i])); - } - t->ping_ack_count = 0; - /* if the grpc_chttp2_transport is ready to send a window update, do so here also; 3/4 is a magic number that will likely get tuned soon */ uint32_t target_incoming_window = GPR_MAX( t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE], 1024); uint32_t threshold_to_send_transport_window_update = - t->outbuf.count > 0 ? target_incoming_window - : 3 * target_incoming_window / 4; + t->outbuf.count > 0 ? 3 * target_incoming_window / 4 + : target_incoming_window / 2; if (t->incoming_window < threshold_to_send_transport_window_update) { maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); @@ -324,7 +329,15 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, t->ping_policy.max_pings_without_data; } - maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); + for (size_t i = 0; i < t->ping_ack_count; i++) { + grpc_slice_buffer_add(&t->outbuf, + grpc_chttp2_ping_create(1, t->ping_acks[i])); + } + t->ping_ack_count = 0; + + if (t->outbuf.count > 0) { + maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); + } GPR_TIMER_END("grpc_chttp2_begin_write", 0); diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index f61bf1582e..cf721be896 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -62,6 +62,7 @@ #include "src/core/lib/surface/init.h" #include "src/core/lib/surface/lame_client.h" #include "src/core/lib/surface/server.h" +#include "src/core/lib/transport/bdp_estimator.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/transport_impl.h" @@ -190,6 +191,7 @@ void grpc_init(void) { grpc_register_tracer("queue_pluck", &grpc_cq_pluck_trace); grpc_register_tracer("combiner", &grpc_combiner_trace); grpc_register_tracer("server_channel", &grpc_server_channel_trace); + grpc_register_tracer("bdp_estimator", &grpc_bdp_estimator_trace); // Default pluck trace to 1 grpc_cq_pluck_trace = 1; grpc_register_tracer("queue_timeout", &grpc_cq_event_timeout_trace); diff --git a/src/core/lib/transport/bdp_estimator.c b/src/core/lib/transport/bdp_estimator.c index 90e4332023..e1483677fd 100644 --- a/src/core/lib/transport/bdp_estimator.c +++ b/src/core/lib/transport/bdp_estimator.c @@ -38,9 +38,12 @@ #include #include -void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator) { +int grpc_bdp_estimator_trace = 0; + +void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name) { estimator->estimate = 65536; estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; + estimator->name = name; } bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, @@ -51,34 +54,51 @@ bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, bool grpc_bdp_estimator_add_incoming_bytes(grpc_bdp_estimator *estimator, int64_t num_bytes) { + estimator->accumulator += num_bytes; switch (estimator->ping_state) { case GRPC_BDP_PING_UNSCHEDULED: return true; case GRPC_BDP_PING_SCHEDULED: return false; case GRPC_BDP_PING_STARTED: - estimator->accumulator += num_bytes; return false; } GPR_UNREACHABLE_CODE(return false); } void grpc_bdp_estimator_schedule_ping(grpc_bdp_estimator *estimator) { + if (grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, + estimator->name, estimator->accumulator, estimator->estimate); + } GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_UNSCHEDULED); estimator->ping_state = GRPC_BDP_PING_SCHEDULED; + estimator->accumulator = 0; } void grpc_bdp_estimator_start_ping(grpc_bdp_estimator *estimator) { + if (grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, + estimator->name, estimator->accumulator, estimator->estimate); + } GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_SCHEDULED); estimator->ping_state = GRPC_BDP_PING_STARTED; estimator->accumulator = 0; } void grpc_bdp_estimator_complete_ping(grpc_bdp_estimator *estimator) { + if (grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, "bdp[%s]:complete acc=%" PRId64 " est=%" PRId64, + estimator->name, estimator->accumulator, estimator->estimate); + } GPR_ASSERT(estimator->ping_state == GRPC_BDP_PING_STARTED); if (estimator->accumulator > 2 * estimator->estimate / 3) { estimator->estimate *= 2; - gpr_log(GPR_DEBUG, "est --> %" PRId64, estimator->estimate); + if (grpc_bdp_estimator_trace) { + gpr_log(GPR_DEBUG, "bdp[%s]: estimate increased to %" PRId64, + estimator->name, estimator->estimate); + } } estimator->ping_state = GRPC_BDP_PING_UNSCHEDULED; + estimator->accumulator = 0; } diff --git a/src/core/lib/transport/bdp_estimator.h b/src/core/lib/transport/bdp_estimator.h index ea74f2b5d5..bcaf899910 100644 --- a/src/core/lib/transport/bdp_estimator.h +++ b/src/core/lib/transport/bdp_estimator.h @@ -40,6 +40,8 @@ #define GRPC_BDP_SAMPLES 16 #define GRPC_BDP_MIN_SAMPLES_FOR_ESTIMATE 3 +extern int grpc_bdp_estimator_trace; + typedef enum { GRPC_BDP_PING_UNSCHEDULED, GRPC_BDP_PING_SCHEDULED, @@ -50,9 +52,10 @@ typedef struct grpc_bdp_estimator { grpc_bdp_estimator_ping_state ping_state; int64_t accumulator; int64_t estimate; + const char *name; } grpc_bdp_estimator; -void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator); +void grpc_bdp_estimator_init(grpc_bdp_estimator *estimator, const char *name); // Returns true if a reasonable estimate could be obtained bool grpc_bdp_estimator_get_estimate(grpc_bdp_estimator *estimator, diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c index 96f541abe9..686f406b0a 100644 --- a/test/core/util/passthru_endpoint.c +++ b/test/core/util/passthru_endpoint.c @@ -148,7 +148,9 @@ static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { } static char *me_get_peer(grpc_endpoint *ep) { - return gpr_strdup("fake:mock_endpoint"); + passthru_endpoint *p = ((half *)ep)->parent; + return ((half *)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint") + : gpr_strdup("fake:mock_server_endpoint"); } static int me_get_fd(grpc_endpoint *ep) { return -1; } -- cgit v1.2.3 From adc003a4809ac5f3fe9c83291167320a43935c81 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Jan 2017 14:26:32 -0800 Subject: Fix validation, stream window update edge triggering --- src/core/ext/transport/chttp2/transport/parsing.c | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index a5eda66e0d..71161f77a0 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -385,25 +385,28 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, grpc_chttp2_initiate_write(exec_ctx, t, false, "flow_control"); } - if (s != NULL) { - if (incoming_frame_size > - s->incoming_window_delta + - t->settings[GRPC_ACKED_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]) { - char *msg; - gpr_asprintf(&msg, - "frame of size %d overflows incoming window of %" PRId64, - t->incoming_frame_size, - s->incoming_window_delta + - t->settings[GRPC_ACKED_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); - grpc_error *err = GRPC_ERROR_CREATE(msg); - gpr_free(msg); - return err; - } + if (incoming_frame_size > + s->incoming_window_delta + + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]) { + char *msg; + gpr_asprintf(&msg, "frame of size %d overflows incoming window of %" PRId64, + t->incoming_frame_size, + s->incoming_window_delta + + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); + grpc_error *err = GRPC_ERROR_CREATE(msg); + gpr_free(msg); + return err; + } + if (s != NULL) { GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); + if (s->incoming_window_delta < -target_incoming_window / 2) { + grpc_chttp2_become_writable(exec_ctx, t, s, false, + "window-update-required"); + } s->received_bytes += incoming_frame_size; } -- cgit v1.2.3 From 75bcb608c51c438303407b703105a8fa2cafb8a2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 27 Jan 2017 15:32:31 -0800 Subject: Fix bugs with TCP --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 +- src/core/ext/transport/chttp2/transport/parsing.c | 5 +++-- src/core/ext/transport/chttp2/transport/writing.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 26c4a5fe13..c1d2bb2227 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -2022,7 +2022,7 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, (uint32_t)(max_recv_bytes - s->incoming_window_delta); bool new_window_write_is_covered_by_poller = s->incoming_window_delta + initial_window_size < (int64_t)have_already; - bool force_send = (s->incoming_window_delta - s->announce_window < + bool force_send = (s->incoming_window_delta - s->announce_window <= -(int64_t)initial_window_size / 2); /* gpr_log(GPR_DEBUG, "%d %d %d", (int)(s->incoming_window_delta - s->announce_window), diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 71161f77a0..7e8ca55e83 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -381,7 +381,7 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, 1024); GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("parse", t, incoming_window, incoming_frame_size); - if (t->incoming_window < target_incoming_window / 2) { + if (t->incoming_window <= target_incoming_window / 2) { grpc_chttp2_initiate_write(exec_ctx, t, false, "flow_control"); } @@ -403,7 +403,8 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, if (s != NULL) { GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); - if (s->incoming_window_delta < -target_incoming_window / 2) { + if (s->incoming_window_delta - s->announce_window <= + -(int64_t)target_incoming_window / 2) { grpc_chttp2_become_writable(exec_ctx, t, s, false, "window-update-required"); } diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 1ff467b33d..3cb4841336 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -316,7 +316,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, uint32_t threshold_to_send_transport_window_update = t->outbuf.count > 0 ? 3 * target_incoming_window / 4 : target_incoming_window / 2; - if (t->incoming_window < threshold_to_send_transport_window_update) { + if (t->incoming_window <= threshold_to_send_transport_window_update) { maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_BEFORE_TRANSPORT_WINDOW_UPDATE); uint32_t announced = (uint32_t)GPR_CLAMP( -- cgit v1.2.3 From 2cf2c5ae0ce15cf4b65451ca4821ab1ddbcab355 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 30 Jan 2017 09:49:31 -0800 Subject: Fix failures in fuzzing tests --- .../transport/chttp2/transport/chttp2_transport.c | 1 + .../ext/transport/chttp2/transport/frame_ping.c | 2 +- src/core/ext/transport/chttp2/transport/parsing.c | 31 +++++++++++----------- 3 files changed, 18 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 8d29798a7f..de67794f5b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -178,6 +178,7 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx, t->write_cb_pool = next; } + gpr_free(t->ping_acks); gpr_free(t->peer_string); gpr_free(t); } diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 20bc3107ce..7cf36cb94a 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -103,7 +103,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, } else { if (t->ping_ack_count == t->ping_ack_capacity) { t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3); - t->ping_acks = gpr_realloc(t->ping_acks, t->ping_ack_capacity); + t->ping_acks = gpr_realloc(t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks)); } t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes; grpc_chttp2_initiate_write(exec_ctx, t, false, "ping response"); diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 7e8ca55e83..ca9b931564 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -385,22 +385,23 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, grpc_chttp2_initiate_write(exec_ctx, t, false, "flow_control"); } - if (incoming_frame_size > - s->incoming_window_delta + - t->settings[GRPC_ACKED_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]) { - char *msg; - gpr_asprintf(&msg, "frame of size %d overflows incoming window of %" PRId64, - t->incoming_frame_size, - s->incoming_window_delta + - t->settings[GRPC_ACKED_SETTINGS] - [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); - grpc_error *err = GRPC_ERROR_CREATE(msg); - gpr_free(msg); - return err; - } - if (s != NULL) { + if (incoming_frame_size > + s->incoming_window_delta + + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]) { + char *msg; + gpr_asprintf(&msg, + "frame of size %d overflows incoming window of %" PRId64, + t->incoming_frame_size, + s->incoming_window_delta + + t->settings[GRPC_ACKED_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]); + grpc_error *err = GRPC_ERROR_CREATE(msg); + gpr_free(msg); + return err; + } + GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); if (s->incoming_window_delta - s->announce_window <= -- cgit v1.2.3 From fa0579511b21cb7e75b01469678f154f4e1c4033 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 30 Jan 2017 10:16:02 -0800 Subject: Fix bugs --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 ++ src/core/ext/transport/chttp2/transport/frame_ping.c | 3 ++- src/core/ext/transport/chttp2/transport/writing.c | 4 +--- test/core/end2end/tests/ping.c | 12 ++++++++---- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index de67794f5b..d7cc7314c3 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -406,6 +406,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, } } + t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; + grpc_chttp2_initiate_write(exec_ctx, t, false, "init"); post_benign_reclaimer(exec_ctx, t); } diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 7cf36cb94a..f487533c41 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -103,7 +103,8 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, } else { if (t->ping_ack_count == t->ping_ack_capacity) { t->ping_ack_capacity = GPR_MAX(t->ping_ack_capacity * 3 / 2, 3); - t->ping_acks = gpr_realloc(t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks)); + t->ping_acks = gpr_realloc( + t->ping_acks, t->ping_ack_capacity * sizeof(*t->ping_acks)); } t->ping_acks[t->ping_ack_count++] = p->opaque_8bytes; grpc_chttp2_initiate_write(exec_ctx, t, false, "ping response"); diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 3cb4841336..05e6f59947 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -335,9 +335,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, } t->ping_ack_count = 0; - if (t->outbuf.count > 0) { - maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); - } + maybe_initiate_ping(exec_ctx, t, GRPC_CHTTP2_PING_ON_NEXT_WRITE); GPR_TIMER_END("grpc_chttp2_begin_write", 0); diff --git a/test/core/end2end/tests/ping.c b/test/core/end2end/tests/ping.c index 0d404229a5..8c89f6c220 100644 --- a/test/core/end2end/tests/ping.c +++ b/test/core/end2end/tests/ping.c @@ -37,6 +37,7 @@ #include #include #include +#include #include "test/core/end2end/cq_verifier.h" @@ -48,10 +49,13 @@ static void test_ping(grpc_end2end_test_config config) { grpc_connectivity_state state = GRPC_CHANNEL_IDLE; int i; - grpc_arg a = {.type = GRPC_ARG_INTEGER, - .key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS, - .value.integer = 0}; - grpc_channel_args client_args = {.num_args = 1, .args = &a}; + grpc_arg a[] = {{.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_HTTP2_MIN_TIME_BETWEEN_PINGS_MS, + .value.integer = 0}, + {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_HTTP2_MAX_PINGS_WITHOUT_DATA, + .value.integer = 20}}; + grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(a), .args = a}; config.init_client(&f, &client_args); config.init_server(&f, NULL); -- cgit v1.2.3 From 1a5ead340558e8491c0a1fec74129413cfe5888a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 30 Jan 2017 14:27:21 -0800 Subject: Accept and count deadline exceeded --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 3 ++- test/core/end2end/tests/resource_quota_server.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index d7cc7314c3..692eb3f902 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -406,7 +406,8 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, } } - t->ping_state.pings_before_data_required = t->ping_policy.max_pings_without_data; + t->ping_state.pings_before_data_required = + t->ping_policy.max_pings_without_data; grpc_chttp2_initiate_write(exec_ctx, t, false, "init"); post_benign_reclaimer(exec_ctx, t); diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index 1000b63add..2886d1ca3d 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -160,6 +160,7 @@ void resource_quota_server(grpc_end2end_test_config config) { int pending_server_end_calls = 0; int cancelled_calls_on_client = 0; int cancelled_calls_on_server = 0; + int deadline_exceeded = 0; grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); @@ -247,6 +248,9 @@ void resource_quota_server(grpc_end2end_test_config config) { case GRPC_STATUS_RESOURCE_EXHAUSTED: cancelled_calls_on_client++; break; + case GRPC_STATUS_DEADLINE_EXCEEDED: + deadline_exceeded++; + break; case GRPC_STATUS_OK: break; default: @@ -343,10 +347,11 @@ void resource_quota_server(grpc_end2end_test_config config) { } } - gpr_log( - GPR_INFO, - "Done. %d total calls: %d cancelled at server, %d cancelled at client.", - NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client); + gpr_log(GPR_INFO, + "Done. %d total calls: %d cancelled at server, %d cancelled at " + "client, %d timed out.", + NUM_CALLS, cancelled_calls_on_server, cancelled_calls_on_client, + deadline_exceeded); /* The call may be cancelled after the server has sent its status but before * the client has received it. This means that we should see strictly more -- cgit v1.2.3 From bd0b0546a6e12dc6b9276502341446e91f0253f0 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 19 Jan 2017 18:09:50 +0100 Subject: windows compilation fixes --- build.yaml | 8 + src/core/lib/iomgr/tcp_client_windows.c | 27 ++- src/core/lib/support/time_windows.c | 8 +- test/core/end2end/data/ssl_test_data.h | 8 + test/cpp/end2end/async_end2end_test.cc | 1 + test/cpp/grpclb/grpclb_api_test.cc | 2 +- test/cpp/interop/client.cc | 2 - test/cpp/interop/client_helper.cc | 2 - test/cpp/interop/interop_client.cc | 6 +- test/cpp/interop/interop_server.cc | 6 +- test/cpp/interop/interop_server_bootstrap.cc | 1 - test/cpp/interop/reconnect_interop_server.cc | 1 - test/cpp/qps/usage_timer.cc | 29 ++- test/cpp/qps/worker.cc | 2 +- test/cpp/thread_manager/thread_manager_test.cc | 1 + test/cpp/util/grpc_tool.cc | 15 +- tools/run_tests/generated/tests.json | 6 +- .../vcxproj/test/bm_fullstack/bm_fullstack.vcxproj | 210 --------------------- .../test/bm_fullstack/bm_fullstack.vcxproj.filters | 21 --- .../json_run_localhost/json_run_localhost.vcxproj | 210 --------------------- .../json_run_localhost.vcxproj.filters | 21 --- 21 files changed, 87 insertions(+), 500 deletions(-) delete mode 100644 vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj delete mode 100644 vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters delete mode 100644 vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj delete mode 100644 vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj.filters (limited to 'src/core') diff --git a/build.yaml b/build.yaml index 578e8bc6e8..06b6eb3255 100644 --- a/build.yaml +++ b/build.yaml @@ -2943,6 +2943,10 @@ targets: - grpc - gpr_test_util - gpr + platforms: + - mac + - linux + - posix - name: channel_arguments_test gtest: true build: test @@ -3369,6 +3373,10 @@ targets: - gpr_test_util - gpr - grpc++_test_config + platforms: + - mac + - linux + - posix - name: metrics_client build: test run: false diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index 1e84ec3a1e..c8dc9e64bd 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -135,12 +135,10 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { /* Tries to issue one async connection, then schedules both an IOCP notification request for the connection, and one timeout alert. */ -void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_done, - grpc_endpoint **endpoint, - grpc_pollset_set *interested_parties, - const grpc_channel_args *channel_args, - const grpc_resolved_address *addr, - gpr_timespec deadline) { +static void tcp_client_connect_impl( + grpc_exec_ctx *exec_ctx, grpc_closure *on_done, grpc_endpoint **endpoint, + grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, + const grpc_resolved_address *addr, gpr_timespec deadline) { SOCKET sock = INVALID_SOCKET; BOOL success; int status; @@ -252,4 +250,21 @@ failure: grpc_closure_sched(exec_ctx, on_done, final_error); } +// overridden by api_fuzzer.c +void (*grpc_tcp_client_connect_impl)( + grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, + grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args, + const grpc_resolved_address *addr, + gpr_timespec deadline) = tcp_client_connect_impl; + +void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, + grpc_endpoint **ep, + grpc_pollset_set *interested_parties, + const grpc_channel_args *channel_args, + const grpc_resolved_address *addr, + gpr_timespec deadline) { + grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, + channel_args, addr, deadline); +} + #endif /* GRPC_WINSOCK_SOCKET */ diff --git a/src/core/lib/support/time_windows.c b/src/core/lib/support/time_windows.c index 6459732879..7b94a5b7bf 100644 --- a/src/core/lib/support/time_windows.c +++ b/src/core/lib/support/time_windows.c @@ -56,7 +56,7 @@ void gpr_time_init(void) { g_time_scale = 1.0 / (double)frequency.QuadPart; } -gpr_timespec gpr_now(gpr_clock_type clock) { +static gpr_timespec now_impl(gpr_clock_type clock) { gpr_timespec now_tv; LONGLONG diff; struct _timeb now_tb; @@ -84,6 +84,12 @@ gpr_timespec gpr_now(gpr_clock_type clock) { return now_tv; } +gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl; + +gpr_timespec gpr_now(gpr_clock_type clock_type) { + return gpr_now_impl(clock_type); +} + void gpr_sleep_until(gpr_timespec until) { gpr_timespec now; gpr_timespec delta; diff --git a/test/core/end2end/data/ssl_test_data.h b/test/core/end2end/data/ssl_test_data.h index 4a64af1e27..0b274e0d95 100644 --- a/test/core/end2end/data/ssl_test_data.h +++ b/test/core/end2end/data/ssl_test_data.h @@ -34,6 +34,10 @@ #ifndef GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H #define GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H +#ifdef __cplusplus +extern "C" { +#endif + extern const char test_root_cert[]; extern const char test_server1_cert[]; extern const char test_server1_key[]; @@ -42,4 +46,8 @@ extern const char test_self_signed_client_key[]; extern const char test_signed_client_cert[]; extern const char test_signed_client_key[]; +#ifdef __cplusplus +} +#endif + #endif /* GRPC_TEST_CORE_END2END_DATA_SSL_TEST_DATA_H */ diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index f53601297c..32e8a41795 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index 191d729a9e..82ccf436f8 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -63,7 +63,7 @@ grpc::string PackedStringToIp(const grpc_grpclb_ip_address& pb_ip) { } else { abort(); } - GPR_ASSERT(inet_ntop(af, pb_ip.bytes, ip_str, 46) != NULL); + GPR_ASSERT(inet_ntop(af, (void*)pb_ip.bytes, ip_str, 46) != NULL); return ip_str; } diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc index 1df2fc8320..8a00b61cef 100644 --- a/test/cpp/interop/client.cc +++ b/test/cpp/interop/client.cc @@ -34,8 +34,6 @@ #include #include -#include - #include #include #include diff --git a/test/cpp/interop/client_helper.cc b/test/cpp/interop/client_helper.cc index 91564e5dce..d3192ad0c9 100644 --- a/test/cpp/interop/client_helper.cc +++ b/test/cpp/interop/client_helper.cc @@ -33,8 +33,6 @@ #include "test/cpp/interop/client_helper.h" -#include - #include #include #include diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc index aa34d94f61..b7f2723c39 100644 --- a/test/cpp/interop/interop_client.cc +++ b/test/cpp/interop/interop_client.cc @@ -31,7 +31,6 @@ * */ -#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include "src/core/lib/transport/byte_stream.h" @@ -618,7 +618,9 @@ bool InteropClient::DoResponseStreamingWithSlowConsumer() { GPR_ASSERT(response.payload().body() == grpc::string(kResponseMessageSize, '\0')); gpr_log(GPR_DEBUG, "received message %d", i); - usleep(kReceiveDelayMilliSeconds * 1000); + gpr_sleep_until(gpr_time_add( + gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_millis(kReceiveDelayMilliSeconds, GPR_TIMESPAN))); ++i; } diff --git a/test/cpp/interop/interop_server.cc b/test/cpp/interop/interop_server.cc index 1810cd076f..77e309dde4 100644 --- a/test/cpp/interop/interop_server.cc +++ b/test/cpp/interop/interop_server.cc @@ -31,8 +31,6 @@ * */ -#include - #include #include #include @@ -45,6 +43,7 @@ #include #include #include +#include #include #include "src/core/lib/support/string.h" @@ -348,6 +347,7 @@ void grpc::testing::interop::RunServer( std::unique_ptr server(builder.BuildAndStart()); gpr_log(GPR_INFO, "Server listening on %s", server_address.str().c_str()); while (!gpr_atm_no_barrier_load(&g_got_sigint)) { - sleep(5); + gpr_sleep_until(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(5, GPR_TIMESPAN))); } } diff --git a/test/cpp/interop/interop_server_bootstrap.cc b/test/cpp/interop/interop_server_bootstrap.cc index 99518c6943..7cbf221a03 100644 --- a/test/cpp/interop/interop_server_bootstrap.cc +++ b/test/cpp/interop/interop_server_bootstrap.cc @@ -32,7 +32,6 @@ */ #include -#include #include "test/cpp/interop/server_helper.h" #include "test/cpp/util/test_config.h" diff --git a/test/cpp/interop/reconnect_interop_server.cc b/test/cpp/interop/reconnect_interop_server.cc index 53d51e80e7..634d0a90fc 100644 --- a/test/cpp/interop/reconnect_interop_server.cc +++ b/test/cpp/interop/reconnect_interop_server.cc @@ -34,7 +34,6 @@ // Test description at doc/connection-backoff-interop-test-description.md #include -#include #include #include diff --git a/test/cpp/qps/usage_timer.cc b/test/cpp/qps/usage_timer.cc index c6697fbdfd..70ef26e82a 100644 --- a/test/cpp/qps/usage_timer.cc +++ b/test/cpp/qps/usage_timer.cc @@ -39,8 +39,15 @@ #include #include +#ifdef __linux__ #include #include + +static double time_double(struct timeval* tv) { + return tv->tv_sec + 1e-6 * tv->tv_usec; +} +#endif + UsageTimer::UsageTimer() : start_(Sample()) {} double UsageTimer::Now() { @@ -48,8 +55,16 @@ double UsageTimer::Now() { return ts.tv_sec + 1e-9 * ts.tv_nsec; } -static double time_double(struct timeval* tv) { - return tv->tv_sec + 1e-6 * tv->tv_usec; +static void get_resource_usage(double* utime, double* stime) { +#ifdef __linux__ + struct rusage usage; + getrusage(RUSAGE_SELF, &usage); + *utime = time_double(&usage.ru_utime); + *stime = time_double(&usage.ru_stime); +#else + *utime = 0; + *stime = 0; +#endif } static void get_cpu_usage(unsigned long long* total_cpu_time, @@ -74,15 +89,9 @@ static void get_cpu_usage(unsigned long long* total_cpu_time, } UsageTimer::Result UsageTimer::Sample() { - struct rusage usage; - struct timeval tv; - gettimeofday(&tv, NULL); - getrusage(RUSAGE_SELF, &usage); - Result r; - r.wall = time_double(&tv); - r.user = time_double(&usage.ru_utime); - r.system = time_double(&usage.ru_stime); + r.wall = Now(); + get_resource_usage(&r.user, &r.system); r.total_cpu_time = 0; r.idle_cpu_time = 0; get_cpu_usage(&r.total_cpu_time, &r.idle_cpu_time); diff --git a/test/cpp/qps/worker.cc b/test/cpp/qps/worker.cc index 2068b7c213..e88d0647dd 100644 --- a/test/cpp/qps/worker.cc +++ b/test/cpp/qps/worker.cc @@ -31,7 +31,7 @@ * */ -#include +#include #include #include diff --git a/test/cpp/thread_manager/thread_manager_test.cc b/test/cpp/thread_manager/thread_manager_test.cc index 284761c53a..35c8d5d088 100644 --- a/test/cpp/thread_manager/thread_manager_test.cc +++ b/test/cpp/thread_manager/thread_manager_test.cc @@ -31,6 +31,7 @@ *is % allowed in string */ +#include #include #include diff --git a/test/cpp/util/grpc_tool.cc b/test/cpp/util/grpc_tool.cc index 39acd8eb4b..856cd32c3c 100644 --- a/test/cpp/util/grpc_tool.cc +++ b/test/cpp/util/grpc_tool.cc @@ -33,7 +33,7 @@ #include "test/cpp/util/grpc_tool.h" -#include +#include #include #include #include @@ -48,12 +48,19 @@ #include #include #include +#include #include "test/cpp/util/cli_call.h" #include "test/cpp/util/proto_file_parser.h" #include "test/cpp/util/proto_reflection_descriptor_database.h" #include "test/cpp/util/service_describer.h" +#if GPR_WINDOWS +#include +#else +#include +#endif + namespace grpc { namespace testing { @@ -484,7 +491,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv, CliCall call(channel, formatted_method_name, client_metadata); if (FLAGS_infile.empty()) { - if (isatty(STDIN_FILENO)) { + if (isatty(fileno(stdin))) { print_mode = true; fprintf(stderr, "reading streaming request message from stdin...\n"); } @@ -566,7 +573,7 @@ bool GrpcTool::CallMethod(int argc, const char** argv, } else { std::stringstream input_stream; if (FLAGS_infile.empty()) { - if (isatty(STDIN_FILENO)) { + if (isatty(fileno(stdin))) { fprintf(stderr, "reading request message from stdin...\n"); } input_stream << std::cin.rdbuf(); @@ -668,7 +675,7 @@ bool GrpcTool::ParseMessage(int argc, const char** argv, } else { std::stringstream input_stream; if (FLAGS_infile.empty()) { - if (isatty(STDIN_FILENO)) { + if (isatty(fileno(stdin))) { fprintf(stderr, "reading request message from stdin...\n"); } input_stream << std::cin.rdbuf(); diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index fbf2115559..5565d28dfd 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -2434,8 +2434,7 @@ "ci_platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ], "cpu_cost": 1.0, "exclude_configs": [], @@ -2447,8 +2446,7 @@ "platforms": [ "linux", "mac", - "posix", - "windows" + "posix" ] }, { diff --git a/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj b/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj deleted file mode 100644 index 3809beb508..0000000000 --- a/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {4AAFDA9D-A596-DE6D-8288-A9219D7EBD93} - true - $(SolutionDir)IntDir\$(MSBuildProjectName)\ - - - - v100 - - - v110 - - - v120 - - - v140 - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - bm_fullstack - static - Debug - static - Debug - - - bm_fullstack - static - Release - static - Release - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - - - - - {07978586-E47C-8709-A63E-895FBF3C3C7D} - - - {0BE77741-552A-929B-A497-4EF7ECE17A64} - - - {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} - - - {C187A093-A0FE-489D-A40A-6E33DE0F9FEB} - - - {29D16885-7228-4C31-81ED-5F9187C7F2A9} - - - {EAB0A629-17A9-44DB-B5FF-E91A721FE037} - - - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - diff --git a/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters b/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters deleted file mode 100644 index 76b29ad3bd..0000000000 --- a/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - test\cpp\microbenchmarks - - - - - - {a2580d22-fbdd-9841-08c9-3173349c0837} - - - {3d07ea20-516b-1ac1-4564-f1f04c929e99} - - - {c130900b-fb0a-d96a-530e-f837d1a9582e} - - - - diff --git a/vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj b/vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj deleted file mode 100644 index 34507b656e..0000000000 --- a/vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj +++ /dev/null @@ -1,210 +0,0 @@ - - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {91678827-DAEF-2E2F-9CD1-1F5E5DD54842} - true - $(SolutionDir)IntDir\$(MSBuildProjectName)\ - - - - v100 - - - v110 - - - v120 - - - v140 - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - - - - json_run_localhost - static - Debug - static - Debug - - - json_run_localhost - static - Release - static - Release - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - true - MultiThreadedDebug - true - None - false - - - Console - true - false - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - NotUsing - Level3 - MaxSpeed - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - true - true - true - MultiThreaded - true - None - false - - - Console - true - false - true - true - - - - - - - - - - {0BE77741-552A-929B-A497-4EF7ECE17A64} - - - {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} - - - {C187A093-A0FE-489D-A40A-6E33DE0F9FEB} - - - {29D16885-7228-4C31-81ED-5F9187C7F2A9} - - - {EAB0A629-17A9-44DB-B5FF-E91A721FE037} - - - {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} - - - {3F7D093D-11F9-C4BC-BEB7-18EB28E3F290} - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - diff --git a/vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj.filters b/vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj.filters deleted file mode 100644 index 84c5d1e377..0000000000 --- a/vsprojects/vcxproj/test/json_run_localhost/json_run_localhost.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ - - - - - test\cpp\qps - - - - - - {6a0e8372-94ed-67cd-edda-56ba97debf76} - - - {2a065f28-e35d-1a75-6e12-fd86e7b99443} - - - {6eec400a-a3a2-2904-8b49-92aeb69c4448} - - - - -- cgit v1.2.3 From 864db53e482a032f10343852a702e51eadc5dc5f Mon Sep 17 00:00:00 2001 From: Vizerai Date: Fri, 20 Jan 2017 18:30:44 -0800 Subject: Updated trace_context.proto and associated files. --- src/core/ext/census/gen/trace_context.pb.c | 45 +++----------- src/core/ext/census/gen/trace_context.pb.h | 48 +++++++-------- src/core/ext/census/trace_context.c | 2 +- src/core/ext/census/trace_context.h | 3 + src/proto/census/trace_context.proto | 20 +++--- test/core/census/data/context_full.pb | Bin 31 -> 32 bytes test/core/census/data/context_full.txt | 5 +- test/core/census/data/context_no_sample.pb | Bin 29 -> 0 bytes test/core/census/data/context_no_sample.txt | 2 - test/core/census/data/context_no_span_options.pb | Bin 0 -> 27 bytes test/core/census/data/context_no_span_options.txt | 3 + test/core/census/data/context_span_only.pb | Bin 11 -> 14 bytes test/core/census/data/context_span_only.txt | 2 +- test/core/census/data/context_trace_only.pb | Bin 22 -> 23 bytes test/core/census/data/context_trace_only.txt | 5 +- test/core/census/trace_context_test.c | 71 +++++++++++----------- 16 files changed, 87 insertions(+), 119 deletions(-) delete mode 100644 test/core/census/data/context_no_sample.pb delete mode 100644 test/core/census/data/context_no_sample.txt create mode 100644 test/core/census/data/context_no_span_options.pb create mode 100644 test/core/census/data/context_no_span_options.txt (limited to 'src/core') diff --git a/src/core/ext/census/gen/trace_context.pb.c b/src/core/ext/census/gen/trace_context.pb.c index c8aea324ce..f4126d4d80 100644 --- a/src/core/ext/census/gen/trace_context.pb.c +++ b/src/core/ext/census/gen/trace_context.pb.c @@ -1,6 +1,6 @@ /* * - * Copyright 2016, Google Inc. + * Copyright 2017, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,51 +31,24 @@ * */ /* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.5-dev */ +/* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */ #include "src/core/ext/census/gen/trace_context.pb.h" +/* @@protoc_insertion_point(includes) */ #if PB_PROTO_HEADER_VERSION != 30 #error Regenerate this file with the current version of nanopb generator. #endif -const pb_field_t google_trace_TraceId_fields[3] = { - PB_FIELD( 1, FIXED64 , OPTIONAL, STATIC , FIRST, google_trace_TraceId, hi, hi, 0), - PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceId, lo, hi, 0), +const pb_field_t google_trace_TraceContext_fields[5] = { + PB_FIELD( 1, FIXED64 , OPTIONAL, STATIC , FIRST, google_trace_TraceContext, trace_id_hi, trace_id_hi, 0), + PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, trace_id_lo, trace_id_hi, 0), + PB_FIELD( 3, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_id, trace_id_lo, 0), + PB_FIELD( 4, FIXED32 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_options, span_id, 0), PB_LAST_FIELD }; -const pb_field_t google_trace_TraceContext_fields[4] = { - PB_FIELD( 1, MESSAGE , OPTIONAL, STATIC , FIRST, google_trace_TraceContext, trace_id, trace_id, &google_trace_TraceId_fields), - PB_FIELD( 2, FIXED64 , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, span_id, trace_id, 0), - PB_FIELD( 3, BOOL , OPTIONAL, STATIC , OTHER, google_trace_TraceContext, is_sampled, span_id, 0), - PB_LAST_FIELD -}; - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(google_trace_TraceContext, trace_id) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_trace_TraceId_google_trace_TraceContext) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(google_trace_TraceContext, trace_id) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_trace_TraceId_google_trace_TraceContext) -#endif - +/* @@protoc_insertion_point(eof) */ diff --git a/src/core/ext/census/gen/trace_context.pb.h b/src/core/ext/census/gen/trace_context.pb.h index cfb2f04ccd..ea127bf70a 100644 --- a/src/core/ext/census/gen/trace_context.pb.h +++ b/src/core/ext/census/gen/trace_context.pb.h @@ -1,6 +1,6 @@ /* * - * Copyright 2016, Google Inc. + * Copyright 2017, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,11 +31,13 @@ * */ /* Automatically generated nanopb header */ -/* Generated by nanopb-0.3.5-dev */ +/* Generated by nanopb-0.3.7-dev at Fri Jan 20 16:14:22 2017. */ #ifndef GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H #define GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H #include "third_party/nanopb/pb.h" + +/* @@protoc_insertion_point(includes) */ #if PB_PROTO_HEADER_VERSION != 30 #error Regenerate this file with the current version of nanopb generator. #endif @@ -45,44 +47,35 @@ extern "C" { #endif /* Struct definitions */ -typedef struct _google_trace_TraceId { - bool has_hi; - uint64_t hi; - bool has_lo; - uint64_t lo; -} google_trace_TraceId; - typedef struct _google_trace_TraceContext { - bool has_trace_id; - google_trace_TraceId trace_id; + bool has_trace_id_hi; + uint64_t trace_id_hi; + bool has_trace_id_lo; + uint64_t trace_id_lo; bool has_span_id; uint64_t span_id; - bool has_is_sampled; - bool is_sampled; + bool has_span_options; + uint32_t span_options; +/* @@protoc_insertion_point(struct:google_trace_TraceContext) */ } google_trace_TraceContext; /* Default values for struct fields */ /* Initializer values for message structs */ -#define google_trace_TraceId_init_default {false, 0, false, 0} -#define google_trace_TraceContext_init_default {false, google_trace_TraceId_init_default, false, 0, false, 0} -#define google_trace_TraceId_init_zero {false, 0, false, 0} -#define google_trace_TraceContext_init_zero {false, google_trace_TraceId_init_zero, false, 0, false, 0} +#define google_trace_TraceContext_init_default {false, 0, false, 0, false, 0, false, 0} +#define google_trace_TraceContext_init_zero {false, 0, false, 0, false, 0, false, 0} /* Field tags (for use in manual encoding/decoding) */ -#define google_trace_TraceId_hi_tag 1 -#define google_trace_TraceId_lo_tag 2 -#define google_trace_TraceContext_trace_id_tag 1 -#define google_trace_TraceContext_span_id_tag 2 -#define google_trace_TraceContext_is_sampled_tag 3 +#define google_trace_TraceContext_trace_id_hi_tag 1 +#define google_trace_TraceContext_trace_id_lo_tag 2 +#define google_trace_TraceContext_span_id_tag 3 +#define google_trace_TraceContext_span_options_tag 4 /* Struct field encoding specification for nanopb */ -extern const pb_field_t google_trace_TraceId_fields[3]; -extern const pb_field_t google_trace_TraceContext_fields[4]; +extern const pb_field_t google_trace_TraceContext_fields[5]; /* Maximum encoded size of messages (where known) */ -#define google_trace_TraceId_size 18 -#define google_trace_TraceContext_size 31 +#define google_trace_TraceContext_size 32 /* Message IDs (where set with "msgid" option) */ #ifdef PB_MSGID @@ -95,5 +88,6 @@ extern const pb_field_t google_trace_TraceContext_fields[4]; #ifdef __cplusplus } /* extern "C" */ #endif +/* @@protoc_insertion_point(eof) */ -#endif /* GRPC_CORE_EXT_CENSUS_GEN_TRACE_CONTEXT_PB_H */ +#endif diff --git a/src/core/ext/census/trace_context.c b/src/core/ext/census/trace_context.c index fbb20d3448..47d0de19da 100644 --- a/src/core/ext/census/trace_context.c +++ b/src/core/ext/census/trace_context.c @@ -73,7 +73,7 @@ bool decode_trace_context(google_trace_TraceContext *ctxt, uint8_t *buffer, } // check fields - if (!ctxt->has_trace_id) { + if (!ctxt->has_trace_id_hi || !ctxt->has_trace_id_lo) { gpr_log(GPR_DEBUG, "Invalid TraceContext: missing trace_id"); return false; } diff --git a/src/core/ext/census/trace_context.h b/src/core/ext/census/trace_context.h index 1cb5e26ea7..f391a1b7c1 100644 --- a/src/core/ext/census/trace_context.h +++ b/src/core/ext/census/trace_context.h @@ -38,6 +38,9 @@ #include "src/core/ext/census/gen/trace_context.pb.h" +/* Span option flags. */ +#define SPAN_OPTIONS_IS_SAMPLED 0x01 + /* Maximum number of bytes required to encode a TraceContext (31) 1 byte for trace_id field 1 byte for trace_id length diff --git a/src/proto/census/trace_context.proto b/src/proto/census/trace_context.proto index a5d5a9595d..fc0a54d2ce 100644 --- a/src/proto/census/trace_context.proto +++ b/src/proto/census/trace_context.proto @@ -31,18 +31,14 @@ syntax = "proto3"; package google.trace; -// A TraceId uniquely represents a single Trace. It is a 128-bit nonce. -message TraceId { - fixed64 hi = 1; - fixed64 lo = 2; -} - // Tracing information that is propagated with RPC's. message TraceContext { - // Trace identifer. Must be present. - TraceId trace_id = 1; - // ID of parent (client) span. Must be present. - fixed64 span_id = 2; - // true if this trace is sampled. - bool is_sampled = 3; + // A TraceId uniquely represents a single Trace. It is a 128-bit nonce. + // The 128-bit ID is split into 2 64-bit chunks. (REQUIRED) + fixed64 trace_id_hi = 1; + fixed64 trace_id_lo = 2; + // ID of parent (client) span. (REQUIRED) + fixed64 span_id = 3; + // Span option flags. First bit is true if this trace is sampled. (OPTIONAL) + fixed32 span_options = 4; } diff --git a/test/core/census/data/context_full.pb b/test/core/census/data/context_full.pb index 80ebcf280b..7b5895cbf1 100644 Binary files a/test/core/census/data/context_full.pb and b/test/core/census/data/context_full.pb differ diff --git a/test/core/census/data/context_full.txt b/test/core/census/data/context_full.txt index 7901a10c33..7d8df37ea1 100644 --- a/test/core/census/data/context_full.txt +++ b/test/core/census/data/context_full.txt @@ -1,3 +1,4 @@ -trace_id { hi : 5; lo : 1 } +trace_id_hi : 5 +trace_id_lo : 1 span_id : 7 -is_sampled : true +span_options : 1 diff --git a/test/core/census/data/context_no_sample.pb b/test/core/census/data/context_no_sample.pb deleted file mode 100644 index ab7ad7d109..0000000000 Binary files a/test/core/census/data/context_no_sample.pb and /dev/null differ diff --git a/test/core/census/data/context_no_sample.txt b/test/core/census/data/context_no_sample.txt deleted file mode 100644 index 150298002f..0000000000 --- a/test/core/census/data/context_no_sample.txt +++ /dev/null @@ -1,2 +0,0 @@ -trace_id { hi : 5; lo : 1 } -span_id : 7 diff --git a/test/core/census/data/context_no_span_options.pb b/test/core/census/data/context_no_span_options.pb new file mode 100644 index 0000000000..4b3425ac01 Binary files /dev/null and b/test/core/census/data/context_no_span_options.pb differ diff --git a/test/core/census/data/context_no_span_options.txt b/test/core/census/data/context_no_span_options.txt new file mode 100644 index 0000000000..4c8398ffd0 --- /dev/null +++ b/test/core/census/data/context_no_span_options.txt @@ -0,0 +1,3 @@ +trace_id_hi : 5 +trace_id_lo : 1 +span_id : 7 diff --git a/test/core/census/data/context_span_only.pb b/test/core/census/data/context_span_only.pb index 2a9527a75a..a9315be91a 100644 Binary files a/test/core/census/data/context_span_only.pb and b/test/core/census/data/context_span_only.pb differ diff --git a/test/core/census/data/context_span_only.txt b/test/core/census/data/context_span_only.txt index d90de2e614..4e473fce53 100644 --- a/test/core/census/data/context_span_only.txt +++ b/test/core/census/data/context_span_only.txt @@ -1,2 +1,2 @@ span_id : 7 -is_sampled : true +span_options : 1 diff --git a/test/core/census/data/context_trace_only.pb b/test/core/census/data/context_trace_only.pb index 7fdf6f61a3..aabb325f92 100644 Binary files a/test/core/census/data/context_trace_only.pb and b/test/core/census/data/context_trace_only.pb differ diff --git a/test/core/census/data/context_trace_only.txt b/test/core/census/data/context_trace_only.txt index 9b68a6aa92..e48a6d7457 100644 --- a/test/core/census/data/context_trace_only.txt +++ b/test/core/census/data/context_trace_only.txt @@ -1,2 +1,3 @@ -trace_id { hi : 5; lo : 1 } -is_sampled : true +trace_id_hi : 5 +trace_id_lo : 1 +span_options : 1 diff --git a/test/core/census/trace_context_test.c b/test/core/census/trace_context_test.c index ee409e8d1a..5963b1a246 100644 --- a/test/core/census/trace_context_test.c +++ b/test/core/census/trace_context_test.c @@ -59,7 +59,6 @@ bool validate_encode_decode_context(google_trace_TraceContext *ctxt1, uint8_t *buffer, size_t buf_size) { google_trace_TraceContext ctxt2 = google_trace_TraceContext_init_zero; size_t msg_length; - GPR_ASSERT(ctxt1->has_trace_id && ctxt1->has_span_id); msg_length = encode_trace_context(ctxt1, buffer, buf_size); if (msg_length == 0) { @@ -70,16 +69,17 @@ bool validate_encode_decode_context(google_trace_TraceContext *ctxt1, return false; } - if (!ctxt2.has_trace_id || !ctxt2.has_span_id) { + if (!ctxt2.has_trace_id_hi || !ctxt2.has_trace_id_lo || !ctxt2.has_span_id) { return false; } - GPR_ASSERT( - ctxt1->trace_id.hi == ctxt2.trace_id.hi && - ctxt1->trace_id.lo == ctxt2.trace_id.lo && - ctxt1->span_id == ctxt2.span_id && - ctxt1->has_is_sampled == ctxt2.has_is_sampled && - (ctxt1->has_is_sampled ? ctxt1->is_sampled == ctxt2.is_sampled : true)); + GPR_ASSERT(ctxt1->trace_id_hi == ctxt2.trace_id_hi && + ctxt1->trace_id_lo == ctxt2.trace_id_lo && + ctxt1->span_id == ctxt2.span_id && + ctxt1->has_span_options == ctxt2.has_span_options && + (ctxt1->has_span_options + ? ctxt1->span_options == ctxt2.span_options + : true)); return true; } @@ -94,7 +94,7 @@ bool validate_decode_context(google_trace_TraceContext *ctxt, uint8_t *buffer, return false; } - if (!ctxt->has_trace_id || !ctxt->has_span_id) { + if (!ctxt->has_trace_id_hi || !ctxt->has_trace_id_lo || !ctxt->has_span_id) { return false; } @@ -144,49 +144,48 @@ static void test_span_only() { &ctxt, "test/core/census/data/context_span_only.pb", false); } -// Test proto-buffer without is_sampled value. -static void test_no_sample() { +// Test proto-buffer without span_options value. +static void test_no_span_options() { google_trace_TraceContext ctxt = google_trace_TraceContext_init_zero; read_and_validate_context_from_file( - &ctxt, "test/core/census/data/context_no_sample.pb", true); - GPR_ASSERT(ctxt.has_is_sampled == false && ctxt.is_sampled == false); + &ctxt, "test/core/census/data/context_no_span_options.pb", true); + GPR_ASSERT(ctxt.has_span_options == false && ctxt.span_options == 0); } static void test_encode_decode() { uint8_t buffer[BUF_SIZE] = {0}; google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero; - ctxt1.has_trace_id = true; - ctxt1.trace_id.has_hi = true; - ctxt1.trace_id.has_lo = true; - ctxt1.trace_id.lo = 1; - ctxt1.trace_id.hi = 2; + ctxt1.has_trace_id_hi = true; + ctxt1.has_trace_id_lo = true; + ctxt1.trace_id_lo = 1; + ctxt1.trace_id_hi = 2; ctxt1.has_span_id = true; ctxt1.span_id = 3; validate_encode_decode_context(&ctxt1, buffer, sizeof(buffer)); + // Missing trace_id. This should fail. google_trace_TraceContext ctxt2 = google_trace_TraceContext_init_zero; - ctxt2.has_trace_id = true; - ctxt2.trace_id.has_hi = false; - ctxt2.trace_id.has_lo = false; + ctxt2.has_trace_id_hi = false; + ctxt2.has_trace_id_lo = false; ctxt2.has_span_id = true; validate_encode_decode_context(&ctxt2, buffer, sizeof(buffer)); } -// Test a corrupted proto-buffer. +// Test a corrupted proto-buffer. This should fail. static void test_corrupt() { uint8_t buffer[BUF_SIZE] = {0}; google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero; size_t msg_length; - ctxt1.has_trace_id = true; - ctxt1.trace_id.has_hi = true; - ctxt1.trace_id.has_lo = true; - ctxt1.trace_id.lo = 1; - ctxt1.trace_id.hi = 2; + ctxt1.has_trace_id_hi = true; + ctxt1.has_trace_id_lo = true; + ctxt1.trace_id_lo = 1; + ctxt1.trace_id_hi = 2; ctxt1.has_span_id = true; ctxt1.span_id = 3; - ctxt1.is_sampled = true; + ctxt1.has_span_options = true; + ctxt1.span_options = SPAN_OPTIONS_IS_SAMPLED; msg_length = encode_trace_context(&ctxt1, buffer, sizeof(buffer)); /* Corrupt some bytes. 255 (0xFF) should be illegal for the first byte of the @@ -198,19 +197,19 @@ static void test_corrupt() { } static void test_buffer_size() { - // This buffer is too small, so the encode should fail. + // This buffer is too small. This should fail. uint8_t buffer[16] = {0}; google_trace_TraceContext ctxt1 = google_trace_TraceContext_init_zero; size_t msg_length; - ctxt1.has_trace_id = true; - ctxt1.trace_id.has_hi = true; - ctxt1.trace_id.has_lo = true; - ctxt1.trace_id.lo = 1; - ctxt1.trace_id.hi = 2; + ctxt1.has_trace_id_hi = true; + ctxt1.has_trace_id_lo = true; + ctxt1.trace_id_lo = 1; + ctxt1.trace_id_hi = 2; ctxt1.has_span_id = true; ctxt1.span_id = 3; - ctxt1.is_sampled = true; + ctxt1.has_span_options = true; + ctxt1.span_options = SPAN_OPTIONS_IS_SAMPLED; msg_length = encode_trace_context(&ctxt1, buffer, sizeof(buffer)); GPR_ASSERT(msg_length == 0); @@ -224,7 +223,7 @@ int main(int argc, char **argv) { test_span_only(); test_encode_decode(); test_corrupt(); - test_no_sample(); + test_no_span_options(); test_buffer_size(); return 0; -- cgit v1.2.3 From 7ec4748502436cc6fb453f0348f6c8868b03b7d3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 1 Feb 2017 16:54:51 -0800 Subject: Improve sync streaming benchmark, fix deadlock that can occur sometimes --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 9 +++++++-- test/cpp/qps/client_sync.cc | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 692eb3f902..9acaddfb38 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -2026,8 +2026,6 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, (uint32_t)(max_recv_bytes - s->incoming_window_delta); bool new_window_write_is_covered_by_poller = s->incoming_window_delta + initial_window_size < (int64_t)have_already; - bool force_send = (s->incoming_window_delta - s->announce_window <= - -(int64_t)initial_window_size / 2); /* gpr_log(GPR_DEBUG, "%d %d %d", (int)(s->incoming_window_delta - s->announce_window), (int)(-(int64_t)initial_window_size / 2), force_send); */ @@ -2035,6 +2033,13 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, add_max_recv_bytes); GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, announce_window, add_max_recv_bytes); + bool force_send = (s->incoming_window_delta - s->announce_window <= + -(int64_t)initial_window_size / 2) || + s->announce_window > initial_window_size / 2; + /* gpr_log(GPR_DEBUG, "%s:%d: iwd=%d ann=%d iws=%d force=%d", + t->peer_string, + s->id, (int)s->incoming_window_delta, (int)s->announce_window, + initial_window_size, force_send); */ if (force_send) { grpc_chttp2_become_writable(exec_ctx, t, s, new_window_write_is_covered_by_poller, diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index b1e61865e7..498416c64a 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -153,7 +153,6 @@ class SynchronousStreamingClient final : public SynchronousClient { if (*stream) { (*stream)->WritesDone(); Status s = (*stream)->Finish(); - EXPECT_TRUE(s.ok()); if (!s.ok()) { gpr_log(GPR_ERROR, "Stream %zu received an error %s", i, s.error_message().c_str()); @@ -173,7 +172,11 @@ class SynchronousStreamingClient final : public SynchronousClient { entry->set_value((UsageTimer::Now() - start) * 1e9); return true; } - return false; + auto* stub = channels_[thread_idx % channels_.size()].get_stub(); + context_[thread_idx].~ClientContext(); + new (&context_[thread_idx]) ClientContext(); + stream_[thread_idx] = stub->StreamingCall(&context_[thread_idx]); + return true; } private: -- cgit v1.2.3 From c23feddd2cc4d48b9dc5b1d4d89afd6aceca5677 Mon Sep 17 00:00:00 2001 From: Robbie Shade Date: Thu, 2 Feb 2017 11:30:20 -0500 Subject: Add an on_write callback to the UDP server. --- src/core/lib/iomgr/udp_server.c | 38 ++++++++++++++++++++++++++++++++++++-- src/core/lib/iomgr/udp_server.h | 5 +++++ test/core/iomgr/udp_server_test.c | 25 +++++++++++++++++++------ 3 files changed, 60 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/lib/iomgr/udp_server.c b/src/core/lib/iomgr/udp_server.c index 3b23b47d4f..02a194c982 100644 --- a/src/core/lib/iomgr/udp_server.c +++ b/src/core/lib/iomgr/udp_server.c @@ -76,8 +76,10 @@ struct grpc_udp_listener { grpc_udp_server *server; grpc_resolved_address addr; grpc_closure read_closure; + grpc_closure write_closure; grpc_closure destroyed_closure; grpc_udp_server_read_cb read_cb; + grpc_udp_server_write_cb write_cb; grpc_udp_server_orphan_cb orphan_cb; struct grpc_udp_listener *next; @@ -304,9 +306,33 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { gpr_mu_unlock(&sp->server->mu); } +static void on_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { + grpc_udp_listener *sp = arg; + + gpr_mu_lock(&(sp->server->mu)); + if (error != GRPC_ERROR_NONE) { + if (0 == --sp->server->active_ports) { + gpr_mu_unlock(&sp->server->mu); + deactivated_all_ports(exec_ctx, sp->server); + } else { + gpr_mu_unlock(&sp->server->mu); + } + return; + } + + /* Tell the registered callback that the socket is writeable. */ + GPR_ASSERT(sp->write_cb); + sp->write_cb(exec_ctx, sp->emfd); + + /* Re-arm the notification event so we get another chance to write. */ + grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure); + gpr_mu_unlock(&sp->server->mu); +} + static int add_socket_to_server(grpc_udp_server *s, int fd, const grpc_resolved_address *addr, grpc_udp_server_read_cb read_cb, + grpc_udp_server_write_cb write_cb, grpc_udp_server_orphan_cb orphan_cb) { grpc_udp_listener *sp; int port; @@ -333,6 +359,7 @@ static int add_socket_to_server(grpc_udp_server *s, int fd, sp->emfd = grpc_fd_create(fd, name); memcpy(&sp->addr, addr, sizeof(grpc_resolved_address)); sp->read_cb = read_cb; + sp->write_cb = write_cb; sp->orphan_cb = orphan_cb; GPR_ASSERT(sp->emfd); gpr_mu_unlock(&s->mu); @@ -345,6 +372,7 @@ static int add_socket_to_server(grpc_udp_server *s, int fd, int grpc_udp_server_add_port(grpc_udp_server *s, const grpc_resolved_address *addr, grpc_udp_server_read_cb read_cb, + grpc_udp_server_write_cb write_cb, grpc_udp_server_orphan_cb orphan_cb) { grpc_udp_listener *sp; int allocated_port1 = -1; @@ -391,7 +419,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s, // TODO(rjshade): Test and propagate the returned grpc_error*: GRPC_ERROR_UNREF(grpc_create_dualstack_socket(addr, SOCK_DGRAM, IPPROTO_UDP, &dsmode, &fd)); - allocated_port1 = add_socket_to_server(s, fd, addr, read_cb, orphan_cb); + allocated_port1 = + add_socket_to_server(s, fd, addr, read_cb, write_cb, orphan_cb); if (fd >= 0 && dsmode == GRPC_DSMODE_DUALSTACK) { goto done; } @@ -413,7 +442,8 @@ int grpc_udp_server_add_port(grpc_udp_server *s, grpc_sockaddr_is_v4mapped(addr, &addr4_copy)) { addr = &addr4_copy; } - allocated_port2 = add_socket_to_server(s, fd, addr, read_cb, orphan_cb); + allocated_port2 = + add_socket_to_server(s, fd, addr, read_cb, write_cb, orphan_cb); done: gpr_free(allocated_addr); @@ -451,6 +481,10 @@ void grpc_udp_server_start(grpc_exec_ctx *exec_ctx, grpc_udp_server *s, grpc_schedule_on_exec_ctx); grpc_fd_notify_on_read(exec_ctx, sp->emfd, &sp->read_closure); + grpc_closure_init(&sp->write_closure, on_write, sp, + grpc_schedule_on_exec_ctx); + grpc_fd_notify_on_write(exec_ctx, sp->emfd, &sp->write_closure); + s->active_ports++; sp = sp->next; } diff --git a/src/core/lib/iomgr/udp_server.h b/src/core/lib/iomgr/udp_server.h index f3c466a031..ce068cbf04 100644 --- a/src/core/lib/iomgr/udp_server.h +++ b/src/core/lib/iomgr/udp_server.h @@ -49,6 +49,10 @@ typedef struct grpc_udp_server grpc_udp_server; typedef void (*grpc_udp_server_read_cb)(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, struct grpc_server *server); +/* Called when the socket is writeable. */ +typedef void (*grpc_udp_server_write_cb)(grpc_exec_ctx *exec_ctx, + grpc_fd *emfd); + /* Called when the grpc_fd is about to be orphaned (and the FD closed). */ typedef void (*grpc_udp_server_orphan_cb)(grpc_fd *emfd); @@ -75,6 +79,7 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned port_index); int grpc_udp_server_add_port(grpc_udp_server *s, const grpc_resolved_address *addr, grpc_udp_server_read_cb read_cb, + grpc_udp_server_write_cb write_cb, grpc_udp_server_orphan_cb orphan_cb); void grpc_udp_server_destroy(grpc_exec_ctx *exec_ctx, grpc_udp_server *server, diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c index 9ec6d7bf20..ba7a52ea21 100644 --- a/test/core/iomgr/udp_server_test.c +++ b/test/core/iomgr/udp_server_test.c @@ -58,6 +58,7 @@ static grpc_pollset *g_pollset; static gpr_mu *g_mu; static int g_number_of_reads = 0; +static int g_number_of_writes = 0; static int g_number_of_bytes_read = 0; static int g_number_of_orphan_calls = 0; @@ -78,6 +79,15 @@ static void on_read(grpc_exec_ctx *exec_ctx, grpc_fd *emfd, gpr_mu_unlock(g_mu); } +static void on_write(grpc_exec_ctx *exec_ctx, grpc_fd *emfd) { + gpr_mu_lock(g_mu); + g_number_of_writes++; + + GPR_ASSERT( + GRPC_LOG_IF_ERROR("pollset_kick", grpc_pollset_kick(g_pollset, NULL))); + gpr_mu_unlock(g_mu); +} + static void on_fd_orphaned(grpc_fd *emfd) { gpr_log(GPR_INFO, "gRPC FD about to be orphaned: %d", grpc_fd_wrapped_fd(emfd)); @@ -111,8 +121,8 @@ static void test_no_op_with_port(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT( - grpc_udp_server_add_port(s, &resolved_addr, on_read, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write, + on_fd_orphaned)); grpc_udp_server_destroy(&exec_ctx, s, NULL); grpc_exec_ctx_finish(&exec_ctx); @@ -132,8 +142,8 @@ static void test_no_op_with_port_and_start(void) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_in); addr->sin_family = AF_INET; - GPR_ASSERT( - grpc_udp_server_add_port(s, &resolved_addr, on_read, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write, + on_fd_orphaned)); grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL); @@ -164,8 +174,8 @@ static void test_receive(int number_of_clients) { memset(&resolved_addr, 0, sizeof(resolved_addr)); resolved_addr.len = sizeof(struct sockaddr_storage); addr->ss_family = AF_INET; - GPR_ASSERT( - grpc_udp_server_add_port(s, &resolved_addr, on_read, on_fd_orphaned)); + GPR_ASSERT(grpc_udp_server_add_port(s, &resolved_addr, on_read, on_write, + on_fd_orphaned)); svrfd = grpc_udp_server_get_fd(s, 0); GPR_ASSERT(svrfd >= 0); @@ -212,6 +222,9 @@ static void test_receive(int number_of_clients) { /* The server had a single FD, which is orphaned once in * * deactivated_all_ports, and once in grpc_udp_server_destroy. */ GPR_ASSERT(g_number_of_orphan_calls == 2); + + /* The write callback should have fired a few times. */ + GPR_ASSERT(g_number_of_writes > 0); } static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p, -- cgit v1.2.3 From 3ceabdee9f16c97d4fc6c9a0172ffe608123c849 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 2 Feb 2017 10:17:42 -0800 Subject: Fix potential flow control deadlock --- .../transport/chttp2/transport/chttp2_transport.c | 65 +++++++++++++--------- .../chttp2/transport/frame_window_update.c | 5 +- src/core/ext/transport/chttp2/transport/internal.h | 12 +++- src/core/ext/transport/chttp2/transport/parsing.c | 3 +- 4 files changed, 54 insertions(+), 31 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 9acaddfb38..db464bbc6b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -679,13 +679,21 @@ void grpc_chttp2_initiate_write(grpc_exec_ctx *exec_ctx, GPR_TIMER_END("grpc_chttp2_initiate_write", 0); } -void grpc_chttp2_become_writable(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, - grpc_chttp2_stream *s, bool covered_by_poller, - const char *reason) { +void grpc_chttp2_become_writable( + grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, + grpc_chttp2_stream_write_type stream_write_type, const char *reason) { if (!t->closed && grpc_chttp2_list_add_writable_stream(t, s)) { GRPC_CHTTP2_STREAM_REF(s, "chttp2_writing:become"); - grpc_chttp2_initiate_write(exec_ctx, t, covered_by_poller, reason); + } + switch (stream_write_type) { + case GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK: + break; + case GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED: + grpc_chttp2_initiate_write(exec_ctx, t, true, reason); + break; + case GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED: + grpc_chttp2_initiate_write(exec_ctx, t, false, reason); + break; } } @@ -837,7 +845,9 @@ static void maybe_start_some_streams(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); post_destructive_reclaimer(exec_ctx, t); - grpc_chttp2_become_writable(exec_ctx, t, s, true, "new_stream"); + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, + "new_stream"); } /* cancel out streams that will never be started */ while (t->next_stream_id >= MAX_CLIENT_STREAM_ID && @@ -932,7 +942,9 @@ static void maybe_become_writable_due_to_send_msg(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s) { if (s->id != 0 && (!s->write_buffering || s->flow_controlled_buffer.length > t->write_buffer_size)) { - grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message"); + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, + "op.send_message"); } } @@ -1094,7 +1106,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, } } else { GPR_ASSERT(s->id != 0); - grpc_chttp2_become_writable(exec_ctx, t, s, true, + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, "op.send_initial_metadata"); } } else { @@ -1185,7 +1198,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, } else if (s->id != 0) { /* TODO(ctiller): check if there's flow control for any outstanding bytes before going writable */ - grpc_chttp2_become_writable(exec_ctx, t, s, true, + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, "op.send_trailing_metadata"); } } @@ -1866,7 +1880,9 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, if (t->initial_window_update > 0) { grpc_chttp2_stream *s; while (grpc_chttp2_list_pop_stalled_by_stream(t, &s)) { - grpc_chttp2_become_writable(exec_ctx, t, s, false, "unstalled"); + grpc_chttp2_become_writable( + exec_ctx, t, s, GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED, + "unstalled"); } } t->initial_window_update = 0; @@ -2024,27 +2040,22 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, if (s->incoming_window_delta < max_recv_bytes) { uint32_t add_max_recv_bytes = (uint32_t)(max_recv_bytes - s->incoming_window_delta); - bool new_window_write_is_covered_by_poller = - s->incoming_window_delta + initial_window_size < (int64_t)have_already; - /* gpr_log(GPR_DEBUG, "%d %d %d", - (int)(s->incoming_window_delta - s->announce_window), - (int)(-(int64_t)initial_window_size / 2), force_send); */ + grpc_chttp2_stream_write_type write_type = + GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED; + if (s->incoming_window_delta + initial_window_size < + (int64_t)have_already) { + write_type = GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED; + } + if (s->incoming_window_delta - s->announce_window < + -(int64_t)initial_window_size / 2) { + write_type = GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK; + } GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, incoming_window_delta, add_max_recv_bytes); GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, announce_window, add_max_recv_bytes); - bool force_send = (s->incoming_window_delta - s->announce_window <= - -(int64_t)initial_window_size / 2) || - s->announce_window > initial_window_size / 2; - /* gpr_log(GPR_DEBUG, "%s:%d: iwd=%d ann=%d iws=%d force=%d", - t->peer_string, - s->id, (int)s->incoming_window_delta, (int)s->announce_window, - initial_window_size, force_send); */ - if (force_send) { - grpc_chttp2_become_writable(exec_ctx, t, s, - new_window_write_is_covered_by_poller, - "read_incoming_stream"); - } + grpc_chttp2_become_writable(exec_ctx, t, s, write_type, + "read_incoming_stream"); } } diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.c b/src/core/ext/transport/chttp2/transport/frame_window_update.c index 83901f8d95..8fa0bb471a 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.c +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.c @@ -113,8 +113,9 @@ grpc_error *grpc_chttp2_window_update_parser_parse( GRPC_CHTTP2_FLOW_CREDIT_STREAM("parse", t, s, outgoing_window_delta, received_update); if (grpc_chttp2_list_remove_stalled_by_stream(t, s)) { - grpc_chttp2_become_writable(exec_ctx, t, s, false, - "stream.read_flow_control"); + grpc_chttp2_become_writable( + exec_ctx, t, s, GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED, + "stream.read_flow_control"); } } } else { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index fca6302392..1dabf9edba 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -714,11 +714,21 @@ void grpc_chttp2_incoming_byte_stream_finished( void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, uint64_t id); +typedef enum { + /* don't initiate a transport write, but piggyback on the next one */ + GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK, + /* initiate a covered write */ + GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED, + /* initiate an uncovered write */ + GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED +} grpc_chttp2_stream_write_type; + /** add a ref to the stream and add it to the writable list; ref will be dropped in writing.c */ void grpc_chttp2_become_writable(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - grpc_chttp2_stream *s, bool covered_by_poller, + grpc_chttp2_stream *s, + grpc_chttp2_stream_write_type type, const char *reason); void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx, diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index ca9b931564..a882a0bba1 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -406,7 +406,8 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, incoming_frame_size); if (s->incoming_window_delta - s->announce_window <= -(int64_t)target_incoming_window / 2) { - grpc_chttp2_become_writable(exec_ctx, t, s, false, + grpc_chttp2_become_writable(exec_ctx, t, s, + GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED, "window-update-required"); } s->received_bytes += incoming_frame_size; -- cgit v1.2.3 From 81bcff7bceb247a548476e7fefcdfb7d9dda97d3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 2 Feb 2017 10:27:20 -0800 Subject: Flip conditional --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index db464bbc6b..272f5fcf8c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -2046,7 +2046,7 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, (int64_t)have_already) { write_type = GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED; } - if (s->incoming_window_delta - s->announce_window < + if (s->incoming_window_delta - s->announce_window > -(int64_t)initial_window_size / 2) { write_type = GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK; } -- cgit v1.2.3 From 4fd2bf6ec964dae973040984e5b5b387fe2f72e1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 3 Feb 2017 10:47:59 -0800 Subject: Dont credit flow control after stream has closed reading --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 272f5fcf8c..fb5ae575db 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -2037,7 +2037,7 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, /* add some small lookahead to keep pipelines flowing */ GPR_ASSERT(max_recv_bytes <= UINT32_MAX - initial_window_size); - if (s->incoming_window_delta < max_recv_bytes) { + if (s->incoming_window_delta < max_recv_bytes && !s->read_closed) { uint32_t add_max_recv_bytes = (uint32_t)(max_recv_bytes - s->incoming_window_delta); grpc_chttp2_stream_write_type write_type = -- cgit v1.2.3 From 8b1d59cafac9b2dd30cd080450ee68e85a039dc4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 27 Dec 2016 15:15:30 -0800 Subject: Add some debug utilities This PR adds a set of debug helpers that are intended for calling only from gdb. They cross abstraction boundaries and allow quickly accessing one thing from another thing. I expect to grow this library significantly over time to aid debugging tricky problems. --- CMakeLists.txt | 239 +++++ Makefile | 231 +++++ build.yaml | 11 + src/core/ext/client_channel/client_channel.c | 6 + src/core/ext/client_channel/client_channel.h | 4 + src/core/ext/debug/debugger_macros.c | 71 ++ src/core/ext/debug/debugger_macros.h | 39 + src/core/lib/channel/connected_channel.c | 6 +- src/core/lib/channel/connected_channel.h | 5 + templates/test/core/end2end/end2end_defs.include | 3 + test/core/end2end/end2end_nosec_tests.c | 3 + test/core/end2end/end2end_tests.c | 3 + tools/buildgen/plugins/expand_filegroups.py | 2 +- tools/run_tests/generated/sources_and_headers.json | 24 +- .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 124 +++ .../grpc_test_util/grpc_test_util.vcxproj.filters | 264 +++++ .../grpc_test_util_unsecure.vcxproj | 493 +++++++++ .../grpc_test_util_unsecure.vcxproj.filters | 1064 ++++++++++++++++++++ 18 files changed, 2587 insertions(+), 5 deletions(-) create mode 100644 src/core/ext/debug/debugger_macros.c create mode 100644 src/core/ext/debug/debugger_macros.h (limited to 'src/core') diff --git a/CMakeLists.txt b/CMakeLists.txt index 1adf092f9b..3ae2197b16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1370,6 +1370,7 @@ add_library(grpc_test_util test/core/util/port_uv.c test/core/util/port_windows.c test/core/util/slice_splitter.c + src/core/ext/debug/debugger_macros.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1487,6 +1488,48 @@ add_library(grpc_test_util src/core/lib/transport/timeout_encoding.c src/core/lib/transport/transport.c src/core/lib/transport/transport_op_string.c + src/core/ext/client_channel/channel_connectivity.c + src/core/ext/client_channel/client_channel.c + src/core/ext/client_channel/client_channel_factory.c + src/core/ext/client_channel/client_channel_plugin.c + src/core/ext/client_channel/connector.c + src/core/ext/client_channel/default_initial_connect_string.c + src/core/ext/client_channel/http_connect_handshaker.c + src/core/ext/client_channel/http_proxy.c + src/core/ext/client_channel/initial_connect_string.c + src/core/ext/client_channel/lb_policy.c + src/core/ext/client_channel/lb_policy_factory.c + src/core/ext/client_channel/lb_policy_registry.c + src/core/ext/client_channel/parse_address.c + src/core/ext/client_channel/proxy_mapper.c + src/core/ext/client_channel/proxy_mapper_registry.c + src/core/ext/client_channel/resolver.c + src/core/ext/client_channel/resolver_factory.c + src/core/ext/client_channel/resolver_registry.c + src/core/ext/client_channel/subchannel.c + src/core/ext/client_channel/subchannel_index.c + src/core/ext/client_channel/uri_parser.c + src/core/ext/transport/chttp2/transport/bin_decoder.c + src/core/ext/transport/chttp2/transport/bin_encoder.c + src/core/ext/transport/chttp2/transport/chttp2_plugin.c + src/core/ext/transport/chttp2/transport/chttp2_transport.c + src/core/ext/transport/chttp2/transport/frame_data.c + src/core/ext/transport/chttp2/transport/frame_goaway.c + src/core/ext/transport/chttp2/transport/frame_ping.c + src/core/ext/transport/chttp2/transport/frame_rst_stream.c + src/core/ext/transport/chttp2/transport/frame_settings.c + src/core/ext/transport/chttp2/transport/frame_window_update.c + src/core/ext/transport/chttp2/transport/hpack_encoder.c + src/core/ext/transport/chttp2/transport/hpack_parser.c + src/core/ext/transport/chttp2/transport/hpack_table.c + src/core/ext/transport/chttp2/transport/huffsyms.c + src/core/ext/transport/chttp2/transport/incoming_metadata.c + src/core/ext/transport/chttp2/transport/parsing.c + src/core/ext/transport/chttp2/transport/stream_lists.c + src/core/ext/transport/chttp2/transport/stream_map.c + src/core/ext/transport/chttp2/transport/varint.c + src/core/ext/transport/chttp2/transport/writing.c + src/core/ext/transport/chttp2/alpn/alpn.c ) @@ -1564,6 +1607,166 @@ add_library(grpc_test_util_unsecure test/core/util/port_uv.c test/core/util/port_windows.c test/core/util/slice_splitter.c + src/core/ext/debug/debugger_macros.c + src/core/lib/channel/channel_args.c + src/core/lib/channel/channel_stack.c + src/core/lib/channel/channel_stack_builder.c + src/core/lib/channel/compress_filter.c + src/core/lib/channel/connected_channel.c + src/core/lib/channel/deadline_filter.c + src/core/lib/channel/handshaker.c + src/core/lib/channel/handshaker_factory.c + src/core/lib/channel/handshaker_registry.c + src/core/lib/channel/http_client_filter.c + src/core/lib/channel/http_server_filter.c + src/core/lib/channel/message_size_filter.c + src/core/lib/compression/compression.c + src/core/lib/compression/message_compress.c + src/core/lib/debug/trace.c + src/core/lib/http/format_request.c + src/core/lib/http/httpcli.c + src/core/lib/http/parser.c + src/core/lib/iomgr/closure.c + src/core/lib/iomgr/combiner.c + src/core/lib/iomgr/endpoint.c + src/core/lib/iomgr/endpoint_pair_posix.c + src/core/lib/iomgr/endpoint_pair_uv.c + src/core/lib/iomgr/endpoint_pair_windows.c + src/core/lib/iomgr/error.c + src/core/lib/iomgr/ev_epoll_linux.c + src/core/lib/iomgr/ev_poll_posix.c + src/core/lib/iomgr/ev_posix.c + src/core/lib/iomgr/exec_ctx.c + src/core/lib/iomgr/executor.c + src/core/lib/iomgr/iocp_windows.c + src/core/lib/iomgr/iomgr.c + src/core/lib/iomgr/iomgr_posix.c + src/core/lib/iomgr/iomgr_uv.c + src/core/lib/iomgr/iomgr_windows.c + src/core/lib/iomgr/load_file.c + src/core/lib/iomgr/network_status_tracker.c + src/core/lib/iomgr/polling_entity.c + src/core/lib/iomgr/pollset_set_uv.c + src/core/lib/iomgr/pollset_set_windows.c + src/core/lib/iomgr/pollset_uv.c + src/core/lib/iomgr/pollset_windows.c + src/core/lib/iomgr/resolve_address_posix.c + src/core/lib/iomgr/resolve_address_uv.c + src/core/lib/iomgr/resolve_address_windows.c + src/core/lib/iomgr/resource_quota.c + src/core/lib/iomgr/sockaddr_utils.c + src/core/lib/iomgr/socket_mutator.c + src/core/lib/iomgr/socket_utils_common_posix.c + src/core/lib/iomgr/socket_utils_linux.c + src/core/lib/iomgr/socket_utils_posix.c + src/core/lib/iomgr/socket_utils_uv.c + src/core/lib/iomgr/socket_utils_windows.c + src/core/lib/iomgr/socket_windows.c + src/core/lib/iomgr/tcp_client_posix.c + src/core/lib/iomgr/tcp_client_uv.c + src/core/lib/iomgr/tcp_client_windows.c + src/core/lib/iomgr/tcp_posix.c + src/core/lib/iomgr/tcp_server_posix.c + src/core/lib/iomgr/tcp_server_uv.c + src/core/lib/iomgr/tcp_server_windows.c + src/core/lib/iomgr/tcp_uv.c + src/core/lib/iomgr/tcp_windows.c + src/core/lib/iomgr/time_averaged_stats.c + src/core/lib/iomgr/timer_generic.c + src/core/lib/iomgr/timer_heap.c + src/core/lib/iomgr/timer_uv.c + src/core/lib/iomgr/udp_server.c + src/core/lib/iomgr/unix_sockets_posix.c + src/core/lib/iomgr/unix_sockets_posix_noop.c + src/core/lib/iomgr/wakeup_fd_cv.c + src/core/lib/iomgr/wakeup_fd_eventfd.c + src/core/lib/iomgr/wakeup_fd_nospecial.c + src/core/lib/iomgr/wakeup_fd_pipe.c + src/core/lib/iomgr/wakeup_fd_posix.c + src/core/lib/iomgr/workqueue_uv.c + src/core/lib/iomgr/workqueue_windows.c + src/core/lib/json/json.c + src/core/lib/json/json_reader.c + src/core/lib/json/json_string.c + src/core/lib/json/json_writer.c + src/core/lib/slice/percent_encoding.c + src/core/lib/slice/slice.c + src/core/lib/slice/slice_buffer.c + src/core/lib/slice/slice_hash_table.c + src/core/lib/slice/slice_intern.c + src/core/lib/slice/slice_string_helpers.c + src/core/lib/surface/alarm.c + src/core/lib/surface/api_trace.c + src/core/lib/surface/byte_buffer.c + src/core/lib/surface/byte_buffer_reader.c + src/core/lib/surface/call.c + src/core/lib/surface/call_details.c + src/core/lib/surface/call_log_batch.c + src/core/lib/surface/channel.c + src/core/lib/surface/channel_init.c + src/core/lib/surface/channel_ping.c + src/core/lib/surface/channel_stack_type.c + src/core/lib/surface/completion_queue.c + src/core/lib/surface/event_string.c + src/core/lib/surface/lame_client.c + src/core/lib/surface/metadata_array.c + src/core/lib/surface/server.c + src/core/lib/surface/validate_metadata.c + src/core/lib/surface/version.c + src/core/lib/transport/byte_stream.c + src/core/lib/transport/connectivity_state.c + src/core/lib/transport/error_utils.c + src/core/lib/transport/metadata.c + src/core/lib/transport/metadata_batch.c + src/core/lib/transport/pid_controller.c + src/core/lib/transport/service_config.c + src/core/lib/transport/static_metadata.c + src/core/lib/transport/status_conversion.c + src/core/lib/transport/timeout_encoding.c + src/core/lib/transport/transport.c + src/core/lib/transport/transport_op_string.c + src/core/ext/client_channel/channel_connectivity.c + src/core/ext/client_channel/client_channel.c + src/core/ext/client_channel/client_channel_factory.c + src/core/ext/client_channel/client_channel_plugin.c + src/core/ext/client_channel/connector.c + src/core/ext/client_channel/default_initial_connect_string.c + src/core/ext/client_channel/http_connect_handshaker.c + src/core/ext/client_channel/http_proxy.c + src/core/ext/client_channel/initial_connect_string.c + src/core/ext/client_channel/lb_policy.c + src/core/ext/client_channel/lb_policy_factory.c + src/core/ext/client_channel/lb_policy_registry.c + src/core/ext/client_channel/parse_address.c + src/core/ext/client_channel/proxy_mapper.c + src/core/ext/client_channel/proxy_mapper_registry.c + src/core/ext/client_channel/resolver.c + src/core/ext/client_channel/resolver_factory.c + src/core/ext/client_channel/resolver_registry.c + src/core/ext/client_channel/subchannel.c + src/core/ext/client_channel/subchannel_index.c + src/core/ext/client_channel/uri_parser.c + src/core/ext/transport/chttp2/transport/bin_decoder.c + src/core/ext/transport/chttp2/transport/bin_encoder.c + src/core/ext/transport/chttp2/transport/chttp2_plugin.c + src/core/ext/transport/chttp2/transport/chttp2_transport.c + src/core/ext/transport/chttp2/transport/frame_data.c + src/core/ext/transport/chttp2/transport/frame_goaway.c + src/core/ext/transport/chttp2/transport/frame_ping.c + src/core/ext/transport/chttp2/transport/frame_rst_stream.c + src/core/ext/transport/chttp2/transport/frame_settings.c + src/core/ext/transport/chttp2/transport/frame_window_update.c + src/core/ext/transport/chttp2/transport/hpack_encoder.c + src/core/ext/transport/chttp2/transport/hpack_parser.c + src/core/ext/transport/chttp2/transport/hpack_table.c + src/core/ext/transport/chttp2/transport/huffsyms.c + src/core/ext/transport/chttp2/transport/incoming_metadata.c + src/core/ext/transport/chttp2/transport/parsing.c + src/core/ext/transport/chttp2/transport/stream_lists.c + src/core/ext/transport/chttp2/transport/stream_map.c + src/core/ext/transport/chttp2/transport/varint.c + src/core/ext/transport/chttp2/transport/writing.c + src/core/ext/transport/chttp2/alpn/alpn.c ) @@ -1586,6 +1789,42 @@ target_link_libraries(grpc_test_util_unsecure grpc ) +foreach(_hdr + include/grpc/byte_buffer.h + include/grpc/byte_buffer_reader.h + include/grpc/compression.h + include/grpc/grpc.h + include/grpc/grpc_posix.h + include/grpc/grpc_security_constants.h + include/grpc/slice.h + include/grpc/slice_buffer.h + include/grpc/status.h + include/grpc/impl/codegen/byte_buffer_reader.h + include/grpc/impl/codegen/compression_types.h + include/grpc/impl/codegen/connectivity_state.h + include/grpc/impl/codegen/exec_ctx_fwd.h + include/grpc/impl/codegen/grpc_types.h + include/grpc/impl/codegen/propagation_bits.h + include/grpc/impl/codegen/status.h + include/grpc/impl/codegen/atm.h + include/grpc/impl/codegen/atm_gcc_atomic.h + include/grpc/impl/codegen/atm_gcc_sync.h + include/grpc/impl/codegen/atm_windows.h + include/grpc/impl/codegen/gpr_slice.h + include/grpc/impl/codegen/gpr_types.h + include/grpc/impl/codegen/port_platform.h + include/grpc/impl/codegen/slice.h + include/grpc/impl/codegen/sync.h + include/grpc/impl/codegen/sync_generic.h + include/grpc/impl/codegen/sync_posix.h + include/grpc/impl/codegen/sync_windows.h +) + string(REPLACE "include/" "" _path ${_hdr}) + get_filename_component(_path ${_path} PATH) + install(FILES ${_hdr} + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + ) +endforeach() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index 66b5db7f03..c575624a74 100644 --- a/Makefile +++ b/Makefile @@ -3230,6 +3230,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_uv.c \ test/core/util/port_windows.c \ test/core/util/slice_splitter.c \ + src/core/ext/debug/debugger_macros.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3347,6 +3348,48 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ src/core/lib/transport/transport_op_string.c \ + src/core/ext/client_channel/channel_connectivity.c \ + src/core/ext/client_channel/client_channel.c \ + src/core/ext/client_channel/client_channel_factory.c \ + src/core/ext/client_channel/client_channel_plugin.c \ + src/core/ext/client_channel/connector.c \ + src/core/ext/client_channel/default_initial_connect_string.c \ + src/core/ext/client_channel/http_connect_handshaker.c \ + src/core/ext/client_channel/http_proxy.c \ + src/core/ext/client_channel/initial_connect_string.c \ + src/core/ext/client_channel/lb_policy.c \ + src/core/ext/client_channel/lb_policy_factory.c \ + src/core/ext/client_channel/lb_policy_registry.c \ + src/core/ext/client_channel/parse_address.c \ + src/core/ext/client_channel/proxy_mapper.c \ + src/core/ext/client_channel/proxy_mapper_registry.c \ + src/core/ext/client_channel/resolver.c \ + src/core/ext/client_channel/resolver_factory.c \ + src/core/ext/client_channel/resolver_registry.c \ + src/core/ext/client_channel/subchannel.c \ + src/core/ext/client_channel/subchannel_index.c \ + src/core/ext/client_channel/uri_parser.c \ + src/core/ext/transport/chttp2/transport/bin_decoder.c \ + src/core/ext/transport/chttp2/transport/bin_encoder.c \ + src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ + src/core/ext/transport/chttp2/transport/chttp2_transport.c \ + src/core/ext/transport/chttp2/transport/frame_data.c \ + src/core/ext/transport/chttp2/transport/frame_goaway.c \ + src/core/ext/transport/chttp2/transport/frame_ping.c \ + src/core/ext/transport/chttp2/transport/frame_rst_stream.c \ + src/core/ext/transport/chttp2/transport/frame_settings.c \ + src/core/ext/transport/chttp2/transport/frame_window_update.c \ + src/core/ext/transport/chttp2/transport/hpack_encoder.c \ + src/core/ext/transport/chttp2/transport/hpack_parser.c \ + src/core/ext/transport/chttp2/transport/hpack_table.c \ + src/core/ext/transport/chttp2/transport/huffsyms.c \ + src/core/ext/transport/chttp2/transport/incoming_metadata.c \ + src/core/ext/transport/chttp2/transport/parsing.c \ + src/core/ext/transport/chttp2/transport/stream_lists.c \ + src/core/ext/transport/chttp2/transport/stream_map.c \ + src/core/ext/transport/chttp2/transport/varint.c \ + src/core/ext/transport/chttp2/transport/writing.c \ + src/core/ext/transport/chttp2/alpn/alpn.c \ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer.h \ @@ -3428,8 +3471,196 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/port_uv.c \ test/core/util/port_windows.c \ test/core/util/slice_splitter.c \ + src/core/ext/debug/debugger_macros.c \ + src/core/lib/channel/channel_args.c \ + src/core/lib/channel/channel_stack.c \ + src/core/lib/channel/channel_stack_builder.c \ + src/core/lib/channel/compress_filter.c \ + src/core/lib/channel/connected_channel.c \ + src/core/lib/channel/deadline_filter.c \ + src/core/lib/channel/handshaker.c \ + src/core/lib/channel/handshaker_factory.c \ + src/core/lib/channel/handshaker_registry.c \ + src/core/lib/channel/http_client_filter.c \ + src/core/lib/channel/http_server_filter.c \ + src/core/lib/channel/message_size_filter.c \ + src/core/lib/compression/compression.c \ + src/core/lib/compression/message_compress.c \ + src/core/lib/debug/trace.c \ + src/core/lib/http/format_request.c \ + src/core/lib/http/httpcli.c \ + src/core/lib/http/parser.c \ + src/core/lib/iomgr/closure.c \ + src/core/lib/iomgr/combiner.c \ + src/core/lib/iomgr/endpoint.c \ + src/core/lib/iomgr/endpoint_pair_posix.c \ + src/core/lib/iomgr/endpoint_pair_uv.c \ + src/core/lib/iomgr/endpoint_pair_windows.c \ + src/core/lib/iomgr/error.c \ + src/core/lib/iomgr/ev_epoll_linux.c \ + src/core/lib/iomgr/ev_poll_posix.c \ + src/core/lib/iomgr/ev_posix.c \ + src/core/lib/iomgr/exec_ctx.c \ + src/core/lib/iomgr/executor.c \ + src/core/lib/iomgr/iocp_windows.c \ + src/core/lib/iomgr/iomgr.c \ + src/core/lib/iomgr/iomgr_posix.c \ + src/core/lib/iomgr/iomgr_uv.c \ + src/core/lib/iomgr/iomgr_windows.c \ + src/core/lib/iomgr/load_file.c \ + src/core/lib/iomgr/network_status_tracker.c \ + src/core/lib/iomgr/polling_entity.c \ + src/core/lib/iomgr/pollset_set_uv.c \ + src/core/lib/iomgr/pollset_set_windows.c \ + src/core/lib/iomgr/pollset_uv.c \ + src/core/lib/iomgr/pollset_windows.c \ + src/core/lib/iomgr/resolve_address_posix.c \ + src/core/lib/iomgr/resolve_address_uv.c \ + src/core/lib/iomgr/resolve_address_windows.c \ + src/core/lib/iomgr/resource_quota.c \ + src/core/lib/iomgr/sockaddr_utils.c \ + src/core/lib/iomgr/socket_mutator.c \ + src/core/lib/iomgr/socket_utils_common_posix.c \ + src/core/lib/iomgr/socket_utils_linux.c \ + src/core/lib/iomgr/socket_utils_posix.c \ + src/core/lib/iomgr/socket_utils_uv.c \ + src/core/lib/iomgr/socket_utils_windows.c \ + src/core/lib/iomgr/socket_windows.c \ + src/core/lib/iomgr/tcp_client_posix.c \ + src/core/lib/iomgr/tcp_client_uv.c \ + src/core/lib/iomgr/tcp_client_windows.c \ + src/core/lib/iomgr/tcp_posix.c \ + src/core/lib/iomgr/tcp_server_posix.c \ + src/core/lib/iomgr/tcp_server_uv.c \ + src/core/lib/iomgr/tcp_server_windows.c \ + src/core/lib/iomgr/tcp_uv.c \ + src/core/lib/iomgr/tcp_windows.c \ + src/core/lib/iomgr/time_averaged_stats.c \ + src/core/lib/iomgr/timer_generic.c \ + src/core/lib/iomgr/timer_heap.c \ + src/core/lib/iomgr/timer_uv.c \ + src/core/lib/iomgr/udp_server.c \ + src/core/lib/iomgr/unix_sockets_posix.c \ + src/core/lib/iomgr/unix_sockets_posix_noop.c \ + src/core/lib/iomgr/wakeup_fd_cv.c \ + src/core/lib/iomgr/wakeup_fd_eventfd.c \ + src/core/lib/iomgr/wakeup_fd_nospecial.c \ + src/core/lib/iomgr/wakeup_fd_pipe.c \ + src/core/lib/iomgr/wakeup_fd_posix.c \ + src/core/lib/iomgr/workqueue_uv.c \ + src/core/lib/iomgr/workqueue_windows.c \ + src/core/lib/json/json.c \ + src/core/lib/json/json_reader.c \ + src/core/lib/json/json_string.c \ + src/core/lib/json/json_writer.c \ + src/core/lib/slice/percent_encoding.c \ + src/core/lib/slice/slice.c \ + src/core/lib/slice/slice_buffer.c \ + src/core/lib/slice/slice_hash_table.c \ + src/core/lib/slice/slice_intern.c \ + src/core/lib/slice/slice_string_helpers.c \ + src/core/lib/surface/alarm.c \ + src/core/lib/surface/api_trace.c \ + src/core/lib/surface/byte_buffer.c \ + src/core/lib/surface/byte_buffer_reader.c \ + src/core/lib/surface/call.c \ + src/core/lib/surface/call_details.c \ + src/core/lib/surface/call_log_batch.c \ + src/core/lib/surface/channel.c \ + src/core/lib/surface/channel_init.c \ + src/core/lib/surface/channel_ping.c \ + src/core/lib/surface/channel_stack_type.c \ + src/core/lib/surface/completion_queue.c \ + src/core/lib/surface/event_string.c \ + src/core/lib/surface/lame_client.c \ + src/core/lib/surface/metadata_array.c \ + src/core/lib/surface/server.c \ + src/core/lib/surface/validate_metadata.c \ + src/core/lib/surface/version.c \ + src/core/lib/transport/byte_stream.c \ + src/core/lib/transport/connectivity_state.c \ + src/core/lib/transport/error_utils.c \ + src/core/lib/transport/metadata.c \ + src/core/lib/transport/metadata_batch.c \ + src/core/lib/transport/pid_controller.c \ + src/core/lib/transport/service_config.c \ + src/core/lib/transport/static_metadata.c \ + src/core/lib/transport/status_conversion.c \ + src/core/lib/transport/timeout_encoding.c \ + src/core/lib/transport/transport.c \ + src/core/lib/transport/transport_op_string.c \ + src/core/ext/client_channel/channel_connectivity.c \ + src/core/ext/client_channel/client_channel.c \ + src/core/ext/client_channel/client_channel_factory.c \ + src/core/ext/client_channel/client_channel_plugin.c \ + src/core/ext/client_channel/connector.c \ + src/core/ext/client_channel/default_initial_connect_string.c \ + src/core/ext/client_channel/http_connect_handshaker.c \ + src/core/ext/client_channel/http_proxy.c \ + src/core/ext/client_channel/initial_connect_string.c \ + src/core/ext/client_channel/lb_policy.c \ + src/core/ext/client_channel/lb_policy_factory.c \ + src/core/ext/client_channel/lb_policy_registry.c \ + src/core/ext/client_channel/parse_address.c \ + src/core/ext/client_channel/proxy_mapper.c \ + src/core/ext/client_channel/proxy_mapper_registry.c \ + src/core/ext/client_channel/resolver.c \ + src/core/ext/client_channel/resolver_factory.c \ + src/core/ext/client_channel/resolver_registry.c \ + src/core/ext/client_channel/subchannel.c \ + src/core/ext/client_channel/subchannel_index.c \ + src/core/ext/client_channel/uri_parser.c \ + src/core/ext/transport/chttp2/transport/bin_decoder.c \ + src/core/ext/transport/chttp2/transport/bin_encoder.c \ + src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ + src/core/ext/transport/chttp2/transport/chttp2_transport.c \ + src/core/ext/transport/chttp2/transport/frame_data.c \ + src/core/ext/transport/chttp2/transport/frame_goaway.c \ + src/core/ext/transport/chttp2/transport/frame_ping.c \ + src/core/ext/transport/chttp2/transport/frame_rst_stream.c \ + src/core/ext/transport/chttp2/transport/frame_settings.c \ + src/core/ext/transport/chttp2/transport/frame_window_update.c \ + src/core/ext/transport/chttp2/transport/hpack_encoder.c \ + src/core/ext/transport/chttp2/transport/hpack_parser.c \ + src/core/ext/transport/chttp2/transport/hpack_table.c \ + src/core/ext/transport/chttp2/transport/huffsyms.c \ + src/core/ext/transport/chttp2/transport/incoming_metadata.c \ + src/core/ext/transport/chttp2/transport/parsing.c \ + src/core/ext/transport/chttp2/transport/stream_lists.c \ + src/core/ext/transport/chttp2/transport/stream_map.c \ + src/core/ext/transport/chttp2/transport/varint.c \ + src/core/ext/transport/chttp2/transport/writing.c \ + src/core/ext/transport/chttp2/alpn/alpn.c \ PUBLIC_HEADERS_C += \ + include/grpc/byte_buffer.h \ + include/grpc/byte_buffer_reader.h \ + include/grpc/compression.h \ + include/grpc/grpc.h \ + include/grpc/grpc_posix.h \ + include/grpc/grpc_security_constants.h \ + include/grpc/slice.h \ + include/grpc/slice_buffer.h \ + include/grpc/status.h \ + include/grpc/impl/codegen/byte_buffer_reader.h \ + include/grpc/impl/codegen/compression_types.h \ + include/grpc/impl/codegen/connectivity_state.h \ + include/grpc/impl/codegen/exec_ctx_fwd.h \ + include/grpc/impl/codegen/grpc_types.h \ + include/grpc/impl/codegen/propagation_bits.h \ + include/grpc/impl/codegen/status.h \ + include/grpc/impl/codegen/atm.h \ + include/grpc/impl/codegen/atm_gcc_atomic.h \ + include/grpc/impl/codegen/atm_gcc_sync.h \ + include/grpc/impl/codegen/atm_windows.h \ + include/grpc/impl/codegen/gpr_slice.h \ + include/grpc/impl/codegen/gpr_types.h \ + include/grpc/impl/codegen/port_platform.h \ + include/grpc/impl/codegen/slice.h \ + include/grpc/impl/codegen/sync.h \ + include/grpc/impl/codegen/sync_generic.h \ + include/grpc/impl/codegen/sync_posix.h \ + include/grpc/impl/codegen/sync_windows.h \ LIBGRPC_TEST_UTIL_UNSECURE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_TEST_UTIL_UNSECURE_SRC)))) diff --git a/build.yaml b/build.yaml index 06b6eb3255..63a6e94059 100644 --- a/build.yaml +++ b/build.yaml @@ -447,6 +447,15 @@ filegroups: - include/grpc/impl/codegen/status.h uses: - gpr_codegen +- name: grpc_debug_macros + headers: + - src/core/ext/debug/debugger_macros.h + src: + - src/core/ext/debug/debugger_macros.c + uses: + - grpc_base + - grpc_client_channel + - grpc_transport_chttp2 - name: grpc_lb_policy_grpclb headers: - src/core/ext/lb_policy/grpclb/grpclb.h @@ -587,6 +596,8 @@ filegroups: deps: - grpc - gpr_test_util + uses: + - grpc_debug_macros - name: grpc_transport_chttp2 headers: - src/core/ext/transport/chttp2/transport/bin_decoder.h diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index 07eb68a3eb..208c95b67a 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -644,6 +644,12 @@ typedef struct client_channel_call_data { grpc_linked_mdelem lb_token_mdelem; } call_data; +grpc_subchannel_call *grpc_client_channel_get_subchannel_call( + grpc_call_element *call_elem) { + grpc_subchannel_call *scc = GET_CALL((call_data *)call_elem->call_data); + return scc == CANCELLED_CALL ? NULL : scc; +} + static void add_waiting_locked(call_data *calld, grpc_transport_stream_op *op) { GPR_TIMER_BEGIN("add_waiting_locked", 0); if (calld->waiting_ops_count == calld->waiting_ops_capacity) { diff --git a/src/core/ext/client_channel/client_channel.h b/src/core/ext/client_channel/client_channel.h index f02587d0c1..5e6e64e58b 100644 --- a/src/core/ext/client_channel/client_channel.h +++ b/src/core/ext/client_channel/client_channel.h @@ -57,4 +57,8 @@ void grpc_client_channel_watch_connectivity_state( grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_pollset *pollset, grpc_connectivity_state *state, grpc_closure *on_complete); +/* Debug helper: pull the subchannel call from a call stack element */ +grpc_subchannel_call *grpc_client_channel_get_subchannel_call( + grpc_call_element *elem); + #endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_CLIENT_CHANNEL_H */ diff --git a/src/core/ext/debug/debugger_macros.c b/src/core/ext/debug/debugger_macros.c new file mode 100644 index 0000000000..de6a2f38a7 --- /dev/null +++ b/src/core/ext/debug/debugger_macros.c @@ -0,0 +1,71 @@ +/* + * + * Copyright 2016, 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. + * + */ + +/* + * A collection of 'macros' that help navigating the grpc object hierarchy + * Not intended to be robust for main-line code, often cuts across abstraction + * boundaries. + */ + +#include + +#include "src/core/ext/client_channel/client_channel.h" +#include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/surface/call.h" + +void grpc_summon_debugger_macros() {} + +grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { + grpc_call_stack *cs = grpc_call_get_call_stack(call); + for (;;) { + grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1); + if (el->filter == &grpc_client_channel_filter) { + grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el); + if (scc == NULL) { + fprintf(stderr, "No subchannel-call"); + return NULL; + } + cs = grpc_subchannel_call_get_call_stack(scc); + } else if (el->filter == &grpc_connected_filter) { + return grpc_connected_channel_get_stream(el); + } else { + fprintf(stderr, "Unrecognized filter: %s", el->filter->name); + return NULL; + } + } +} + +grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) { + return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call); +} diff --git a/src/core/ext/debug/debugger_macros.h b/src/core/ext/debug/debugger_macros.h new file mode 100644 index 0000000000..4494176560 --- /dev/null +++ b/src/core/ext/debug/debugger_macros.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016, 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. + * + */ + +#ifndef DEBUGGER_MACROS_H +#define DEBUGGER_MACROS_H + +void grpc_summon_debugger_macros(); + +#endif diff --git a/src/core/lib/channel/connected_channel.c b/src/core/lib/channel/connected_channel.c index ccc0619e1c..068c61c92a 100644 --- a/src/core/lib/channel/connected_channel.c +++ b/src/core/lib/channel/connected_channel.c @@ -140,7 +140,7 @@ static void con_get_channel_info(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, const grpc_channel_info *channel_info) {} -static const grpc_channel_filter connected_channel_filter = { +const grpc_channel_filter grpc_connected_filter = { con_start_transport_stream_op, con_start_transport_op, sizeof(call_data), @@ -158,7 +158,7 @@ static const grpc_channel_filter connected_channel_filter = { static void bind_transport(grpc_channel_stack *channel_stack, grpc_channel_element *elem, void *t) { channel_data *cd = (channel_data *)elem->channel_data; - GPR_ASSERT(elem->filter == &connected_channel_filter); + GPR_ASSERT(elem->filter == &grpc_connected_filter); GPR_ASSERT(cd->transport == NULL); cd->transport = t; @@ -178,7 +178,7 @@ bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx, grpc_transport *t = grpc_channel_stack_builder_get_transport(builder); GPR_ASSERT(t != NULL); return grpc_channel_stack_builder_append_filter( - builder, &connected_channel_filter, bind_transport, t); + builder, &grpc_connected_filter, bind_transport, t); } grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem) { diff --git a/src/core/lib/channel/connected_channel.h b/src/core/lib/channel/connected_channel.h index 3585c0ecbc..5c7ea9ed26 100644 --- a/src/core/lib/channel/connected_channel.h +++ b/src/core/lib/channel/connected_channel.h @@ -36,8 +36,13 @@ #include "src/core/lib/channel/channel_stack_builder.h" +extern const grpc_channel_filter grpc_connected_filter; + bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg_must_be_null); +/* Debug helper to dig the transport stream out of a call element */ +grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem); + #endif /* GRPC_CORE_LIB_CHANNEL_CONNECTED_CHANNEL_H */ diff --git a/templates/test/core/end2end/end2end_defs.include b/templates/test/core/end2end/end2end_defs.include index b828f84f1c..4086a30360 100644 --- a/templates/test/core/end2end/end2end_defs.include +++ b/templates/test/core/end2end/end2end_defs.include @@ -42,6 +42,8 @@ #include +#include "src/core/ext/debug/debugger_macros.h" + static bool g_pre_init_called = false; % for test in tests: @@ -52,6 +54,7 @@ extern void ${test}_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; + grpc_summon_debugger_macros(); % for test in tests: ${test}_pre_init(); % endfor diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index b162bf2f40..6a0032c324 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -41,6 +41,8 @@ #include +#include "src/core/ext/debug/debugger_macros.h" + static bool g_pre_init_called = false; extern void authority_not_supported(grpc_end2end_test_config config); @@ -143,6 +145,7 @@ extern void write_buffering_at_end_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; + grpc_summon_debugger_macros(); authority_not_supported_pre_init(); bad_hostname_pre_init(); binary_metadata_pre_init(); diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 9bca0c81f6..c9641d7d13 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -41,6 +41,8 @@ #include +#include "src/core/ext/debug/debugger_macros.h" + static bool g_pre_init_called = false; extern void authority_not_supported(grpc_end2end_test_config config); @@ -145,6 +147,7 @@ extern void write_buffering_at_end_pre_init(void); void grpc_end2end_tests_pre_init(void) { GPR_ASSERT(!g_pre_init_called); g_pre_init_called = true; + grpc_summon_debugger_macros(); authority_not_supported_pre_init(); bad_hostname_pre_init(); binary_metadata_pre_init(); diff --git a/tools/buildgen/plugins/expand_filegroups.py b/tools/buildgen/plugins/expand_filegroups.py index 477e69c869..46739f8f10 100755 --- a/tools/buildgen/plugins/expand_filegroups.py +++ b/tools/buildgen/plugins/expand_filegroups.py @@ -85,7 +85,7 @@ def mako_plugin(dictionary): skips = 0 while todo: - assert skips != len(todo), "infinite loop in filegroup uses clauses" + assert skips != len(todo), "infinite loop in filegroup uses clauses: %r" % [t['name'] for t in todo] # take the first element of the todo list cur = todo[0] todo = todo[1:] diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 900f9a6fe7..d24c37e007 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7449,6 +7449,26 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base", + "grpc_client_channel", + "grpc_transport_chttp2" + ], + "headers": [ + "src/core/ext/debug/debugger_macros.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_debug_macros", + "src": [ + "src/core/ext/debug/debugger_macros.c", + "src/core/ext/debug/debugger_macros.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", @@ -7643,8 +7663,10 @@ }, { "deps": [ + "gpr", "gpr_test_util", - "grpc" + "grpc", + "grpc_debug_macros" ], "headers": [ "test/core/end2end/cq_verifier.h", diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index 7d6685d4bf..5a0e09e1bb 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -192,6 +192,7 @@ + @@ -297,6 +298,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -339,6 +377,8 @@ + + @@ -573,6 +613,90 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index 1c21ff301c..be8024c7aa 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -61,6 +61,9 @@ test\core\util + + src\core\ext\debug + src\core\lib\channel @@ -412,6 +415,132 @@ src\core\lib\transport + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\alpn + @@ -545,6 +674,9 @@ test\core\util + + src\core\ext\debug + src\core\lib\channel @@ -860,6 +992,117 @@ src\core\lib\transport + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\alpn + @@ -881,6 +1124,27 @@ {f7bfac91-5eb2-dea7-4601-6c63edbbf997} + + {5db70e06-741d-708c-bf0a-b59f8ca1f8bd} + + + {7f75a084-6bc4-e813-f85b-120148aa35da} + + + {88f64b2c-ca67-05ef-c15b-8ab420357a2a} + + + {b5f17b17-8012-87c9-dfb2-428dd29d0b94} + + + {608f56aa-d257-f25b-14aa-1776a771defd} + + + {49d381db-172f-9765-4135-d7a10c4485bf} + + + {4395ba2e-6b6d-ea05-8a1e-915b8f0f85f6} + {f4e8c61e-1ca6-0fdd-7b5e-b7f9a30c9a21} diff --git a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj index 7f3e101e75..c9e18e94b0 100644 --- a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj @@ -146,6 +146,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -160,6 +190,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -192,6 +365,326 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters index 8be9f5b796..017e96ff62 100644 --- a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters @@ -46,6 +46,572 @@ test\core\util + + src\core\ext\debug + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\compression + + + src\core\lib\compression + + + src\core\lib\debug + + + src\core\lib\http + + + src\core\lib\http + + + src\core\lib\http + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\json + + + src\core\lib\json + + + src\core\lib\json + + + src\core\lib\json + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\alpn + + + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + + + include\grpc\impl\codegen + @@ -87,9 +653,507 @@ test\core\util + + src\core\ext\debug + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\channel + + + src\core\lib\compression + + + src\core\lib\compression + + + src\core\lib\debug + + + src\core\lib\http + + + src\core\lib\http + + + src\core\lib\http + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\iomgr + + + src\core\lib\json + + + src\core\lib\json + + + src\core\lib\json + + + src\core\lib\json + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\slice + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\surface + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\lib\transport + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\client_channel + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\transport + + + src\core\ext\transport\chttp2\alpn + + + {9793fab6-15ae-1f61-712d-c3d673654d72} + + + {c2447106-a6bf-6b88-9ad0-a42b7ac1573c} + + + {dba70812-267b-656c-9f8c-636338d3f5c0} + + + {b9e2ddac-f042-3042-ba4b-79ba4445e68c} + + + {65483377-42fd-137e-3847-00dfd4675db3} + + + {51a516dc-93e3-4dd5-d114-2d06f5df4ad7} + + + {a927155d-bcf6-0dd8-6d63-be48bcaf617f} + + + {ecb054bb-d7ce-b4db-7f82-ae022486c076} + + + {de5ce030-9e5d-b93a-da8f-ee5825ded59a} + + + {fb32254e-a807-768a-3686-4e87f3bf1e8e} + + + {87c61e56-5090-5e1a-22af-02e3c8bf4a2a} + + + {e50ce1d1-6b17-dad2-9ef3-46f68d4bee1b} + + + {67007111-23fe-296f-1808-91f2b96a31aa} + + + {e3d002a7-9318-1ac5-4259-e177f58ccc9a} + + + {ac14fd16-a4af-6b22-4226-2d7dabf25409} + + + {24268e45-f6c3-6024-b49a-d01bb9c12d96} + + + {0be401bd-3e26-dead-fdf4-2ce27a1ac3a3} + + + {ac2f12e3-ac77-f0a7-d15d-92899e61ed25} + + + {9015222c-df04-298f-3f2c-d19babffc180} + + + {c3ff117a-aae9-dedd-2f5a-888f0383cbb8} + + + {588ffbfc-2f94-a99f-85b0-4c47ec9f8d13} + + + {732318c6-bb34-9a99-611b-9928db3d4e2a} + + + {2c0ca4a1-38df-329d-eeba-5c5b61dc81a5} + {037c7645-1698-cf2d-4163-525240323101} -- cgit v1.2.3 From 61eb40ce56cd72b89afbfac2af400b64d627522d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 3 Feb 2017 13:46:33 -0800 Subject: Put files in a better place --- CMakeLists.txt | 241 +---- Makefile | 233 +---- build.yaml | 13 +- src/core/ext/debug/debugger_macros.c | 71 -- src/core/ext/debug/debugger_macros.h | 39 - templates/test/core/end2end/end2end_defs.include | 2 +- test/core/end2end/end2end_nosec_tests.c | 2 +- test/core/end2end/end2end_tests.c | 2 +- test/core/util/debugger_macros.c | 71 ++ test/core/util/debugger_macros.h | 39 + tools/run_tests/generated/sources_and_headers.json | 27 +- .../vcxproj/grpc_test_util/grpc_test_util.vcxproj | 127 +-- .../grpc_test_util/grpc_test_util.vcxproj.filters | 270 +---- .../grpc_test_util_unsecure.vcxproj | 496 +-------- .../grpc_test_util_unsecure.vcxproj.filters | 1070 +------------------- 15 files changed, 141 insertions(+), 2562 deletions(-) delete mode 100644 src/core/ext/debug/debugger_macros.c delete mode 100644 src/core/ext/debug/debugger_macros.h create mode 100644 test/core/util/debugger_macros.c create mode 100644 test/core/util/debugger_macros.h (limited to 'src/core') diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ae2197b16..3b320db1b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1360,6 +1360,7 @@ add_library(grpc_test_util test/core/end2end/fixtures/http_proxy.c test/core/end2end/fixtures/proxy.c test/core/iomgr/endpoint_tests.c + test/core/util/debugger_macros.c test/core/util/grpc_profiler.c test/core/util/memory_counters.c test/core/util/mock_endpoint.c @@ -1370,7 +1371,6 @@ add_library(grpc_test_util test/core/util/port_uv.c test/core/util/port_windows.c test/core/util/slice_splitter.c - src/core/ext/debug/debugger_macros.c src/core/lib/channel/channel_args.c src/core/lib/channel/channel_stack.c src/core/lib/channel/channel_stack_builder.c @@ -1488,48 +1488,6 @@ add_library(grpc_test_util src/core/lib/transport/timeout_encoding.c src/core/lib/transport/transport.c src/core/lib/transport/transport_op_string.c - src/core/ext/client_channel/channel_connectivity.c - src/core/ext/client_channel/client_channel.c - src/core/ext/client_channel/client_channel_factory.c - src/core/ext/client_channel/client_channel_plugin.c - src/core/ext/client_channel/connector.c - src/core/ext/client_channel/default_initial_connect_string.c - src/core/ext/client_channel/http_connect_handshaker.c - src/core/ext/client_channel/http_proxy.c - src/core/ext/client_channel/initial_connect_string.c - src/core/ext/client_channel/lb_policy.c - src/core/ext/client_channel/lb_policy_factory.c - src/core/ext/client_channel/lb_policy_registry.c - src/core/ext/client_channel/parse_address.c - src/core/ext/client_channel/proxy_mapper.c - src/core/ext/client_channel/proxy_mapper_registry.c - src/core/ext/client_channel/resolver.c - src/core/ext/client_channel/resolver_factory.c - src/core/ext/client_channel/resolver_registry.c - src/core/ext/client_channel/subchannel.c - src/core/ext/client_channel/subchannel_index.c - src/core/ext/client_channel/uri_parser.c - src/core/ext/transport/chttp2/transport/bin_decoder.c - src/core/ext/transport/chttp2/transport/bin_encoder.c - src/core/ext/transport/chttp2/transport/chttp2_plugin.c - src/core/ext/transport/chttp2/transport/chttp2_transport.c - src/core/ext/transport/chttp2/transport/frame_data.c - src/core/ext/transport/chttp2/transport/frame_goaway.c - src/core/ext/transport/chttp2/transport/frame_ping.c - src/core/ext/transport/chttp2/transport/frame_rst_stream.c - src/core/ext/transport/chttp2/transport/frame_settings.c - src/core/ext/transport/chttp2/transport/frame_window_update.c - src/core/ext/transport/chttp2/transport/hpack_encoder.c - src/core/ext/transport/chttp2/transport/hpack_parser.c - src/core/ext/transport/chttp2/transport/hpack_table.c - src/core/ext/transport/chttp2/transport/huffsyms.c - src/core/ext/transport/chttp2/transport/incoming_metadata.c - src/core/ext/transport/chttp2/transport/parsing.c - src/core/ext/transport/chttp2/transport/stream_lists.c - src/core/ext/transport/chttp2/transport/stream_map.c - src/core/ext/transport/chttp2/transport/varint.c - src/core/ext/transport/chttp2/transport/writing.c - src/core/ext/transport/chttp2/alpn/alpn.c ) @@ -1597,6 +1555,7 @@ add_library(grpc_test_util_unsecure test/core/end2end/fixtures/http_proxy.c test/core/end2end/fixtures/proxy.c test/core/iomgr/endpoint_tests.c + test/core/util/debugger_macros.c test/core/util/grpc_profiler.c test/core/util/memory_counters.c test/core/util/mock_endpoint.c @@ -1607,166 +1566,6 @@ add_library(grpc_test_util_unsecure test/core/util/port_uv.c test/core/util/port_windows.c test/core/util/slice_splitter.c - src/core/ext/debug/debugger_macros.c - src/core/lib/channel/channel_args.c - src/core/lib/channel/channel_stack.c - src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c - src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c - src/core/lib/channel/handshaker.c - src/core/lib/channel/handshaker_factory.c - src/core/lib/channel/handshaker_registry.c - src/core/lib/channel/http_client_filter.c - src/core/lib/channel/http_server_filter.c - src/core/lib/channel/message_size_filter.c - src/core/lib/compression/compression.c - src/core/lib/compression/message_compress.c - src/core/lib/debug/trace.c - src/core/lib/http/format_request.c - src/core/lib/http/httpcli.c - src/core/lib/http/parser.c - src/core/lib/iomgr/closure.c - src/core/lib/iomgr/combiner.c - src/core/lib/iomgr/endpoint.c - src/core/lib/iomgr/endpoint_pair_posix.c - src/core/lib/iomgr/endpoint_pair_uv.c - src/core/lib/iomgr/endpoint_pair_windows.c - src/core/lib/iomgr/error.c - src/core/lib/iomgr/ev_epoll_linux.c - src/core/lib/iomgr/ev_poll_posix.c - src/core/lib/iomgr/ev_posix.c - src/core/lib/iomgr/exec_ctx.c - src/core/lib/iomgr/executor.c - src/core/lib/iomgr/iocp_windows.c - src/core/lib/iomgr/iomgr.c - src/core/lib/iomgr/iomgr_posix.c - src/core/lib/iomgr/iomgr_uv.c - src/core/lib/iomgr/iomgr_windows.c - src/core/lib/iomgr/load_file.c - src/core/lib/iomgr/network_status_tracker.c - src/core/lib/iomgr/polling_entity.c - src/core/lib/iomgr/pollset_set_uv.c - src/core/lib/iomgr/pollset_set_windows.c - src/core/lib/iomgr/pollset_uv.c - src/core/lib/iomgr/pollset_windows.c - src/core/lib/iomgr/resolve_address_posix.c - src/core/lib/iomgr/resolve_address_uv.c - src/core/lib/iomgr/resolve_address_windows.c - src/core/lib/iomgr/resource_quota.c - src/core/lib/iomgr/sockaddr_utils.c - src/core/lib/iomgr/socket_mutator.c - src/core/lib/iomgr/socket_utils_common_posix.c - src/core/lib/iomgr/socket_utils_linux.c - src/core/lib/iomgr/socket_utils_posix.c - src/core/lib/iomgr/socket_utils_uv.c - src/core/lib/iomgr/socket_utils_windows.c - src/core/lib/iomgr/socket_windows.c - src/core/lib/iomgr/tcp_client_posix.c - src/core/lib/iomgr/tcp_client_uv.c - src/core/lib/iomgr/tcp_client_windows.c - src/core/lib/iomgr/tcp_posix.c - src/core/lib/iomgr/tcp_server_posix.c - src/core/lib/iomgr/tcp_server_uv.c - src/core/lib/iomgr/tcp_server_windows.c - src/core/lib/iomgr/tcp_uv.c - src/core/lib/iomgr/tcp_windows.c - src/core/lib/iomgr/time_averaged_stats.c - src/core/lib/iomgr/timer_generic.c - src/core/lib/iomgr/timer_heap.c - src/core/lib/iomgr/timer_uv.c - src/core/lib/iomgr/udp_server.c - src/core/lib/iomgr/unix_sockets_posix.c - src/core/lib/iomgr/unix_sockets_posix_noop.c - src/core/lib/iomgr/wakeup_fd_cv.c - src/core/lib/iomgr/wakeup_fd_eventfd.c - src/core/lib/iomgr/wakeup_fd_nospecial.c - src/core/lib/iomgr/wakeup_fd_pipe.c - src/core/lib/iomgr/wakeup_fd_posix.c - src/core/lib/iomgr/workqueue_uv.c - src/core/lib/iomgr/workqueue_windows.c - src/core/lib/json/json.c - src/core/lib/json/json_reader.c - src/core/lib/json/json_string.c - src/core/lib/json/json_writer.c - src/core/lib/slice/percent_encoding.c - src/core/lib/slice/slice.c - src/core/lib/slice/slice_buffer.c - src/core/lib/slice/slice_hash_table.c - src/core/lib/slice/slice_intern.c - src/core/lib/slice/slice_string_helpers.c - src/core/lib/surface/alarm.c - src/core/lib/surface/api_trace.c - src/core/lib/surface/byte_buffer.c - src/core/lib/surface/byte_buffer_reader.c - src/core/lib/surface/call.c - src/core/lib/surface/call_details.c - src/core/lib/surface/call_log_batch.c - src/core/lib/surface/channel.c - src/core/lib/surface/channel_init.c - src/core/lib/surface/channel_ping.c - src/core/lib/surface/channel_stack_type.c - src/core/lib/surface/completion_queue.c - src/core/lib/surface/event_string.c - src/core/lib/surface/lame_client.c - src/core/lib/surface/metadata_array.c - src/core/lib/surface/server.c - src/core/lib/surface/validate_metadata.c - src/core/lib/surface/version.c - src/core/lib/transport/byte_stream.c - src/core/lib/transport/connectivity_state.c - src/core/lib/transport/error_utils.c - src/core/lib/transport/metadata.c - src/core/lib/transport/metadata_batch.c - src/core/lib/transport/pid_controller.c - src/core/lib/transport/service_config.c - src/core/lib/transport/static_metadata.c - src/core/lib/transport/status_conversion.c - src/core/lib/transport/timeout_encoding.c - src/core/lib/transport/transport.c - src/core/lib/transport/transport_op_string.c - src/core/ext/client_channel/channel_connectivity.c - src/core/ext/client_channel/client_channel.c - src/core/ext/client_channel/client_channel_factory.c - src/core/ext/client_channel/client_channel_plugin.c - src/core/ext/client_channel/connector.c - src/core/ext/client_channel/default_initial_connect_string.c - src/core/ext/client_channel/http_connect_handshaker.c - src/core/ext/client_channel/http_proxy.c - src/core/ext/client_channel/initial_connect_string.c - src/core/ext/client_channel/lb_policy.c - src/core/ext/client_channel/lb_policy_factory.c - src/core/ext/client_channel/lb_policy_registry.c - src/core/ext/client_channel/parse_address.c - src/core/ext/client_channel/proxy_mapper.c - src/core/ext/client_channel/proxy_mapper_registry.c - src/core/ext/client_channel/resolver.c - src/core/ext/client_channel/resolver_factory.c - src/core/ext/client_channel/resolver_registry.c - src/core/ext/client_channel/subchannel.c - src/core/ext/client_channel/subchannel_index.c - src/core/ext/client_channel/uri_parser.c - src/core/ext/transport/chttp2/transport/bin_decoder.c - src/core/ext/transport/chttp2/transport/bin_encoder.c - src/core/ext/transport/chttp2/transport/chttp2_plugin.c - src/core/ext/transport/chttp2/transport/chttp2_transport.c - src/core/ext/transport/chttp2/transport/frame_data.c - src/core/ext/transport/chttp2/transport/frame_goaway.c - src/core/ext/transport/chttp2/transport/frame_ping.c - src/core/ext/transport/chttp2/transport/frame_rst_stream.c - src/core/ext/transport/chttp2/transport/frame_settings.c - src/core/ext/transport/chttp2/transport/frame_window_update.c - src/core/ext/transport/chttp2/transport/hpack_encoder.c - src/core/ext/transport/chttp2/transport/hpack_parser.c - src/core/ext/transport/chttp2/transport/hpack_table.c - src/core/ext/transport/chttp2/transport/huffsyms.c - src/core/ext/transport/chttp2/transport/incoming_metadata.c - src/core/ext/transport/chttp2/transport/parsing.c - src/core/ext/transport/chttp2/transport/stream_lists.c - src/core/ext/transport/chttp2/transport/stream_map.c - src/core/ext/transport/chttp2/transport/varint.c - src/core/ext/transport/chttp2/transport/writing.c - src/core/ext/transport/chttp2/alpn/alpn.c ) @@ -1789,42 +1588,6 @@ target_link_libraries(grpc_test_util_unsecure grpc ) -foreach(_hdr - include/grpc/byte_buffer.h - include/grpc/byte_buffer_reader.h - include/grpc/compression.h - include/grpc/grpc.h - include/grpc/grpc_posix.h - include/grpc/grpc_security_constants.h - include/grpc/slice.h - include/grpc/slice_buffer.h - include/grpc/status.h - include/grpc/impl/codegen/byte_buffer_reader.h - include/grpc/impl/codegen/compression_types.h - include/grpc/impl/codegen/connectivity_state.h - include/grpc/impl/codegen/exec_ctx_fwd.h - include/grpc/impl/codegen/grpc_types.h - include/grpc/impl/codegen/propagation_bits.h - include/grpc/impl/codegen/status.h - include/grpc/impl/codegen/atm.h - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h - include/grpc/impl/codegen/atm_windows.h - include/grpc/impl/codegen/gpr_slice.h - include/grpc/impl/codegen/gpr_types.h - include/grpc/impl/codegen/port_platform.h - include/grpc/impl/codegen/slice.h - include/grpc/impl/codegen/sync.h - include/grpc/impl/codegen/sync_generic.h - include/grpc/impl/codegen/sync_posix.h - include/grpc/impl/codegen/sync_windows.h -) - string(REPLACE "include/" "" _path ${_hdr}) - get_filename_component(_path ${_path} PATH) - install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" - ) -endforeach() endif (gRPC_BUILD_TESTS) diff --git a/Makefile b/Makefile index c575624a74..0d1d64cdcd 100644 --- a/Makefile +++ b/Makefile @@ -3220,6 +3220,7 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/end2end/fixtures/http_proxy.c \ test/core/end2end/fixtures/proxy.c \ test/core/iomgr/endpoint_tests.c \ + test/core/util/debugger_macros.c \ test/core/util/grpc_profiler.c \ test/core/util/memory_counters.c \ test/core/util/mock_endpoint.c \ @@ -3230,7 +3231,6 @@ LIBGRPC_TEST_UTIL_SRC = \ test/core/util/port_uv.c \ test/core/util/port_windows.c \ test/core/util/slice_splitter.c \ - src/core/ext/debug/debugger_macros.c \ src/core/lib/channel/channel_args.c \ src/core/lib/channel/channel_stack.c \ src/core/lib/channel/channel_stack_builder.c \ @@ -3348,48 +3348,6 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ src/core/lib/transport/transport_op_string.c \ - src/core/ext/client_channel/channel_connectivity.c \ - src/core/ext/client_channel/client_channel.c \ - src/core/ext/client_channel/client_channel_factory.c \ - src/core/ext/client_channel/client_channel_plugin.c \ - src/core/ext/client_channel/connector.c \ - src/core/ext/client_channel/default_initial_connect_string.c \ - src/core/ext/client_channel/http_connect_handshaker.c \ - src/core/ext/client_channel/http_proxy.c \ - src/core/ext/client_channel/initial_connect_string.c \ - src/core/ext/client_channel/lb_policy.c \ - src/core/ext/client_channel/lb_policy_factory.c \ - src/core/ext/client_channel/lb_policy_registry.c \ - src/core/ext/client_channel/parse_address.c \ - src/core/ext/client_channel/proxy_mapper.c \ - src/core/ext/client_channel/proxy_mapper_registry.c \ - src/core/ext/client_channel/resolver.c \ - src/core/ext/client_channel/resolver_factory.c \ - src/core/ext/client_channel/resolver_registry.c \ - src/core/ext/client_channel/subchannel.c \ - src/core/ext/client_channel/subchannel_index.c \ - src/core/ext/client_channel/uri_parser.c \ - src/core/ext/transport/chttp2/transport/bin_decoder.c \ - src/core/ext/transport/chttp2/transport/bin_encoder.c \ - src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ - src/core/ext/transport/chttp2/transport/chttp2_transport.c \ - src/core/ext/transport/chttp2/transport/frame_data.c \ - src/core/ext/transport/chttp2/transport/frame_goaway.c \ - src/core/ext/transport/chttp2/transport/frame_ping.c \ - src/core/ext/transport/chttp2/transport/frame_rst_stream.c \ - src/core/ext/transport/chttp2/transport/frame_settings.c \ - src/core/ext/transport/chttp2/transport/frame_window_update.c \ - src/core/ext/transport/chttp2/transport/hpack_encoder.c \ - src/core/ext/transport/chttp2/transport/hpack_parser.c \ - src/core/ext/transport/chttp2/transport/hpack_table.c \ - src/core/ext/transport/chttp2/transport/huffsyms.c \ - src/core/ext/transport/chttp2/transport/incoming_metadata.c \ - src/core/ext/transport/chttp2/transport/parsing.c \ - src/core/ext/transport/chttp2/transport/stream_lists.c \ - src/core/ext/transport/chttp2/transport/stream_map.c \ - src/core/ext/transport/chttp2/transport/varint.c \ - src/core/ext/transport/chttp2/transport/writing.c \ - src/core/ext/transport/chttp2/alpn/alpn.c \ PUBLIC_HEADERS_C += \ include/grpc/byte_buffer.h \ @@ -3461,6 +3419,7 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/end2end/fixtures/http_proxy.c \ test/core/end2end/fixtures/proxy.c \ test/core/iomgr/endpoint_tests.c \ + test/core/util/debugger_macros.c \ test/core/util/grpc_profiler.c \ test/core/util/memory_counters.c \ test/core/util/mock_endpoint.c \ @@ -3471,196 +3430,8 @@ LIBGRPC_TEST_UTIL_UNSECURE_SRC = \ test/core/util/port_uv.c \ test/core/util/port_windows.c \ test/core/util/slice_splitter.c \ - src/core/ext/debug/debugger_macros.c \ - src/core/lib/channel/channel_args.c \ - src/core/lib/channel/channel_stack.c \ - src/core/lib/channel/channel_stack_builder.c \ - src/core/lib/channel/compress_filter.c \ - src/core/lib/channel/connected_channel.c \ - src/core/lib/channel/deadline_filter.c \ - src/core/lib/channel/handshaker.c \ - src/core/lib/channel/handshaker_factory.c \ - src/core/lib/channel/handshaker_registry.c \ - src/core/lib/channel/http_client_filter.c \ - src/core/lib/channel/http_server_filter.c \ - src/core/lib/channel/message_size_filter.c \ - src/core/lib/compression/compression.c \ - src/core/lib/compression/message_compress.c \ - src/core/lib/debug/trace.c \ - src/core/lib/http/format_request.c \ - src/core/lib/http/httpcli.c \ - src/core/lib/http/parser.c \ - src/core/lib/iomgr/closure.c \ - src/core/lib/iomgr/combiner.c \ - src/core/lib/iomgr/endpoint.c \ - src/core/lib/iomgr/endpoint_pair_posix.c \ - src/core/lib/iomgr/endpoint_pair_uv.c \ - src/core/lib/iomgr/endpoint_pair_windows.c \ - src/core/lib/iomgr/error.c \ - src/core/lib/iomgr/ev_epoll_linux.c \ - src/core/lib/iomgr/ev_poll_posix.c \ - src/core/lib/iomgr/ev_posix.c \ - src/core/lib/iomgr/exec_ctx.c \ - src/core/lib/iomgr/executor.c \ - src/core/lib/iomgr/iocp_windows.c \ - src/core/lib/iomgr/iomgr.c \ - src/core/lib/iomgr/iomgr_posix.c \ - src/core/lib/iomgr/iomgr_uv.c \ - src/core/lib/iomgr/iomgr_windows.c \ - src/core/lib/iomgr/load_file.c \ - src/core/lib/iomgr/network_status_tracker.c \ - src/core/lib/iomgr/polling_entity.c \ - src/core/lib/iomgr/pollset_set_uv.c \ - src/core/lib/iomgr/pollset_set_windows.c \ - src/core/lib/iomgr/pollset_uv.c \ - src/core/lib/iomgr/pollset_windows.c \ - src/core/lib/iomgr/resolve_address_posix.c \ - src/core/lib/iomgr/resolve_address_uv.c \ - src/core/lib/iomgr/resolve_address_windows.c \ - src/core/lib/iomgr/resource_quota.c \ - src/core/lib/iomgr/sockaddr_utils.c \ - src/core/lib/iomgr/socket_mutator.c \ - src/core/lib/iomgr/socket_utils_common_posix.c \ - src/core/lib/iomgr/socket_utils_linux.c \ - src/core/lib/iomgr/socket_utils_posix.c \ - src/core/lib/iomgr/socket_utils_uv.c \ - src/core/lib/iomgr/socket_utils_windows.c \ - src/core/lib/iomgr/socket_windows.c \ - src/core/lib/iomgr/tcp_client_posix.c \ - src/core/lib/iomgr/tcp_client_uv.c \ - src/core/lib/iomgr/tcp_client_windows.c \ - src/core/lib/iomgr/tcp_posix.c \ - src/core/lib/iomgr/tcp_server_posix.c \ - src/core/lib/iomgr/tcp_server_uv.c \ - src/core/lib/iomgr/tcp_server_windows.c \ - src/core/lib/iomgr/tcp_uv.c \ - src/core/lib/iomgr/tcp_windows.c \ - src/core/lib/iomgr/time_averaged_stats.c \ - src/core/lib/iomgr/timer_generic.c \ - src/core/lib/iomgr/timer_heap.c \ - src/core/lib/iomgr/timer_uv.c \ - src/core/lib/iomgr/udp_server.c \ - src/core/lib/iomgr/unix_sockets_posix.c \ - src/core/lib/iomgr/unix_sockets_posix_noop.c \ - src/core/lib/iomgr/wakeup_fd_cv.c \ - src/core/lib/iomgr/wakeup_fd_eventfd.c \ - src/core/lib/iomgr/wakeup_fd_nospecial.c \ - src/core/lib/iomgr/wakeup_fd_pipe.c \ - src/core/lib/iomgr/wakeup_fd_posix.c \ - src/core/lib/iomgr/workqueue_uv.c \ - src/core/lib/iomgr/workqueue_windows.c \ - src/core/lib/json/json.c \ - src/core/lib/json/json_reader.c \ - src/core/lib/json/json_string.c \ - src/core/lib/json/json_writer.c \ - src/core/lib/slice/percent_encoding.c \ - src/core/lib/slice/slice.c \ - src/core/lib/slice/slice_buffer.c \ - src/core/lib/slice/slice_hash_table.c \ - src/core/lib/slice/slice_intern.c \ - src/core/lib/slice/slice_string_helpers.c \ - src/core/lib/surface/alarm.c \ - src/core/lib/surface/api_trace.c \ - src/core/lib/surface/byte_buffer.c \ - src/core/lib/surface/byte_buffer_reader.c \ - src/core/lib/surface/call.c \ - src/core/lib/surface/call_details.c \ - src/core/lib/surface/call_log_batch.c \ - src/core/lib/surface/channel.c \ - src/core/lib/surface/channel_init.c \ - src/core/lib/surface/channel_ping.c \ - src/core/lib/surface/channel_stack_type.c \ - src/core/lib/surface/completion_queue.c \ - src/core/lib/surface/event_string.c \ - src/core/lib/surface/lame_client.c \ - src/core/lib/surface/metadata_array.c \ - src/core/lib/surface/server.c \ - src/core/lib/surface/validate_metadata.c \ - src/core/lib/surface/version.c \ - src/core/lib/transport/byte_stream.c \ - src/core/lib/transport/connectivity_state.c \ - src/core/lib/transport/error_utils.c \ - src/core/lib/transport/metadata.c \ - src/core/lib/transport/metadata_batch.c \ - src/core/lib/transport/pid_controller.c \ - src/core/lib/transport/service_config.c \ - src/core/lib/transport/static_metadata.c \ - src/core/lib/transport/status_conversion.c \ - src/core/lib/transport/timeout_encoding.c \ - src/core/lib/transport/transport.c \ - src/core/lib/transport/transport_op_string.c \ - src/core/ext/client_channel/channel_connectivity.c \ - src/core/ext/client_channel/client_channel.c \ - src/core/ext/client_channel/client_channel_factory.c \ - src/core/ext/client_channel/client_channel_plugin.c \ - src/core/ext/client_channel/connector.c \ - src/core/ext/client_channel/default_initial_connect_string.c \ - src/core/ext/client_channel/http_connect_handshaker.c \ - src/core/ext/client_channel/http_proxy.c \ - src/core/ext/client_channel/initial_connect_string.c \ - src/core/ext/client_channel/lb_policy.c \ - src/core/ext/client_channel/lb_policy_factory.c \ - src/core/ext/client_channel/lb_policy_registry.c \ - src/core/ext/client_channel/parse_address.c \ - src/core/ext/client_channel/proxy_mapper.c \ - src/core/ext/client_channel/proxy_mapper_registry.c \ - src/core/ext/client_channel/resolver.c \ - src/core/ext/client_channel/resolver_factory.c \ - src/core/ext/client_channel/resolver_registry.c \ - src/core/ext/client_channel/subchannel.c \ - src/core/ext/client_channel/subchannel_index.c \ - src/core/ext/client_channel/uri_parser.c \ - src/core/ext/transport/chttp2/transport/bin_decoder.c \ - src/core/ext/transport/chttp2/transport/bin_encoder.c \ - src/core/ext/transport/chttp2/transport/chttp2_plugin.c \ - src/core/ext/transport/chttp2/transport/chttp2_transport.c \ - src/core/ext/transport/chttp2/transport/frame_data.c \ - src/core/ext/transport/chttp2/transport/frame_goaway.c \ - src/core/ext/transport/chttp2/transport/frame_ping.c \ - src/core/ext/transport/chttp2/transport/frame_rst_stream.c \ - src/core/ext/transport/chttp2/transport/frame_settings.c \ - src/core/ext/transport/chttp2/transport/frame_window_update.c \ - src/core/ext/transport/chttp2/transport/hpack_encoder.c \ - src/core/ext/transport/chttp2/transport/hpack_parser.c \ - src/core/ext/transport/chttp2/transport/hpack_table.c \ - src/core/ext/transport/chttp2/transport/huffsyms.c \ - src/core/ext/transport/chttp2/transport/incoming_metadata.c \ - src/core/ext/transport/chttp2/transport/parsing.c \ - src/core/ext/transport/chttp2/transport/stream_lists.c \ - src/core/ext/transport/chttp2/transport/stream_map.c \ - src/core/ext/transport/chttp2/transport/varint.c \ - src/core/ext/transport/chttp2/transport/writing.c \ - src/core/ext/transport/chttp2/alpn/alpn.c \ PUBLIC_HEADERS_C += \ - include/grpc/byte_buffer.h \ - include/grpc/byte_buffer_reader.h \ - include/grpc/compression.h \ - include/grpc/grpc.h \ - include/grpc/grpc_posix.h \ - include/grpc/grpc_security_constants.h \ - include/grpc/slice.h \ - include/grpc/slice_buffer.h \ - include/grpc/status.h \ - include/grpc/impl/codegen/byte_buffer_reader.h \ - include/grpc/impl/codegen/compression_types.h \ - include/grpc/impl/codegen/connectivity_state.h \ - include/grpc/impl/codegen/exec_ctx_fwd.h \ - include/grpc/impl/codegen/grpc_types.h \ - include/grpc/impl/codegen/propagation_bits.h \ - include/grpc/impl/codegen/status.h \ - include/grpc/impl/codegen/atm.h \ - include/grpc/impl/codegen/atm_gcc_atomic.h \ - include/grpc/impl/codegen/atm_gcc_sync.h \ - include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/gpr_slice.h \ - include/grpc/impl/codegen/gpr_types.h \ - include/grpc/impl/codegen/port_platform.h \ - include/grpc/impl/codegen/slice.h \ - include/grpc/impl/codegen/sync.h \ - include/grpc/impl/codegen/sync_generic.h \ - include/grpc/impl/codegen/sync_posix.h \ - include/grpc/impl/codegen/sync_windows.h \ LIBGRPC_TEST_UTIL_UNSECURE_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC_TEST_UTIL_UNSECURE_SRC)))) diff --git a/build.yaml b/build.yaml index 63a6e94059..3cec9c5bd2 100644 --- a/build.yaml +++ b/build.yaml @@ -447,15 +447,6 @@ filegroups: - include/grpc/impl/codegen/status.h uses: - gpr_codegen -- name: grpc_debug_macros - headers: - - src/core/ext/debug/debugger_macros.h - src: - - src/core/ext/debug/debugger_macros.c - uses: - - grpc_base - - grpc_client_channel - - grpc_transport_chttp2 - name: grpc_lb_policy_grpclb headers: - src/core/ext/lb_policy/grpclb/grpclb.h @@ -569,6 +560,7 @@ filegroups: - test/core/end2end/fixtures/http_proxy.h - test/core/end2end/fixtures/proxy.h - test/core/iomgr/endpoint_tests.h + - test/core/util/debugger_macros.h - test/core/util/grpc_profiler.h - test/core/util/memory_counters.h - test/core/util/mock_endpoint.h @@ -583,6 +575,7 @@ filegroups: - test/core/end2end/fixtures/http_proxy.c - test/core/end2end/fixtures/proxy.c - test/core/iomgr/endpoint_tests.c + - test/core/util/debugger_macros.c - test/core/util/grpc_profiler.c - test/core/util/memory_counters.c - test/core/util/mock_endpoint.c @@ -596,8 +589,6 @@ filegroups: deps: - grpc - gpr_test_util - uses: - - grpc_debug_macros - name: grpc_transport_chttp2 headers: - src/core/ext/transport/chttp2/transport/bin_decoder.h diff --git a/src/core/ext/debug/debugger_macros.c b/src/core/ext/debug/debugger_macros.c deleted file mode 100644 index de6a2f38a7..0000000000 --- a/src/core/ext/debug/debugger_macros.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Copyright 2016, 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. - * - */ - -/* - * A collection of 'macros' that help navigating the grpc object hierarchy - * Not intended to be robust for main-line code, often cuts across abstraction - * boundaries. - */ - -#include - -#include "src/core/ext/client_channel/client_channel.h" -#include "src/core/ext/transport/chttp2/transport/internal.h" -#include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/surface/call.h" - -void grpc_summon_debugger_macros() {} - -grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { - grpc_call_stack *cs = grpc_call_get_call_stack(call); - for (;;) { - grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1); - if (el->filter == &grpc_client_channel_filter) { - grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el); - if (scc == NULL) { - fprintf(stderr, "No subchannel-call"); - return NULL; - } - cs = grpc_subchannel_call_get_call_stack(scc); - } else if (el->filter == &grpc_connected_filter) { - return grpc_connected_channel_get_stream(el); - } else { - fprintf(stderr, "Unrecognized filter: %s", el->filter->name); - return NULL; - } - } -} - -grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) { - return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call); -} diff --git a/src/core/ext/debug/debugger_macros.h b/src/core/ext/debug/debugger_macros.h deleted file mode 100644 index 4494176560..0000000000 --- a/src/core/ext/debug/debugger_macros.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright 2016, 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. - * - */ - -#ifndef DEBUGGER_MACROS_H -#define DEBUGGER_MACROS_H - -void grpc_summon_debugger_macros(); - -#endif diff --git a/templates/test/core/end2end/end2end_defs.include b/templates/test/core/end2end/end2end_defs.include index 4086a30360..68b9e69c2f 100644 --- a/templates/test/core/end2end/end2end_defs.include +++ b/templates/test/core/end2end/end2end_defs.include @@ -42,7 +42,7 @@ #include -#include "src/core/ext/debug/debugger_macros.h" +#include "test/core/util/debugger_macros.h" static bool g_pre_init_called = false; diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index 6a0032c324..fdfa31b5fb 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -41,7 +41,7 @@ #include -#include "src/core/ext/debug/debugger_macros.h" +#include "test/core/util/debugger_macros.h" static bool g_pre_init_called = false; diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index c9641d7d13..f529d6a899 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -41,7 +41,7 @@ #include -#include "src/core/ext/debug/debugger_macros.h" +#include "test/core/util/debugger_macros.h" static bool g_pre_init_called = false; diff --git a/test/core/util/debugger_macros.c b/test/core/util/debugger_macros.c new file mode 100644 index 0000000000..de6a2f38a7 --- /dev/null +++ b/test/core/util/debugger_macros.c @@ -0,0 +1,71 @@ +/* + * + * Copyright 2016, 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. + * + */ + +/* + * A collection of 'macros' that help navigating the grpc object hierarchy + * Not intended to be robust for main-line code, often cuts across abstraction + * boundaries. + */ + +#include + +#include "src/core/ext/client_channel/client_channel.h" +#include "src/core/ext/transport/chttp2/transport/internal.h" +#include "src/core/lib/channel/connected_channel.h" +#include "src/core/lib/surface/call.h" + +void grpc_summon_debugger_macros() {} + +grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { + grpc_call_stack *cs = grpc_call_get_call_stack(call); + for (;;) { + grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1); + if (el->filter == &grpc_client_channel_filter) { + grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el); + if (scc == NULL) { + fprintf(stderr, "No subchannel-call"); + return NULL; + } + cs = grpc_subchannel_call_get_call_stack(scc); + } else if (el->filter == &grpc_connected_filter) { + return grpc_connected_channel_get_stream(el); + } else { + fprintf(stderr, "Unrecognized filter: %s", el->filter->name); + return NULL; + } + } +} + +grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) { + return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call); +} diff --git a/test/core/util/debugger_macros.h b/test/core/util/debugger_macros.h new file mode 100644 index 0000000000..4494176560 --- /dev/null +++ b/test/core/util/debugger_macros.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016, 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. + * + */ + +#ifndef DEBUGGER_MACROS_H +#define DEBUGGER_MACROS_H + +void grpc_summon_debugger_macros(); + +#endif diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index d24c37e007..8a9bedc94f 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7449,26 +7449,6 @@ "third_party": false, "type": "filegroup" }, - { - "deps": [ - "gpr", - "grpc_base", - "grpc_client_channel", - "grpc_transport_chttp2" - ], - "headers": [ - "src/core/ext/debug/debugger_macros.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_debug_macros", - "src": [ - "src/core/ext/debug/debugger_macros.c", - "src/core/ext/debug/debugger_macros.h" - ], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "gpr", @@ -7663,10 +7643,8 @@ }, { "deps": [ - "gpr", "gpr_test_util", - "grpc", - "grpc_debug_macros" + "grpc" ], "headers": [ "test/core/end2end/cq_verifier.h", @@ -7674,6 +7652,7 @@ "test/core/end2end/fixtures/http_proxy.h", "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.h", + "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.h", "test/core/util/memory_counters.h", "test/core/util/mock_endpoint.h", @@ -7697,6 +7676,8 @@ "test/core/end2end/fixtures/proxy.h", "test/core/iomgr/endpoint_tests.c", "test/core/iomgr/endpoint_tests.h", + "test/core/util/debugger_macros.c", + "test/core/util/debugger_macros.h", "test/core/util/grpc_profiler.c", "test/core/util/grpc_profiler.h", "test/core/util/memory_counters.c", diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index 5a0e09e1bb..98f73b76bf 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -184,6 +184,7 @@ + @@ -192,7 +193,6 @@ - @@ -298,43 +298,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -357,6 +320,8 @@ + + @@ -377,8 +342,6 @@ - - @@ -613,90 +576,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index be8024c7aa..d88585d002 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -31,6 +31,9 @@ test\core\iomgr + + test\core\util + test\core\util @@ -61,9 +64,6 @@ test\core\util - - src\core\ext\debug - src\core\lib\channel @@ -415,132 +415,6 @@ src\core\lib\transport - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\alpn - @@ -650,6 +524,9 @@ test\core\iomgr + + test\core\util + test\core\util @@ -674,9 +551,6 @@ test\core\util - - src\core\ext\debug - src\core\lib\channel @@ -992,117 +866,6 @@ src\core\lib\transport - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\alpn - @@ -1124,27 +887,6 @@ {f7bfac91-5eb2-dea7-4601-6c63edbbf997} - - {5db70e06-741d-708c-bf0a-b59f8ca1f8bd} - - - {7f75a084-6bc4-e813-f85b-120148aa35da} - - - {88f64b2c-ca67-05ef-c15b-8ab420357a2a} - - - {b5f17b17-8012-87c9-dfb2-428dd29d0b94} - - - {608f56aa-d257-f25b-14aa-1776a771defd} - - - {49d381db-172f-9765-4135-d7a10c4485bf} - - - {4395ba2e-6b6d-ea05-8a1e-915b8f0f85f6} - {f4e8c61e-1ca6-0fdd-7b5e-b7f9a30c9a21} diff --git a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj index c9e18e94b0..daf92305c4 100644 --- a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj @@ -146,42 +146,13 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -190,149 +161,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -345,6 +173,8 @@ + + @@ -365,326 +195,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters index 017e96ff62..c9a1b4c10d 100644 --- a/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util_unsecure/grpc_test_util_unsecure.vcxproj.filters @@ -16,6 +16,9 @@ test\core\iomgr + + test\core\util + test\core\util @@ -46,572 +49,6 @@ test\core\util - - src\core\ext\debug - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\compression - - - src\core\lib\compression - - - src\core\lib\debug - - - src\core\lib\http - - - src\core\lib\http - - - src\core\lib\http - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\json - - - src\core\lib\json - - - src\core\lib\json - - - src\core\lib\json - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\alpn - - - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - - - include\grpc\impl\codegen - @@ -629,6 +66,9 @@ test\core\iomgr + + test\core\util + test\core\util @@ -653,507 +93,9 @@ test\core\util - - src\core\ext\debug - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\channel - - - src\core\lib\compression - - - src\core\lib\compression - - - src\core\lib\debug - - - src\core\lib\http - - - src\core\lib\http - - - src\core\lib\http - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\iomgr - - - src\core\lib\json - - - src\core\lib\json - - - src\core\lib\json - - - src\core\lib\json - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\slice - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\surface - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\lib\transport - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\client_channel - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\transport - - - src\core\ext\transport\chttp2\alpn - - - {9793fab6-15ae-1f61-712d-c3d673654d72} - - - {c2447106-a6bf-6b88-9ad0-a42b7ac1573c} - - - {dba70812-267b-656c-9f8c-636338d3f5c0} - - - {b9e2ddac-f042-3042-ba4b-79ba4445e68c} - - - {65483377-42fd-137e-3847-00dfd4675db3} - - - {51a516dc-93e3-4dd5-d114-2d06f5df4ad7} - - - {a927155d-bcf6-0dd8-6d63-be48bcaf617f} - - - {ecb054bb-d7ce-b4db-7f82-ae022486c076} - - - {de5ce030-9e5d-b93a-da8f-ee5825ded59a} - - - {fb32254e-a807-768a-3686-4e87f3bf1e8e} - - - {87c61e56-5090-5e1a-22af-02e3c8bf4a2a} - - - {e50ce1d1-6b17-dad2-9ef3-46f68d4bee1b} - - - {67007111-23fe-296f-1808-91f2b96a31aa} - - - {e3d002a7-9318-1ac5-4259-e177f58ccc9a} - - - {ac14fd16-a4af-6b22-4226-2d7dabf25409} - - - {24268e45-f6c3-6024-b49a-d01bb9c12d96} - - - {0be401bd-3e26-dead-fdf4-2ce27a1ac3a3} - - - {ac2f12e3-ac77-f0a7-d15d-92899e61ed25} - - - {9015222c-df04-298f-3f2c-d19babffc180} - - - {c3ff117a-aae9-dedd-2f5a-888f0383cbb8} - - - {588ffbfc-2f94-a99f-85b0-4c47ec9f8d13} - - - {732318c6-bb34-9a99-611b-9928db3d4e2a} - - - {2c0ca4a1-38df-329d-eeba-5c5b61dc81a5} - {037c7645-1698-cf2d-4163-525240323101} -- cgit v1.2.3 From 9429250e477a2dcbed76c4c1dd72a02b68f63d0a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 3 Feb 2017 22:24:57 -0800 Subject: Flow control corrections --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 9 +++++---- src/core/ext/transport/chttp2/transport/parsing.c | 8 ++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index fb5ae575db..fa18f5a725 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -2046,14 +2046,15 @@ static void incoming_byte_stream_update_flow_control(grpc_exec_ctx *exec_ctx, (int64_t)have_already) { write_type = GRPC_CHTTP2_STREAM_WRITE_INITIATE_COVERED; } - if (s->incoming_window_delta - s->announce_window > - -(int64_t)initial_window_size / 2) { - write_type = GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK; - } GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, incoming_window_delta, add_max_recv_bytes); GRPC_CHTTP2_FLOW_CREDIT_STREAM("op", t, s, announce_window, add_max_recv_bytes); + if ((int64_t)s->incoming_window_delta + (int64_t)initial_window_size - + (int64_t)s->announce_window > + (int64_t)initial_window_size / 2) { + write_type = GRPC_CHTTP2_STREAM_WRITE_PIGGYBACK; + } grpc_chttp2_become_writable(exec_ctx, t, s, write_type, "read_incoming_stream"); } diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index a882a0bba1..24bd93067b 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -404,8 +404,12 @@ static grpc_error *update_incoming_window(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_FLOW_DEBIT_STREAM("parse", t, s, incoming_window_delta, incoming_frame_size); - if (s->incoming_window_delta - s->announce_window <= - -(int64_t)target_incoming_window / 2) { + if ((int64_t)t->settings[GRPC_SENT_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] + + (int64_t)s->incoming_window_delta - (int64_t)s->announce_window <= + (int64_t)t->settings[GRPC_SENT_SETTINGS] + [GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] / + 2) { grpc_chttp2_become_writable(exec_ctx, t, s, GRPC_CHTTP2_STREAM_WRITE_INITIATE_UNCOVERED, "window-update-required"); -- cgit v1.2.3