From 2b1fd661afc94b871bb200721bf96e6cd5477808 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 07:33:37 -0700 Subject: Hoist iov_size into a grpc_tcp member --- src/core/iomgr/tcp_posix.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index 86721e9c95..f5f30cac36 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -258,6 +258,7 @@ typedef struct { grpc_endpoint base; grpc_fd *em_fd; int fd; + int iov_size; /* Number of slices to allocate per read attempt */ size_t slice_size; gpr_refcount refcount; @@ -317,7 +318,6 @@ static void call_read_cb(grpc_tcp *tcp, gpr_slice *slices, size_t nslices, #define MAX_READ_IOVEC 4 static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { grpc_tcp *tcp = (grpc_tcp *)arg; - int iov_size = 1; gpr_slice static_read_slices[INLINE_SLICE_BUFFER_SIZE]; struct msghdr msg; struct iovec iov[MAX_READ_IOVEC]; @@ -340,12 +340,12 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { /* TODO(klempner): Limit the amount we read at once. */ for (;;) { allocated_bytes = slice_state_append_blocks_into_iovec( - &read_state, iov, iov_size, tcp->slice_size); + &read_state, iov, tcp->iov_size, tcp->slice_size); msg.msg_name = NULL; msg.msg_namelen = 0; msg.msg_iov = iov; - msg.msg_iovlen = iov_size; + msg.msg_iovlen = tcp->iov_size; msg.msg_control = NULL; msg.msg_controllen = 0; msg.msg_flags = 0; @@ -368,6 +368,9 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { /* NB: After calling the user_cb a parallel call of the read handler may * be running. */ if (errno == EAGAIN) { + if (tcp->iov_size > 1) { + tcp->iov_size /= 2; + } if (slice_state_has_available(&read_state)) { /* TODO(klempner): We should probably do the call into the application without all this junk on the stack */ @@ -402,8 +405,8 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { slice_state_destroy(&read_state); grpc_tcp_unref(tcp); return; - } else if (iov_size < MAX_READ_IOVEC) { - ++iov_size; + } else if (tcp->iov_size < MAX_READ_IOVEC) { + ++tcp->iov_size; } } GRPC_TIMER_MARK(HANDLE_READ_END, 0); @@ -554,6 +557,7 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size) { tcp->read_user_data = NULL; tcp->write_user_data = NULL; tcp->slice_size = slice_size; + tcp->iov_size = 1; slice_state_init(&tcp->write_state, NULL, 0, 0); /* paired with unref in grpc_tcp_destroy */ gpr_ref_init(&tcp->refcount, 1); -- cgit v1.2.3 From 89d304a3013652089890d87ea0b3a903a4920947 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 09:20:58 -0700 Subject: Fix test for multiple reads Previously this test assumed all bytes would be read in one request. Also update test to use grpc_init() so that we can enable tracing. --- test/core/iomgr/tcp_posix_test.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 59e525a8e1..40abed5f6e 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -140,11 +141,12 @@ static void read_cb(void *user_data, gpr_slice *slices, size_t nslices, grpc_endpoint_cb_status error) { struct read_socket_state *state = (struct read_socket_state *)user_data; ssize_t read_bytes; - int current_data = 0; + int current_data; GPR_ASSERT(error == GRPC_ENDPOINT_CB_OK); gpr_mu_lock(&state->mu); + current_data = state->read_bytes % 256; read_bytes = count_and_unref_slices(slices, nslices, ¤t_data); state->read_bytes += read_bytes; gpr_log(GPR_INFO, "Read %d bytes of %d", read_bytes, @@ -483,10 +485,10 @@ static grpc_endpoint_test_config configs[] = { int main(int argc, char **argv) { grpc_test_init(argc, argv); - grpc_iomgr_init(); + grpc_init(); run_tests(); grpc_endpoint_tests(configs[0]); - grpc_iomgr_shutdown(); + grpc_shutdown(); return 0; } -- cgit v1.2.3 From 5c07cce72da4177704df654527781e7fb905cb74 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 09:21:58 -0700 Subject: Don't wait for EAGAIN before reporting reads up --- src/core/iomgr/tcp_posix.c | 154 +++++++++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 68 deletions(-) diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index f5f30cac36..3825713aba 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -259,6 +259,7 @@ typedef struct { grpc_fd *em_fd; int fd; int iov_size; /* Number of slices to allocate per read attempt */ + int finished_edge; size_t slice_size; gpr_refcount refcount; @@ -316,8 +317,7 @@ static void call_read_cb(grpc_tcp *tcp, gpr_slice *slices, size_t nslices, #define INLINE_SLICE_BUFFER_SIZE 8 #define MAX_READ_IOVEC 4 -static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { - grpc_tcp *tcp = (grpc_tcp *)arg; +static void grpc_tcp_continue_read(grpc_tcp *tcp) { gpr_slice static_read_slices[INLINE_SLICE_BUFFER_SIZE]; struct msghdr msg; struct iovec iov[MAX_READ_IOVEC]; @@ -327,91 +327,103 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { gpr_slice *final_slices; size_t final_nslices; + GPR_ASSERT(!tcp->finished_edge); GRPC_TIMER_MARK(HANDLE_READ_BEGIN, 0); slice_state_init(&read_state, static_read_slices, INLINE_SLICE_BUFFER_SIZE, 0); - if (!success) { - call_read_cb(tcp, NULL, 0, GRPC_ENDPOINT_CB_SHUTDOWN); - grpc_tcp_unref(tcp); - return; + allocated_bytes = slice_state_append_blocks_into_iovec( + &read_state, iov, tcp->iov_size, tcp->slice_size); + + msg.msg_name = NULL; + msg.msg_namelen = 0; + msg.msg_iov = iov; + msg.msg_iovlen = tcp->iov_size; + msg.msg_control = NULL; + msg.msg_controllen = 0; + msg.msg_flags = 0; + + GRPC_TIMER_MARK(RECVMSG_BEGIN, 0); + do { + read_bytes = recvmsg(tcp->fd, &msg, 0); + } while (read_bytes < 0 && errno == EINTR); + GRPC_TIMER_MARK(RECVMSG_END, 0); + + if (read_bytes < allocated_bytes) { + /* TODO(klempner): Consider a second read first, in hopes of getting a + * quick EAGAIN and saving a bunch of allocations. */ + slice_state_remove_last(&read_state, read_bytes < 0 + ? allocated_bytes + : allocated_bytes - read_bytes); } - /* TODO(klempner): Limit the amount we read at once. */ - for (;;) { - allocated_bytes = slice_state_append_blocks_into_iovec( - &read_state, iov, tcp->iov_size, tcp->slice_size); - - msg.msg_name = NULL; - msg.msg_namelen = 0; - msg.msg_iov = iov; - msg.msg_iovlen = tcp->iov_size; - msg.msg_control = NULL; - msg.msg_controllen = 0; - msg.msg_flags = 0; - - GRPC_TIMER_MARK(RECVMSG_BEGIN, 0); - do { - read_bytes = recvmsg(tcp->fd, &msg, 0); - } while (read_bytes < 0 && errno == EINTR); - GRPC_TIMER_MARK(RECVMSG_END, 0); - - if (read_bytes < allocated_bytes) { - /* TODO(klempner): Consider a second read first, in hopes of getting a - * quick EAGAIN and saving a bunch of allocations. */ - slice_state_remove_last(&read_state, read_bytes < 0 - ? allocated_bytes - : allocated_bytes - read_bytes); - } - - if (read_bytes < 0) { - /* NB: After calling the user_cb a parallel call of the read handler may - * be running. */ - if (errno == EAGAIN) { - if (tcp->iov_size > 1) { - tcp->iov_size /= 2; - } - if (slice_state_has_available(&read_state)) { - /* TODO(klempner): We should probably do the call into the application - without all this junk on the stack */ - /* FIXME(klempner): Refcount properly */ - slice_state_transfer_ownership(&read_state, &final_slices, - &final_nslices); - call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_OK); - slice_state_destroy(&read_state); - grpc_tcp_unref(tcp); - } else { - /* Spurious read event, consume it here */ - slice_state_destroy(&read_state); - grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_closure); - } - } else { - /* TODO(klempner): Log interesting errors */ - call_read_cb(tcp, NULL, 0, GRPC_ENDPOINT_CB_ERROR); - slice_state_destroy(&read_state); - grpc_tcp_unref(tcp); + if (read_bytes < 0) { + /* NB: After calling the user_cb a parallel call of the read handler may + * be running. */ + if (errno == EAGAIN) { + if (tcp->iov_size > 1) { + tcp->iov_size /= 2; } - return; - } else if (read_bytes == 0) { - /* 0 read size ==> end of stream */ if (slice_state_has_available(&read_state)) { - /* there were bytes already read: pass them up to the application */ + /* TODO(klempner): We should probably do the call into the application + without all this junk on the stack */ + /* FIXME(klempner): Refcount properly */ slice_state_transfer_ownership(&read_state, &final_slices, &final_nslices); - call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_EOF); + tcp->finished_edge = 1; + call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_OK); + slice_state_destroy(&read_state); + grpc_tcp_unref(tcp); } else { - call_read_cb(tcp, NULL, 0, GRPC_ENDPOINT_CB_EOF); + /* Spurious read event, consume it here */ + slice_state_destroy(&read_state); + grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_closure); } + } else { + /* TODO(klempner): Log interesting errors */ + call_read_cb(tcp, NULL, 0, GRPC_ENDPOINT_CB_ERROR); slice_state_destroy(&read_state); grpc_tcp_unref(tcp); - return; - } else if (tcp->iov_size < MAX_READ_IOVEC) { + } + } else if (read_bytes == 0) { + /* 0 read size ==> end of stream */ + if (slice_state_has_available(&read_state)) { + /* there were bytes already read: pass them up to the application */ + slice_state_transfer_ownership(&read_state, &final_slices, + &final_nslices); + call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_EOF); + } else { + call_read_cb(tcp, NULL, 0, GRPC_ENDPOINT_CB_EOF); + } + slice_state_destroy(&read_state); + grpc_tcp_unref(tcp); + } else { + if (tcp->iov_size < MAX_READ_IOVEC) { ++tcp->iov_size; } + GPR_ASSERT(slice_state_has_available(&read_state)); + slice_state_transfer_ownership(&read_state, &final_slices, + &final_nslices); + call_read_cb(tcp, final_slices, final_nslices, GRPC_ENDPOINT_CB_OK); + slice_state_destroy(&read_state); + grpc_tcp_unref(tcp); } + GRPC_TIMER_MARK(HANDLE_READ_END, 0); } +static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { + grpc_tcp *tcp = (grpc_tcp *)arg; + GPR_ASSERT(!tcp->finished_edge); + + if (!success) { + call_read_cb(tcp, NULL, 0, GRPC_ENDPOINT_CB_SHUTDOWN); + grpc_tcp_unref(tcp); + } else { + grpc_tcp_continue_read(tcp); + } +} + static void grpc_tcp_notify_on_read(grpc_endpoint *ep, grpc_endpoint_read_cb cb, void *user_data) { grpc_tcp *tcp = (grpc_tcp *)ep; @@ -419,7 +431,12 @@ static void grpc_tcp_notify_on_read(grpc_endpoint *ep, grpc_endpoint_read_cb cb, tcp->read_cb = cb; tcp->read_user_data = user_data; gpr_ref(&tcp->refcount); - grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_closure); + if (tcp->finished_edge) { + tcp->finished_edge = 0; + grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_closure); + } else { + grpc_iomgr_add_callback(grpc_tcp_handle_read, tcp); + } } #define MAX_WRITE_IOVEC 16 @@ -558,6 +575,7 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, size_t slice_size) { tcp->write_user_data = NULL; tcp->slice_size = slice_size; tcp->iov_size = 1; + tcp->finished_edge = 1; slice_state_init(&tcp->write_state, NULL, 0, 0); /* paired with unref in grpc_tcp_destroy */ gpr_ref_init(&tcp->refcount, 1); -- cgit v1.2.3 From 10b9cb5a38480d6acea62e890936914f89b6aa7f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 10:00:15 -0700 Subject: Refine need_more_data We don't need to request more transport data if we: - already have queued messages - are not ready to receive messages --- src/core/surface/call.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 6ca1b4e9a1..f358eb546a 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -421,14 +421,14 @@ static void lock(grpc_call *call) { gpr_mu_lock(&call->mu); } static int need_more_data(grpc_call *call) { return is_op_live(call, GRPC_IOREQ_RECV_INITIAL_METADATA) || - is_op_live(call, GRPC_IOREQ_RECV_MESSAGE) || + (is_op_live(call, GRPC_IOREQ_RECV_MESSAGE) && grpc_bbq_empty(&call->incoming_queue)) || is_op_live(call, GRPC_IOREQ_RECV_TRAILING_METADATA) || is_op_live(call, GRPC_IOREQ_RECV_STATUS) || is_op_live(call, GRPC_IOREQ_RECV_STATUS_DETAILS) || (is_op_live(call, GRPC_IOREQ_RECV_CLOSE) && grpc_bbq_empty(&call->incoming_queue)) || (call->write_state == WRITE_STATE_INITIAL && !call->is_client && - call->read_state != READ_STATE_STREAM_CLOSED); + call->read_state < READ_STATE_GOT_INITIAL_METADATA); } static void unlock(grpc_call *call) { -- cgit v1.2.3 From 6a8c038d2d569aec1c3dd97484088e415aaab1ad Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 10:01:22 -0700 Subject: Add flow control tracing Allow some insight into what the flow controller is doing --- src/core/surface/init.c | 1 + src/core/transport/chttp2_transport.c | 22 ++++++++++++++++++++++ src/core/transport/chttp2_transport.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/core/surface/init.c b/src/core/surface/init.c index 5a119a47cc..a5d86d0071 100644 --- a/src/core/surface/init.c +++ b/src/core/surface/init.c @@ -59,6 +59,7 @@ void grpc_init(void) { grpc_register_tracer("channel", &grpc_trace_channel); grpc_register_tracer("surface", &grpc_surface_trace); grpc_register_tracer("http", &grpc_http_trace); + grpc_register_tracer("flowctl", &grpc_flowctl_trace); grpc_register_tracer("batch", &grpc_trace_batch); grpc_security_pre_init(); grpc_iomgr_init(); diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 26c550c1f1..65161bd1af 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -64,6 +64,7 @@ #define CLIENT_CONNECT_STRLEN 24 int grpc_http_trace = 0; +int grpc_flowctl_trace = 0; typedef struct transport transport; typedef struct stream stream; @@ -74,6 +75,12 @@ typedef struct stream stream; else \ stmt +#define FLOWCTL_TRACE(t, obj, dir, id, delta) \ + if (!grpc_flowctl_trace) \ + ; \ + else \ + flowctl_trace(t, #dir, obj->dir##_window, id, delta) + /* streams are kept in various linked lists depending on what things need to happen to them... this enum labels each list */ typedef enum { @@ -382,6 +389,12 @@ static void add_to_pollset_locked(transport *t, grpc_pollset *pollset); static void perform_op_locked(transport *t, stream *s, grpc_transport_op *op); static void add_metadata_batch(transport *t, stream *s); +static void flowctl_trace(transport *t, const char *flow, gpr_int32 window, + gpr_uint32 id, gpr_int32 delta) { + gpr_log(GPR_DEBUG, "HTTP:FLOW:%p:%d:%s: %d + %d = %d", t, id, flow, window, + delta, window + delta); +} + /* * CONSTRUCTION/DESTRUCTION/REFCOUNTING */ @@ -894,6 +907,8 @@ static int prepare_write(transport *t) { window_delta = grpc_chttp2_preencode( s->outgoing_sopb->ops, &s->outgoing_sopb->nops, GPR_MIN(t->outgoing_window, s->outgoing_window), &s->writing_sopb); + FLOWCTL_TRACE(t, t, outgoing, 0, -window_delta); + FLOWCTL_TRACE(t, s, outgoing, s->id, -window_delta); t->outgoing_window -= window_delta; s->outgoing_window -= window_delta; @@ -922,6 +937,7 @@ static int prepare_write(transport *t) { if (!s->read_closed && window_delta) { gpr_slice_buffer_add( &t->outbuf, grpc_chttp2_window_update_create(s->id, window_delta)); + FLOWCTL_TRACE(t, s, incoming, s->id, window_delta); s->incoming_window += window_delta; } } @@ -931,6 +947,7 @@ static int prepare_write(transport *t) { window_delta = t->connection_window_target - t->incoming_window; gpr_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create(0, window_delta)); + FLOWCTL_TRACE(t, t, incoming, 0, window_delta); t->incoming_window += window_delta; } @@ -1253,6 +1270,8 @@ static grpc_chttp2_parse_error update_incoming_window(transport *t, stream *s) { return GRPC_CHTTP2_CONNECTION_ERROR; } + FLOWCTL_TRACE(t, t, incoming, 0, -t->incoming_frame_size); + FLOWCTL_TRACE(t, s, incoming, s->id, -t->incoming_frame_size); t->incoming_window -= t->incoming_frame_size; s->incoming_window -= t->incoming_frame_size; @@ -1599,6 +1618,7 @@ static int parse_frame_slice(transport *t, gpr_slice slice, int is_last) { for (i = 0; i < t->stream_map.count; i++) { stream *s = (stream *)(t->stream_map.values[i]); int was_window_empty = s->outgoing_window <= 0; + FLOWCTL_TRACE(t, s, outgoing, s->id, st.initial_window_update); s->outgoing_window += st.initial_window_update; if (was_window_empty && s->outgoing_window > 0 && s->outgoing_sopb && s->outgoing_sopb->nops > 0) { @@ -1617,6 +1637,7 @@ static int parse_frame_slice(transport *t, gpr_slice slice, int is_last) { GRPC_CHTTP2_FLOW_CONTROL_ERROR), GRPC_CHTTP2_FLOW_CONTROL_ERROR, NULL, 1); } else { + FLOWCTL_TRACE(t, s, outgoing, s->id, st.window_update); s->outgoing_window += st.window_update; /* if this window update makes outgoing ops writable again, flag that */ @@ -1631,6 +1652,7 @@ static int parse_frame_slice(transport *t, gpr_slice slice, int is_last) { if (!is_window_update_legal(st.window_update, t->outgoing_window)) { drop_connection(t); } else { + FLOWCTL_TRACE(t, t, outgoing, 0, st.window_update); t->outgoing_window += st.window_update; } } diff --git a/src/core/transport/chttp2_transport.h b/src/core/transport/chttp2_transport.h index a7f1b9a864..fad714fabf 100644 --- a/src/core/transport/chttp2_transport.h +++ b/src/core/transport/chttp2_transport.h @@ -38,6 +38,7 @@ #include "src/core/transport/transport.h" extern int grpc_http_trace; +extern int grpc_flowctl_trace; void grpc_create_chttp2_transport(grpc_transport_setup_callback setup, void *arg, -- cgit v1.2.3 From 8119c0a08f977180c225d8447cd5e5337d6cf80f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 17:05:09 -0700 Subject: Capure thread id with default timer implementation --- src/core/profiling/timers.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/profiling/timers.c b/src/core/profiling/timers.c index 7cc79bd22b..bd1700ffd8 100644 --- a/src/core/profiling/timers.c +++ b/src/core/profiling/timers.c @@ -40,10 +40,12 @@ #include #include #include +#include #include typedef struct grpc_timer_entry { grpc_precise_clock tm; + gpr_thd_id thd; const char* tag; void* id; const char* file; @@ -85,7 +87,7 @@ static void log_report_locked(grpc_timers_log* log) { grpc_timer_entry* entry = &(log->log[i]); fprintf(fp, "GRPC_LAT_PROF "); grpc_precise_clock_print(&entry->tm, fp); - fprintf(fp, " %s %p %s %d\n", entry->tag, entry->id, entry->file, + fprintf(fp, " %p %s %p %s %d\n", (void*)(gpr_intptr)entry->thd, entry->tag, entry->id, entry->file, entry->line); } @@ -121,6 +123,7 @@ void grpc_timers_log_add(grpc_timers_log* log, const char* tag, void* id, entry->id = id; entry->file = file; entry->line = line; + entry->thd = gpr_thd_currentid(); gpr_mu_unlock(&log->mu); } -- cgit v1.2.3 From 50968495795f3e491a54f6361acb957141004e24 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 17:05:49 -0700 Subject: Add some helpful timing markers --- src/core/surface/call.c | 3 +++ src/core/transport/chttp2_transport.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/core/surface/call.c b/src/core/surface/call.c index f358eb546a..fc07a19894 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -34,6 +34,7 @@ #include "src/core/surface/call.h" #include "src/core/channel/channel_stack.h" #include "src/core/iomgr/alarm.h" +#include "src/core/profiling/timers.h" #include "src/core/support/string.h" #include "src/core/surface/byte_buffer_queue.h" #include "src/core/surface/channel.h" @@ -701,6 +702,7 @@ static int add_slice_to_message(grpc_call *call, gpr_slice slice) { static void call_on_done_recv(void *pc, int success) { grpc_call *call = pc; size_t i; + GRPC_TIMER_MARK(CALL_ON_DONE_RECV_BEGIN, 0); lock(call); call->receiving = 0; if (success) { @@ -741,6 +743,7 @@ static void call_on_done_recv(void *pc, int success) { unlock(call); GRPC_CALL_INTERNAL_UNREF(call, "receiving", 0); + GRPC_TIMER_MARK(CALL_ON_DONE_RECV_END, 0); } static grpc_mdelem_list chain_metadata_from_app(grpc_call *call, size_t count, diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 65161bd1af..c78d64d2dd 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -37,6 +37,7 @@ #include #include +#include "src/core/profiling/timers.h" #include "src/core/support/string.h" #include "src/core/transport/chttp2/frame_data.h" #include "src/core/transport/chttp2/frame_goaway.h" @@ -783,6 +784,8 @@ static void unlock(transport *t) { grpc_stream_op_buffer nuke_now; const grpc_transport_callbacks *cb = t->cb; + GRPC_TIMER_MARK(HTTP2_UNLOCK_BEGIN, 0); + grpc_sopb_init(&nuke_now); if (t->nuke_later_sopb.nops) { grpc_sopb_swap(&nuke_now, &t->nuke_later_sopb); @@ -831,6 +834,8 @@ static void unlock(transport *t) { /* finally unlock */ gpr_mu_unlock(&t->mu); + GRPC_TIMER_MARK(HTTP2_UNLOCK_CLEANUP, 0); + /* perform some callbacks if necessary */ for (i = 0; i < num_goaways; i++) { cb->goaway(t->cb_user_data, &t->base, goaways[i].status, goaways[i].debug); @@ -861,6 +866,8 @@ static void unlock(transport *t) { grpc_sopb_destroy(&nuke_now); gpr_free(goaways); + + GRPC_TIMER_MARK(HTTP2_UNLOCK_END, 0); } /* -- cgit v1.2.3 From 39d4d72eb6c3b34664ce4d65cfa4f940c78ee536 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Apr 2015 12:52:35 -0700 Subject: Cast away errors on Windows --- src/core/transport/chttp2_transport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 264e653124..dd7c60710b 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -914,8 +914,8 @@ static int prepare_write(transport *t) { window_delta = grpc_chttp2_preencode( s->outgoing_sopb->ops, &s->outgoing_sopb->nops, GPR_MIN(t->outgoing_window, s->outgoing_window), &s->writing_sopb); - FLOWCTL_TRACE(t, t, outgoing, 0, -window_delta); - FLOWCTL_TRACE(t, s, outgoing, s->id, -window_delta); + FLOWCTL_TRACE(t, t, outgoing, 0, -(gpr_int64)window_delta); + FLOWCTL_TRACE(t, s, outgoing, s->id, -(gpr_int64)window_delta); t->outgoing_window -= window_delta; s->outgoing_window -= window_delta; @@ -1277,8 +1277,8 @@ static grpc_chttp2_parse_error update_incoming_window(transport *t, stream *s) { return GRPC_CHTTP2_CONNECTION_ERROR; } - FLOWCTL_TRACE(t, t, incoming, 0, -t->incoming_frame_size); - FLOWCTL_TRACE(t, s, incoming, s->id, -t->incoming_frame_size); + FLOWCTL_TRACE(t, t, incoming, 0, -(gpr_int64)t->incoming_frame_size); + FLOWCTL_TRACE(t, s, incoming, s->id, -(gpr_int64)t->incoming_frame_size); t->incoming_window -= t->incoming_frame_size; s->incoming_window -= t->incoming_frame_size; -- cgit v1.2.3 From dba5e0f96be51cce1343a31b5bd3734342642a29 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Apr 2015 12:53:49 -0700 Subject: Tweak comment --- src/core/iomgr/tcp_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index 3825713aba..cef5e09760 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -375,7 +375,7 @@ static void grpc_tcp_continue_read(grpc_tcp *tcp) { slice_state_destroy(&read_state); grpc_tcp_unref(tcp); } else { - /* Spurious read event, consume it here */ + /* We've consumed the edge, request a new one */ slice_state_destroy(&read_state); grpc_fd_notify_on_read(tcp->em_fd, &tcp->read_closure); } -- cgit v1.2.3