From 611b7362c6b684045191f1d116041b7de537267e Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 27 Apr 2015 15:49:31 -0700 Subject: Tentative stap version --- src/core/profiling/stap_probes.d | 5 +++++ src/core/profiling/timers.h | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/core/profiling/stap_probes.d (limited to 'src/core') diff --git a/src/core/profiling/stap_probes.d b/src/core/profiling/stap_probes.d new file mode 100644 index 0000000000..04881826d0 --- /dev/null +++ b/src/core/profiling/stap_probes.d @@ -0,0 +1,5 @@ +provider _stap { + probe timing_ns_begin(int tag); + probe timing_ns_end(int tag); +}; + diff --git a/src/core/profiling/timers.h b/src/core/profiling/timers.h index 1a6b9ffac9..8fe8a8fe99 100644 --- a/src/core/profiling/timers.h +++ b/src/core/profiling/timers.h @@ -36,6 +36,23 @@ #include +#ifdef GRPC_STAP_PROFILER +#include +/* Generated from src/core/profiling/stap_probes.d */ +#include "src/core/profiling/stap_probes.h" + +#define GRPC_STAP_TIMING_NS_BEGIN(tag) _STAP_TIMING_NS_BEGIN(tag) +#define GRPC_STAP_TIMING_NS_END(tag) _STAP_TIMING_NS_END(tag) + +#else /* !GRPC_STAP_PROFILER */ +#define GRPC_STAP_BEGIN_NS(x, s) \ + do { \ + } while (0) +#define GRPC_STAP_END_NS(x, s) \ + do { \ + } while (0) +#endif /* GRPC_STAP_PROFILER */ + #ifdef __cplusplus extern "C" { #endif -- cgit v1.2.3 From a9eb302abaccdd3609d81ba75434cccaed49f4fd Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 27 Apr 2015 19:17:20 -0700 Subject: STAP annotation working. Test annotations made to client_channel.c (start_rpc) and channel_create.c (grpc_channel_create). --- Makefile | 25 +++++++++++++++++++++ src/core/channel/client_channel.c | 4 ++++ src/core/surface/channel_create.c | 8 +++++-- test/build/systemtap.c | 42 ++++++++++++++++++++++++++++++++++++ test/core/profiling/mark_timings.stp | 32 +++++++++++++++++++++++++++ 5 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 test/build/systemtap.c create mode 100644 test/core/profiling/mark_timings.stp (limited to 'src/core') diff --git a/Makefile b/Makefile index 2def6e2413..1955e2fa48 100644 --- a/Makefile +++ b/Makefile @@ -183,6 +183,7 @@ DEFINES_gcov = NDEBUG prefix ?= /usr/local PROTOC = protoc +DTRACE = dtrace CONFIG ?= opt CC = $(CC_$(CONFIG)) CXX = $(CXX_$(CONFIG)) @@ -350,6 +351,8 @@ PERFTOOLS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/perfto PROTOBUF_CHECK_CMD = $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/protobuf.cc -lprotobuf $(LDFLAGS) PROTOC_CHECK_CMD = which protoc > /dev/null PROTOC_CHECK_VERSION_CMD = protoc --version | grep -q libprotoc.3 +DTRACE_CHECK_CMD = which dtrace > /dev/null +SYSTEMTAP_HEADERS_CHECK_CMD = $(CC) $(CFLAGS) $(CPPFLAGS) -o $(TMPOUT) test/build/systemtap.c $(LDFLAGS) ifeq ($(OPENSSL_REQUIRES_DL),true) OPENSSL_ALPN_CHECK_CMD += -ldl @@ -382,6 +385,19 @@ else HAS_VALID_PROTOC = false endif +# Check for Systemtap (https://sourceware.org/systemtap/), first by making sure is present +# in the system and secondly by checking for the "dtrace" binary (on Linux, this is part of the Systemtap +# distribution. It's part of the base system on BSD/Solaris machines). +HAS_SYSTEMTAP_HEADERS = $(shell $(SYSTEMTAP_HEADERS_CHECK_CMD) 2> /dev/null && echo true || echo false) +HAS_DTRACE = $(shell $(DTRACE_CHECK_CMD) 2> /dev/null && echo true || echo false) +HAS_SYSTEMTAP = false +ifeq ($(HAS_SYSTEMTAP_HEADERS),true) +ifeq ($(HAS_DTRACE),true) +HAS_SYSTEMTAP = true +DEFINES += GRPC_STAP_PROFILER +endif +endif + ifeq ($(wildcard third_party/openssl/ssl/ssl.h),) HAS_EMBEDDED_OPENSSL_ALPN = false else @@ -2779,6 +2795,15 @@ $(GENDIR)/test/proto/test.grpc.pb.cc: test/proto/test.proto $(PROTOBUF_DEP) $(PR endif +ifeq ($(HAS_SYSTEMTAP),true) +$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d + $(E) "[DTRACE] Compiling $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(DTRACE) -C -h -s $< -o $@ + +src/core/profiling/timers.h: $(GENDIR)/src/core/profiling/stap_probes.h +endif + $(OBJDIR)/$(CONFIG)/%.o : %.c $(E) "[C] Compiling $<" $(Q) mkdir -p `dirname $@` diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index bc481e59ca..0c241240e2 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -39,7 +39,9 @@ #include "src/core/channel/child_channel.h" #include "src/core/channel/connected_channel.h" #include "src/core/iomgr/iomgr.h" +#include "src/core/profiling/timers.h" #include "src/core/support/string.h" + #include #include #include @@ -127,6 +129,7 @@ static void complete_activate(grpc_call_element *elem, grpc_call_op *op) { static void start_rpc(grpc_call_element *elem, grpc_call_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; + GRPC_STAP_TIMING_NS_BEGIN(2); gpr_mu_lock(&chand->mu); if (calld->state == CALL_CANCELLED) { gpr_mu_unlock(&chand->mu); @@ -172,6 +175,7 @@ static void start_rpc(grpc_call_element *elem, grpc_call_op *op) { grpc_transport_setup_initiate(chand->transport_setup); } } + GRPC_STAP_TIMING_NS_END(2); } static void remove_waiting_child(channel_data *chand, call_data *calld) { diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 3104b1d00d..73b3670ccc 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -31,6 +31,7 @@ * */ + #include "src/core/iomgr/sockaddr.h" #include @@ -48,10 +49,12 @@ #include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/tcp_client.h" +#include "src/core/profiling/timers.h" +#include "src/core/support/string.h" #include "src/core/surface/channel.h" #include "src/core/surface/client.h" -#include "src/core/support/string.h" #include "src/core/transport/chttp2_transport.h" + #include #include #include @@ -195,6 +198,7 @@ grpc_channel *grpc_channel_create(const char *target, #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; int n = 0; + GRPC_STAP_TIMING_NS_BEGIN(1); filters[n++] = &grpc_client_surface_filter; if (grpc_channel_args_is_census_enabled(args)) { filters[n++] = &grpc_client_census_filter; @@ -210,6 +214,6 @@ grpc_channel *grpc_channel_create(const char *target, grpc_client_setup_create_and_attach(grpc_channel_get_channel_stack(channel), args, mdctx, initiate_setup, done_setup, s); - + GRPC_STAP_TIMING_NS_END(1); return channel; } diff --git a/test/build/systemtap.c b/test/build/systemtap.c new file mode 100644 index 0000000000..66ff38ebd6 --- /dev/null +++ b/test/build/systemtap.c @@ -0,0 +1,42 @@ +/* + * + * Copyright 2015, 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 + +#ifndef _SYS_SDT_H +#error "_SYS_SDT_H not defined, despite being present." +#endif + +int main() { + return 0; +} diff --git a/test/core/profiling/mark_timings.stp b/test/core/profiling/mark_timings.stp new file mode 100644 index 0000000000..a7ccc83c61 --- /dev/null +++ b/test/core/profiling/mark_timings.stp @@ -0,0 +1,32 @@ +global starts, times, times_per_tag + +probe process.mark("timing_ns_begin") { + starts[$arg1, tid()] = gettimeofday_ns(); +} + +probe process.mark("timing_ns_end") { + tag = $arg1 + t = gettimeofday_ns(); + if (s = starts[tag, tid()]) { + times[tag, tid()] <<< t-s; + delete starts[tag, tid()]; + } +} + +probe end { + printf("%15s %9s %10s %10s %10s %10s\n", "tag", "tid", "count", + "min(ns)", "avg(ns)", "max(ns)"); + foreach ([tag+, tid] in times) { + printf("%15X %9d %10d %10d %10d %10d\n", tag, tid, @count(times[tag, tid]), + @min(times[tag, tid]), @avg(times[tag, tid]), @max(times[tag, tid])); + } + + printf("Per tag average of averages\n"); + foreach ([tag+, tid] in times) { + times_per_tag[tag] <<< @avg(times[tag, tid]); + } + printf("%15s %10s %10s\n", "tag", "count", "avg(ns)"); + foreach ([tag+] in times_per_tag) { + printf("%15X %10d %10d\n", tag, @count(times_per_tag[tag]), @avg(times_per_tag[tag])); + } +} -- cgit v1.2.3 From c9e39c0728da270c1bced4938ee9745aeb208890 Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Tue, 28 Apr 2015 10:30:28 -0700 Subject: Fix flow control issue --- src/core/transport/chttp2_transport.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/core') diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index e32ee284e0..786d9cf6eb 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -582,16 +582,18 @@ static int init_stream(grpc_transport *gt, grpc_stream *gs, if (!server_data) { lock(t); s->id = 0; + s->outgoing_window = 0; + s->incoming_window = 0; } else { s->id = (gpr_uint32)(gpr_uintptr)server_data; + s->outgoing_window = + t->settings[PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; + s->incoming_window = + t->settings[SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; t->incoming_stream = s; grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); } - s->outgoing_window = - t->settings[PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; - s->incoming_window = - t->settings[SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; s->queued_write_closed = 0; s->sending_write_closed = 0; s->sent_write_closed = 0; @@ -983,6 +985,10 @@ static void maybe_start_some_streams(transport *t) { GPR_ASSERT(s->id == 0); s->id = t->next_stream_id; t->next_stream_id += 2; + s->outgoing_window = + t->settings[PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; + s->incoming_window = + t->settings[SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE]; grpc_chttp2_stream_map_add(&t->stream_map, s->id, s); stream_list_join(t, s, WRITABLE); } -- cgit v1.2.3 From 0e91956b49c2782ef7fae0acf2362a8863b37ee4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 28 Apr 2015 14:03:47 -0700 Subject: Remove _old apis from the core library --- include/grpc/grpc.h | 106 --------------- src/core/surface/call.c | 325 ---------------------------------------------- src/core/surface/server.c | 54 +------- 3 files changed, 1 insertion(+), 484 deletions(-) (limited to 'src/core') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index b7d14a521e..532fd2d157 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -413,13 +413,6 @@ void grpc_completion_queue_shutdown(grpc_completion_queue *cq); drained and no threads are executing grpc_completion_queue_next */ void grpc_completion_queue_destroy(grpc_completion_queue *cq); -/* Create a call given a grpc_channel, in order to call 'method'. The request - is not sent until grpc_call_invoke is called. All completions are sent to - 'completion_queue'. */ -grpc_call *grpc_channel_create_call_old(grpc_channel *channel, - const char *method, const char *host, - gpr_timespec deadline); - /* Create a call given a grpc_channel, in order to call 'method'. The request is not sent until grpc_call_invoke is called. All completions are sent to 'completion_queue'. */ @@ -475,48 +468,6 @@ void grpc_channel_destroy(grpc_channel *channel); If a grpc_call fails, it's guaranteed that no change to the call state has been made. */ -/* Add a single metadata element to the call, to be sent upon invocation. - flags is a bit-field combination of the write flags defined above. - REQUIRES: grpc_call_start_invoke/grpc_call_server_end_initial_metadata have - not been called on this call. - Produces no events. */ -grpc_call_error grpc_call_add_metadata_old(grpc_call *call, - grpc_metadata *metadata, - gpr_uint32 flags); - -/* Invoke the RPC. Starts sending metadata and request headers on the wire. - flags is a bit-field combination of the write flags defined above. - REQUIRES: Can be called at most once per call. - Can only be called on the client. - Produces a GRPC_CLIENT_METADATA_READ event with metadata_read_tag when - the servers initial metadata has been read. - Produces a GRPC_FINISHED event with finished_tag when the call has been - completed (there may be other events for the call pending at this - time) */ -grpc_call_error grpc_call_invoke_old(grpc_call *call, grpc_completion_queue *cq, - void *metadata_read_tag, - void *finished_tag, gpr_uint32 flags); - -/* Accept an incoming RPC, binding a completion queue to it. - To be called before sending or receiving messages. - REQUIRES: Can be called at most once per call. - Can only be called on the server. - Produces a GRPC_FINISHED event with finished_tag when the call has been - completed (there may be other events for the call pending at this - time) */ -grpc_call_error grpc_call_server_accept_old(grpc_call *call, - grpc_completion_queue *cq, - void *finished_tag); - -/* Start sending metadata. - To be called before sending messages. - flags is a bit-field combination of the write flags defined above. - REQUIRES: Can be called at most once per call. - Can only be called on the server. - Must be called after grpc_call_server_accept */ -grpc_call_error grpc_call_server_end_initial_metadata_old(grpc_call *call, - gpr_uint32 flags); - /* Called by clients to cancel an RPC on the server. Can be called multiple times, from any thread. */ grpc_call_error grpc_call_cancel(grpc_call *call); @@ -531,66 +482,9 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *call, grpc_status_code status, const char *description); -/* Queue a byte buffer for writing. - flags is a bit-field combination of the write flags defined above. - A write with byte_buffer null is allowed, and will not send any bytes on the - wire. If this is performed without GRPC_WRITE_BUFFER_HINT flag it provides - a mechanism to flush any previously buffered writes to outgoing flow control. - REQUIRES: No other writes are pending on the call. It is only safe to - start the next write after the corresponding write_accepted event - is received. - GRPC_INVOKE_ACCEPTED must have been received by the application - prior to calling this on the client. On the server, - grpc_call_server_end_of_initial_metadata must have been called - successfully. - Produces a GRPC_WRITE_ACCEPTED event. */ -grpc_call_error grpc_call_start_write_old(grpc_call *call, - grpc_byte_buffer *byte_buffer, - void *tag, gpr_uint32 flags); - -/* Queue a status for writing. - REQUIRES: No other writes are pending on the call. - grpc_call_server_end_initial_metadata must have been called on the - call prior to calling this. - Only callable on the server. - Produces a GRPC_FINISH_ACCEPTED event when the status is sent. */ -grpc_call_error grpc_call_start_write_status_old(grpc_call *call, - grpc_status_code status_code, - const char *status_message, - void *tag); - -/* No more messages to send. - REQUIRES: No other writes are pending on the call. - Only callable on the client. - Produces a GRPC_FINISH_ACCEPTED event when all bytes for the call have passed - outgoing flow control. */ -grpc_call_error grpc_call_writes_done_old(grpc_call *call, void *tag); - -/* Initiate a read on a call. Output event contains a byte buffer with the - result of the read. - REQUIRES: No other reads are pending on the call. It is only safe to start - the next read after the corresponding read event is received. - On the client: - GRPC_INVOKE_ACCEPTED must have been received by the application - prior to calling this. - On the server: - grpc_call_server_accept must be called before calling this. - Produces a single GRPC_READ event. */ -grpc_call_error grpc_call_start_read_old(grpc_call *call, void *tag); - /* Destroy a call. */ void grpc_call_destroy(grpc_call *call); -/* Request a call on a server. - Allows the server to create a single GRPC_SERVER_RPC_NEW event, with tag - tag_new. - If the call is subsequently cancelled, the cancellation will occur with tag - tag_cancel. - REQUIRES: Server must not have been shutdown. - NOTE: calling this is the only way to obtain GRPC_SERVER_RPC_NEW events. */ -grpc_call_error grpc_server_request_call_old(grpc_server *server, - void *tag_new); - /* Request notification of a new call */ grpc_call_error grpc_server_request_call( grpc_server *server, grpc_call **call, grpc_call_details *details, diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 6ca1b4e9a1..189a2fd2b3 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -46,9 +46,6 @@ #include #include -typedef struct legacy_state legacy_state; -static void destroy_legacy_state(legacy_state *ls); - typedef enum { REQ_INITIAL = 0, REQ_READY, REQ_DONE } req_state; typedef enum { @@ -225,10 +222,6 @@ struct grpc_call { gpr_slice_buffer incoming_message; gpr_uint32 incoming_message_length; - - /* Data that the legacy api needs to track. To be deleted at some point - soon */ - legacy_state *legacy_state; }; #define CALL_STACK_FROM_CALL(call) ((grpc_call_stack *)((call) + 1)) @@ -352,9 +345,6 @@ static void destroy_call(void *call, int ignored_success) { } grpc_sopb_destroy(&c->send_ops); grpc_sopb_destroy(&c->recv_ops); - if (c->legacy_state) { - destroy_legacy_state(c->legacy_state); - } grpc_bbq_destroy(&c->incoming_queue); gpr_slice_buffer_destroy(&c->incoming_message); gpr_free(c); @@ -403,12 +393,6 @@ static void set_status_details(grpc_call *call, status_source source, call->status[source].details = status; } -static grpc_call_error bind_cq(grpc_call *call, grpc_completion_queue *cq) { - if (call->cq) return GRPC_CALL_ERROR_ALREADY_INVOKED; - call->cq = cq; - return GRPC_CALL_OK; -} - static int is_op_live(grpc_call *call, grpc_ioreq_op op) { gpr_uint8 set = call->request_set[op]; reqinfo_master *master; @@ -1265,312 +1249,3 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, return grpc_call_start_ioreq_and_call_back(call, reqs, out, finish_batch, tag); } - -/* - * LEGACY API IMPLEMENTATION - * All this code will disappear as soon as wrappings are updated - */ - -struct legacy_state { - gpr_uint8 md_out_buffer; - size_t md_out_count[2]; - size_t md_out_capacity[2]; - grpc_metadata *md_out[2]; - grpc_byte_buffer *msg_out; - - /* input buffers */ - grpc_metadata_array initial_md_in; - grpc_metadata_array trailing_md_in; - - size_t details_capacity; - char *details; - grpc_status_code status; - - char *send_details; - - size_t msg_in_read_idx; - grpc_byte_buffer *msg_in; - - void *finished_tag; -}; - -static legacy_state *get_legacy_state(grpc_call *call) { - if (call->legacy_state == NULL) { - call->legacy_state = gpr_malloc(sizeof(legacy_state)); - memset(call->legacy_state, 0, sizeof(legacy_state)); - } - return call->legacy_state; -} - -static void destroy_legacy_state(legacy_state *ls) { - size_t i, j; - for (i = 0; i < 2; i++) { - for (j = 0; j < ls->md_out_count[i]; j++) { - gpr_free((char *)ls->md_out[i][j].key); - gpr_free((char *)ls->md_out[i][j].value); - } - gpr_free(ls->md_out[i]); - } - gpr_free(ls->initial_md_in.metadata); - gpr_free(ls->trailing_md_in.metadata); - gpr_free(ls->details); - gpr_free(ls->send_details); - gpr_free(ls); -} - -grpc_call_error grpc_call_add_metadata_old(grpc_call *call, - grpc_metadata *metadata, - gpr_uint32 flags) { - legacy_state *ls; - grpc_metadata *mdout; - - lock(call); - ls = get_legacy_state(call); - - if (ls->md_out_count[ls->md_out_buffer] == - ls->md_out_capacity[ls->md_out_buffer]) { - ls->md_out_capacity[ls->md_out_buffer] = - GPR_MAX(ls->md_out_capacity[ls->md_out_buffer] * 3 / 2, - ls->md_out_capacity[ls->md_out_buffer] + 8); - ls->md_out[ls->md_out_buffer] = gpr_realloc( - ls->md_out[ls->md_out_buffer], - sizeof(grpc_metadata) * ls->md_out_capacity[ls->md_out_buffer]); - } - mdout = &ls->md_out[ls->md_out_buffer][ls->md_out_count[ls->md_out_buffer]++]; - mdout->key = gpr_strdup(metadata->key); - mdout->value = gpr_malloc(metadata->value_length); - mdout->value_length = metadata->value_length; - memcpy((char *)mdout->value, metadata->value, metadata->value_length); - - unlock(call); - - return GRPC_CALL_OK; -} - -static void finish_status(grpc_call *call, grpc_op_error status, - void *ignored) { - legacy_state *ls; - - lock(call); - ls = get_legacy_state(call); - grpc_cq_end_finished(call->cq, ls->finished_tag, call, do_nothing, NULL, - ls->status, ls->details, ls->trailing_md_in.metadata, - ls->trailing_md_in.count); - unlock(call); -} - -static void finish_recv_metadata(grpc_call *call, grpc_op_error status, - void *tag) { - legacy_state *ls; - - lock(call); - ls = get_legacy_state(call); - if (status == GRPC_OP_OK) { - grpc_cq_end_client_metadata_read(call->cq, tag, call, do_nothing, NULL, - ls->initial_md_in.count, - ls->initial_md_in.metadata); - - } else { - grpc_cq_end_client_metadata_read(call->cq, tag, call, do_nothing, NULL, 0, - NULL); - } - unlock(call); -} - -static void finish_send_metadata(grpc_call *call, grpc_op_error status, - void *tag) {} - -grpc_call_error grpc_call_invoke_old(grpc_call *call, grpc_completion_queue *cq, - void *metadata_read_tag, - void *finished_tag, gpr_uint32 flags) { - grpc_ioreq reqs[4]; - legacy_state *ls; - grpc_call_error err; - - grpc_cq_begin_op(cq, call, GRPC_CLIENT_METADATA_READ); - grpc_cq_begin_op(cq, call, GRPC_FINISHED); - - lock(call); - ls = get_legacy_state(call); - err = bind_cq(call, cq); - if (err != GRPC_CALL_OK) goto done; - - ls->finished_tag = finished_tag; - - reqs[0].op = GRPC_IOREQ_SEND_INITIAL_METADATA; - reqs[0].data.send_metadata.count = ls->md_out_count[ls->md_out_buffer]; - reqs[0].data.send_metadata.metadata = ls->md_out[ls->md_out_buffer]; - ls->md_out_buffer++; - err = start_ioreq(call, reqs, 1, finish_send_metadata, NULL); - if (err != GRPC_CALL_OK) goto done; - - reqs[0].op = GRPC_IOREQ_RECV_INITIAL_METADATA; - reqs[0].data.recv_metadata = &ls->initial_md_in; - err = start_ioreq(call, reqs, 1, finish_recv_metadata, metadata_read_tag); - if (err != GRPC_CALL_OK) goto done; - - reqs[0].op = GRPC_IOREQ_RECV_TRAILING_METADATA; - reqs[0].data.recv_metadata = &ls->trailing_md_in; - reqs[1].op = GRPC_IOREQ_RECV_STATUS; - reqs[1].data.recv_status.user_data = &ls->status; - reqs[1].data.recv_status.set_value = set_status_value_directly; - reqs[2].op = GRPC_IOREQ_RECV_STATUS_DETAILS; - reqs[2].data.recv_status_details.details = &ls->details; - reqs[2].data.recv_status_details.details_capacity = &ls->details_capacity; - reqs[3].op = GRPC_IOREQ_RECV_CLOSE; - err = start_ioreq(call, reqs, 4, finish_status, NULL); - if (err != GRPC_CALL_OK) goto done; - -done: - unlock(call); - return err; -} - -grpc_call_error grpc_call_server_accept_old(grpc_call *call, - grpc_completion_queue *cq, - void *finished_tag) { - grpc_ioreq reqs[2]; - grpc_call_error err; - legacy_state *ls; - - /* inform the completion queue of an incoming operation (corresponding to - finished_tag) */ - grpc_cq_begin_op(cq, call, GRPC_FINISHED); - - lock(call); - ls = get_legacy_state(call); - - err = bind_cq(call, cq); - if (err != GRPC_CALL_OK) { - unlock(call); - return err; - } - - ls->finished_tag = finished_tag; - - reqs[0].op = GRPC_IOREQ_RECV_STATUS; - reqs[0].data.recv_status.user_data = &ls->status; - reqs[0].data.recv_status.set_value = set_status_value_directly; - reqs[1].op = GRPC_IOREQ_RECV_CLOSE; - err = start_ioreq(call, reqs, 2, finish_status, NULL); - unlock(call); - return err; -} - -static void finish_send_initial_metadata(grpc_call *call, grpc_op_error status, - void *tag) {} - -grpc_call_error grpc_call_server_end_initial_metadata_old(grpc_call *call, - gpr_uint32 flags) { - grpc_ioreq req; - grpc_call_error err; - legacy_state *ls; - - lock(call); - ls = get_legacy_state(call); - req.op = GRPC_IOREQ_SEND_INITIAL_METADATA; - req.data.send_metadata.count = ls->md_out_count[ls->md_out_buffer]; - req.data.send_metadata.metadata = ls->md_out[ls->md_out_buffer]; - err = start_ioreq(call, &req, 1, finish_send_initial_metadata, NULL); - unlock(call); - - return err; -} - -static void finish_read_event(void *p, grpc_op_error error) { - if (p) grpc_byte_buffer_destroy(p); -} - -static void finish_read(grpc_call *call, grpc_op_error error, void *tag) { - legacy_state *ls; - grpc_byte_buffer *msg; - lock(call); - ls = get_legacy_state(call); - msg = ls->msg_in; - grpc_cq_end_read(call->cq, tag, call, finish_read_event, msg, msg); - unlock(call); -} - -grpc_call_error grpc_call_start_read_old(grpc_call *call, void *tag) { - legacy_state *ls; - grpc_ioreq req; - grpc_call_error err; - - grpc_cq_begin_op(call->cq, call, GRPC_READ); - - lock(call); - ls = get_legacy_state(call); - req.op = GRPC_IOREQ_RECV_MESSAGE; - req.data.recv_message = &ls->msg_in; - err = start_ioreq(call, &req, 1, finish_read, tag); - unlock(call); - return err; -} - -static void finish_write(grpc_call *call, grpc_op_error status, void *tag) { - lock(call); - grpc_byte_buffer_destroy(get_legacy_state(call)->msg_out); - unlock(call); - grpc_cq_end_write_accepted(call->cq, tag, call, do_nothing, NULL, status); -} - -grpc_call_error grpc_call_start_write_old(grpc_call *call, - grpc_byte_buffer *byte_buffer, - void *tag, gpr_uint32 flags) { - grpc_ioreq req; - legacy_state *ls; - grpc_call_error err; - - grpc_cq_begin_op(call->cq, call, GRPC_WRITE_ACCEPTED); - - lock(call); - ls = get_legacy_state(call); - ls->msg_out = grpc_byte_buffer_copy(byte_buffer); - req.op = GRPC_IOREQ_SEND_MESSAGE; - req.data.send_message = ls->msg_out; - err = start_ioreq(call, &req, 1, finish_write, tag); - unlock(call); - - return err; -} - -static void finish_finish(grpc_call *call, grpc_op_error status, void *tag) { - grpc_cq_end_finish_accepted(call->cq, tag, call, do_nothing, NULL, status); -} - -grpc_call_error grpc_call_writes_done_old(grpc_call *call, void *tag) { - grpc_ioreq req; - grpc_call_error err; - grpc_cq_begin_op(call->cq, call, GRPC_FINISH_ACCEPTED); - - lock(call); - req.op = GRPC_IOREQ_SEND_CLOSE; - err = start_ioreq(call, &req, 1, finish_finish, tag); - unlock(call); - - return err; -} - -grpc_call_error grpc_call_start_write_status_old(grpc_call *call, - grpc_status_code status, - const char *details, - void *tag) { - grpc_ioreq reqs[3]; - grpc_call_error err; - legacy_state *ls; - grpc_cq_begin_op(call->cq, call, GRPC_FINISH_ACCEPTED); - - lock(call); - ls = get_legacy_state(call); - reqs[0].op = GRPC_IOREQ_SEND_TRAILING_METADATA; - reqs[0].data.send_metadata.count = ls->md_out_count[ls->md_out_buffer]; - reqs[0].data.send_metadata.metadata = ls->md_out[ls->md_out_buffer]; - reqs[1].op = GRPC_IOREQ_SEND_STATUS; - reqs[1].data.send_status.code = status; - reqs[1].data.send_status.details = ls->send_details = gpr_strdup(details); - reqs[2].op = GRPC_IOREQ_SEND_CLOSE; - err = start_ioreq(call, reqs, 3, finish_finish, tag); - unlock(call); - - return err; -} diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 83caefcbc6..ac89589dc8 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -69,7 +69,7 @@ typedef struct { call_data *prev; } call_link; -typedef enum { LEGACY_CALL, BATCH_CALL, REGISTERED_CALL } requested_call_type; +typedef enum { BATCH_CALL, REGISTERED_CALL } requested_call_type; typedef struct { requested_call_type type; @@ -165,10 +165,6 @@ typedef enum { ZOMBIED } call_state; -typedef struct legacy_data { - grpc_metadata_array initial_metadata; -} legacy_data; - struct call_data { grpc_call *call; @@ -178,7 +174,6 @@ struct call_data { gpr_timespec deadline; int got_initial_metadata; - legacy_data *legacy; grpc_completion_queue *cq_new; grpc_stream_op_buffer *recv_ops; @@ -557,11 +552,6 @@ static void destroy_call_elem(grpc_call_element *elem) { grpc_mdstr_unref(calld->path); } - if (calld->legacy) { - gpr_free(calld->legacy->initial_metadata.metadata); - gpr_free(calld->legacy); - } - server_unref(chand->server); } @@ -998,7 +988,6 @@ static grpc_call_error queue_call_request(grpc_server *server, return GRPC_CALL_OK; } switch (rc->type) { - case LEGACY_CALL: case BATCH_CALL: calld = call_list_remove_head(&server->lists[PENDING_START], PENDING_START); @@ -1057,16 +1046,6 @@ grpc_call_error grpc_server_request_registered_call( return queue_call_request(server, &rc); } -grpc_call_error grpc_server_request_call_old(grpc_server *server, - void *tag_new) { - requested_call rc; - grpc_cq_begin_op(server->unregistered_cq, NULL, GRPC_SERVER_RPC_NEW); - rc.type = LEGACY_CALL; - rc.tag = tag_new; - return queue_call_request(server, &rc); -} - -static void publish_legacy(grpc_call *call, grpc_op_error status, void *tag); static void publish_registered_or_batch(grpc_call *call, grpc_op_error status, void *tag); static void publish_was_not_set(grpc_call *call, grpc_op_error status, @@ -1098,14 +1077,6 @@ static void begin_call(grpc_server *server, call_data *calld, an ioreq op, that should complete immediately. */ switch (rc->type) { - case LEGACY_CALL: - calld->legacy = gpr_malloc(sizeof(legacy_data)); - memset(calld->legacy, 0, sizeof(legacy_data)); - r->op = GRPC_IOREQ_RECV_INITIAL_METADATA; - r->data.recv_metadata = &calld->legacy->initial_metadata; - r++; - publish = publish_legacy; - break; case BATCH_CALL: cpstr(&rc->data.batch.details->host, &rc->data.batch.details->host_capacity, calld->host); @@ -1144,10 +1115,6 @@ static void begin_call(grpc_server *server, call_data *calld, static void fail_call(grpc_server *server, requested_call *rc) { switch (rc->type) { - case LEGACY_CALL: - grpc_cq_end_new_rpc(server->unregistered_cq, rc->tag, NULL, do_nothing, - NULL, NULL, NULL, gpr_inf_past, 0, NULL); - break; case BATCH_CALL: *rc->data.batch.call = NULL; rc->data.batch.initial_metadata->count = 0; @@ -1163,25 +1130,6 @@ static void fail_call(grpc_server *server, requested_call *rc) { } } -static void publish_legacy(grpc_call *call, grpc_op_error status, void *tag) { - grpc_call_element *elem = - grpc_call_stack_element(grpc_call_get_call_stack(call), 0); - call_data *calld = elem->call_data; - channel_data *chand = elem->channel_data; - grpc_server *server = chand->server; - - if (status == GRPC_OP_OK) { - grpc_cq_end_new_rpc(server->unregistered_cq, tag, call, do_nothing, NULL, - grpc_mdstr_as_c_string(calld->path), - grpc_mdstr_as_c_string(calld->host), calld->deadline, - calld->legacy->initial_metadata.count, - calld->legacy->initial_metadata.metadata); - } else { - gpr_log(GPR_ERROR, "should never reach here"); - abort(); - } -} - static void publish_registered_or_batch(grpc_call *call, grpc_op_error status, void *tag) { grpc_call_element *elem = -- cgit v1.2.3 From 87ab19f8131a54a07590b365e8ae9303ace4c1c1 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(-) (limited to 'src/core') 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 8a5bce35419abd3d0b51498afcdd091b39683930 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Apr 2015 07:49:47 -0700 Subject: Incoming stream id validation fixes - correct log message on an invalid stream id - add an additional check that the low bit indicates a client stream id on the server --- src/core/transport/chttp2_transport.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index e32ee284e0..1bb6e7f960 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -1327,7 +1327,10 @@ static int init_header_frame_parser(transport *t, int is_continuation) { gpr_log(GPR_ERROR, "ignoring out of order new stream request on server; last stream " "id=%d, new stream id=%d", - t->last_incoming_stream_id, t->incoming_stream); + t->last_incoming_stream_id, t->incoming_stream_id); + return init_skip_frame(t, 1); + } else if ((t->incoming_stream_id & 1) == 0) { + gpr_log(GPR_ERROR, "ignoring stream with non-client generated index %d", t->incoming_stream_id); return init_skip_frame(t, 1); } t->incoming_stream = NULL; -- cgit v1.2.3 From 8954e90b72e69ef353eddb1fcfd4765a75b79111 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 29 Apr 2015 09:46:33 -0700 Subject: Integration of Systemtap (STAP) for profiling. This commit includes a faulty Makefile to be fixed in a follow commit. --- BUILD | 6 +- Makefile | 60 ++++++-- build.json | 3 +- src/core/channel/client_channel.c | 4 +- src/core/iomgr/pollset_posix.c | 2 +- src/core/iomgr/tcp_posix.c | 20 +-- src/core/profiling/basic_timers.c | 151 +++++++++++++++++++++ src/core/profiling/stap_probes.d | 1 + src/core/profiling/stap_probes.h | 43 ++++++ src/core/profiling/stap_timers.c | 57 ++++++++ src/core/profiling/timers.c | 138 ------------------- src/core/profiling/timers.h | 98 ++++++++----- src/core/surface/channel_create.c | 4 +- src/core/surface/init.c | 4 +- src/cpp/client/channel.cc | 6 +- src/cpp/common/call.cc | 8 +- src/cpp/server/server.cc | 8 +- templates/Makefile.template | 54 ++++++-- vsprojects/grpc/grpc.vcxproj | 4 +- vsprojects/grpc/grpc.vcxproj.filters | 5 +- vsprojects/grpc_unsecure/grpc_unsecure.vcxproj | 4 +- .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 5 +- 22 files changed, 452 insertions(+), 233 deletions(-) create mode 100644 src/core/profiling/basic_timers.c create mode 100644 src/core/profiling/stap_probes.h create mode 100644 src/core/profiling/stap_timers.c delete mode 100644 src/core/profiling/timers.c (limited to 'src/core') diff --git a/BUILD b/BUILD index e862898eaa..d06571e735 100644 --- a/BUILD +++ b/BUILD @@ -299,7 +299,8 @@ cc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", - "src/core/profiling/timers.c", + "src/core/profiling/basic_timers.c", + "src/core/profiling/stap_timers.c", "src/core/statistics/census_init.c", "src/core/statistics/census_log.c", "src/core/statistics/census_rpc_stats.c", @@ -508,7 +509,8 @@ cc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", - "src/core/profiling/timers.c", + "src/core/profiling/basic_timers.c", + "src/core/profiling/stap_timers.c", "src/core/statistics/census_init.c", "src/core/statistics/census_log.c", "src/core/statistics/census_rpc_stats.c", diff --git a/Makefile b/Makefile index 1955e2fa48..f222c8551e 100644 --- a/Makefile +++ b/Makefile @@ -87,14 +87,23 @@ CPPFLAGS_opt = -O2 LDFLAGS_opt = DEFINES_opt = NDEBUG -VALID_CONFIG_latprof = 1 -CC_latprof = $(DEFAULT_CC) -CXX_latprof = $(DEFAULT_CXX) -LD_latprof = $(DEFAULT_CC) -LDXX_latprof = $(DEFAULT_CXX) -CPPFLAGS_latprof = -O2 -DGRPC_LATENCY_PROFILER -LDFLAGS_latprof = -DEFINES_latprof = NDEBUG +VALID_CONFIG_basicprof = 1 +CC_basicprof = $(DEFAULT_CC) +CXX_basicprof = $(DEFAULT_CXX) +LD_basicprof = $(DEFAULT_CC) +LDXX_basicprof = $(DEFAULT_CXX) +CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER +LDFLAGS_basicprof = +DEFINES_basicprof = NDEBUG + +VALID_CONFIG_stapprof = 1 +CC_stapprof = $(DEFAULT_CC) +CXX_stapprof = $(DEFAULT_CXX) +LD_stapprof = $(DEFAULT_CC) +LDXX_stapprof = $(DEFAULT_CXX) +CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER +LDFLAGS_stapprof = +DEFINES_stapprof = NDEBUG VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -394,7 +403,6 @@ HAS_SYSTEMTAP = false ifeq ($(HAS_SYSTEMTAP_HEADERS),true) ifeq ($(HAS_DTRACE),true) HAS_SYSTEMTAP = true -DEFINES += GRPC_STAP_PROFILER endif endif @@ -565,6 +573,17 @@ protoc_dep_message: @echo " make run_dep_checks" @echo +systemtap_dep_error: + @echo + @echo "DEPENDENCY ERROR" + @echo + @echo "Under the '$(CONFIG)' configutation, the target you are trying " + @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other " + @echo "platforms such as Solaris and *BSD). " + @echo + @echo "Please consult INSTALL to get more information." + @echo + stop: @false @@ -2795,13 +2814,15 @@ $(GENDIR)/test/proto/test.grpc.pb.cc: test/proto/test.proto $(PROTOBUF_DEP) $(PR endif +ifeq ($(CONFIG), stapprof) ifeq ($(HAS_SYSTEMTAP),true) $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d $(E) "[DTRACE] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(DTRACE) -C -h -s $< -o $@ - -src/core/profiling/timers.h: $(GENDIR)/src/core/profiling/stap_probes.h +else +$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop +endif endif $(OBJDIR)/$(CONFIG)/%.o : %.c @@ -2824,6 +2845,17 @@ $(OBJDIR)/$(CONFIG)/%.o : %.cc $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< +ifeq ($(CONFIG), stapprof) +ifeq ($(HAS_SYSTEMTAP),true) +$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d + $(E) "[DTRACE] Compiling $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(DTRACE) -C -h -s $< -o $@ +else +$(GENDIR)/src/core/profiling/stap_probes.c: systemtap_dep_error stop +endif +endif + install: install_c install_cxx install-plugins install-certs verify-install @@ -3223,7 +3255,8 @@ LIBGRPC_SRC = \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ - src/core/profiling/timers.c \ + src/core/profiling/basic_timers.c \ + src/core/profiling/stap_timers.c \ src/core/statistics/census_init.c \ src/core/statistics/census_log.c \ src/core/statistics/census_rpc_stats.c \ @@ -3472,7 +3505,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ - src/core/profiling/timers.c \ + src/core/profiling/basic_timers.c \ + src/core/profiling/stap_timers.c \ src/core/statistics/census_init.c \ src/core/statistics/census_log.c \ src/core/statistics/census_rpc_stats.c \ diff --git a/build.json b/build.json index e072ed67c3..5408ccc0d6 100644 --- a/build.json +++ b/build.json @@ -234,7 +234,8 @@ "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", - "src/core/profiling/timers.c", + "src/core/profiling/basic_timers.c", + "src/core/profiling/stap_timers.c", "src/core/statistics/census_init.c", "src/core/statistics/census_log.c", "src/core/statistics/census_rpc_stats.c", diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 0c241240e2..7be89e5349 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -129,7 +129,7 @@ static void complete_activate(grpc_call_element *elem, grpc_call_op *op) { static void start_rpc(grpc_call_element *elem, grpc_call_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; - GRPC_STAP_TIMING_NS_BEGIN(2); + GRPC_TIMER_BEGIN(PTAG_OTHER_BASE + 1, NULL); gpr_mu_lock(&chand->mu); if (calld->state == CALL_CANCELLED) { gpr_mu_unlock(&chand->mu); @@ -175,7 +175,7 @@ static void start_rpc(grpc_call_element *elem, grpc_call_op *op) { grpc_transport_setup_initiate(chand->transport_setup); } } - GRPC_STAP_TIMING_NS_END(2); + GRPC_TIMER_BEGIN(PTAG_OTHER_BASE + 1, NULL); } static void remove_waiting_child(channel_data *chand, call_data *calld) { diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 60d0dad6d8..4985dcf739 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -411,7 +411,7 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher); r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout); - GRPC_TIMER_MARK(POLL_FINISHED, r); + GRPC_TIMER_MARK(PTAG_POLL_FINISHED, r); grpc_fd_end_poll(&fd_watcher); diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index 86721e9c95..7626a51184 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -327,7 +327,7 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { gpr_slice *final_slices; size_t final_nslices; - GRPC_TIMER_MARK(HANDLE_READ_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_HANDLE_READ, 0); slice_state_init(&read_state, static_read_slices, INLINE_SLICE_BUFFER_SIZE, 0); @@ -350,11 +350,11 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { msg.msg_controllen = 0; msg.msg_flags = 0; - GRPC_TIMER_MARK(RECVMSG_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_RECVMSG, 0); do { read_bytes = recvmsg(tcp->fd, &msg, 0); } while (read_bytes < 0 && errno == EINTR); - GRPC_TIMER_MARK(RECVMSG_END, 0); + GRPC_TIMER_END(PTAG_RECVMSG, 0); if (read_bytes < allocated_bytes) { /* TODO(klempner): Consider a second read first, in hopes of getting a @@ -406,7 +406,7 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { ++iov_size; } } - GRPC_TIMER_MARK(HANDLE_READ_END, 0); + GRPC_TIMER_END(PTAG_HANDLE_READ, 0); } static void grpc_tcp_notify_on_read(grpc_endpoint *ep, grpc_endpoint_read_cb cb, @@ -438,12 +438,12 @@ static grpc_endpoint_write_status grpc_tcp_flush(grpc_tcp *tcp) { msg.msg_controllen = 0; msg.msg_flags = 0; - GRPC_TIMER_MARK(SENDMSG_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_SENDMSG, 0); do { /* TODO(klempner): Cork if this is a partial write */ sent_length = sendmsg(tcp->fd, &msg, 0); } while (sent_length < 0 && errno == EINTR); - GRPC_TIMER_MARK(SENDMSG_END, 0); + GRPC_TIMER_END(PTAG_SENDMSG, 0); if (sent_length < 0) { if (errno == EAGAIN) { @@ -479,7 +479,7 @@ static void grpc_tcp_handle_write(void *arg /* grpc_tcp */, int success) { return; } - GRPC_TIMER_MARK(CB_WRITE_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_TCP_CB_WRITE, 0); write_status = grpc_tcp_flush(tcp); if (write_status == GRPC_ENDPOINT_WRITE_PENDING) { grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_closure); @@ -495,7 +495,7 @@ static void grpc_tcp_handle_write(void *arg /* grpc_tcp */, int success) { cb(tcp->write_user_data, cb_status); grpc_tcp_unref(tcp); } - GRPC_TIMER_MARK(CB_WRITE_END, 0); + GRPC_TIMER_END(PTAG_TCP_CB_WRITE, 0); } static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep, @@ -518,7 +518,7 @@ static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep, } } - GRPC_TIMER_MARK(WRITE_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_TCP_WRITE, 0); GPR_ASSERT(tcp->write_cb == NULL); slice_state_init(&tcp->write_state, slices, nslices, nslices); @@ -532,7 +532,7 @@ static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep, grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_closure); } - GRPC_TIMER_MARK(WRITE_END, 0); + GRPC_TIMER_END(PTAG_TCP_WRITE, 0); return status; } diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c new file mode 100644 index 0000000000..b33afa7e8c --- /dev/null +++ b/src/core/profiling/basic_timers.c @@ -0,0 +1,151 @@ +/* + * + * Copyright 2015, 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 + +#ifdef GRPC_BASIC_PROFILER + +#include "src/core/profiling/timers.h" +#include "src/core/profiling/timers_preciseclock.h" + +#include +#include +#include +#include +#include + +typedef struct grpc_timer_entry { + grpc_precise_clock tm; + int tag; + void* id; + const char* file; + int line; +} grpc_timer_entry; + +struct grpc_timers_log { + gpr_mu mu; + grpc_timer_entry* log; + int num_entries; + int capacity; + int capacity_limit; + FILE* fp; +}; + +grpc_timers_log* grpc_timers_log_global = NULL; + +static grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE* dump) { + grpc_timers_log* log = gpr_malloc(sizeof(*log)); + + /* TODO (vpai): Allow allocation below limit */ + log->log = gpr_malloc(capacity_limit * sizeof(*log->log)); + + /* TODO (vpai): Improve concurrency, do per-thread logging? */ + gpr_mu_init(&log->mu); + + log->num_entries = 0; + log->capacity = log->capacity_limit = capacity_limit; + + log->fp = dump; + + return log; +} + +static void log_report_locked(grpc_timers_log* log) { + FILE* fp = log->fp; + int i; + for (i = 0; i < log->num_entries; i++) { + grpc_timer_entry* entry = &(log->log[i]); + fprintf(fp, "GRPC_LAT_PROF "); + grpc_precise_clock_print(&entry->tm, fp); + fprintf(fp, " %d %p %s %d\n", entry->tag, entry->id, entry->file, + entry->line); + } + + /* Now clear out the log */ + log->num_entries = 0; +} + +static void grpc_timers_log_destroy(grpc_timers_log* log) { + gpr_mu_lock(&log->mu); + log_report_locked(log); + gpr_mu_unlock(&log->mu); + + gpr_free(log->log); + gpr_mu_destroy(&log->mu); + + gpr_free(log); +} + +static void grpc_timers_log_add(grpc_timers_log* log, int tag, void* id, + const char* file, int line) { + grpc_timer_entry* entry; + + /* TODO (vpai) : Improve concurrency */ + gpr_mu_lock(&log->mu); + if (log->num_entries == log->capacity_limit) { + log_report_locked(log); + } + + entry = &log->log[log->num_entries++]; + + grpc_precise_clock_now(&entry->tm); + entry->tag = tag; + entry->id = id; + entry->file = file; + entry->line = line; + + gpr_mu_unlock(&log->mu); +} + +/* Latency profiler API implementation. */ +void grpc_timer_add_mark(int tag, void* id, const char* file, int line) { + grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line); +} + +void grpc_timer_begin(int tag, void* id, const char *file, int line) {} +void grpc_timer_end(int tag, void* id, const char *file, int line) {} + +/* Basic profiler specific API functions. */ +void grpc_timers_global_init(void) { + grpc_timers_log_global = grpc_timers_log_create(100000, stdout); +} + +void grpc_timers_global_destroy(void) { + grpc_timers_log_destroy(grpc_timers_log_global); +} + + +#else /* !GRPC_BASIC_PROFILER */ +void grpc_timers_global_init(void) {} +void grpc_timers_global_destroy(void) {} +#endif /* GRPC_BASIC_PROFILER */ diff --git a/src/core/profiling/stap_probes.d b/src/core/profiling/stap_probes.d index 04881826d0..374eeedd6c 100644 --- a/src/core/profiling/stap_probes.d +++ b/src/core/profiling/stap_probes.d @@ -1,4 +1,5 @@ provider _stap { + probe add_mark(int tag); probe timing_ns_begin(int tag); probe timing_ns_end(int tag); }; diff --git a/src/core/profiling/stap_probes.h b/src/core/profiling/stap_probes.h new file mode 100644 index 0000000000..ba8020c5a3 --- /dev/null +++ b/src/core/profiling/stap_probes.h @@ -0,0 +1,43 @@ +/* Generated by the Systemtap dtrace wrapper */ + +#define _SDT_HAS_SEMAPHORES 1 + + +#define STAP_HAS_SEMAPHORES 1 /* deprecated */ + + +#include + +/* _STAP_ADD_MARK ( int tag) */ +#if defined STAP_SDT_V1 +#define _STAP_ADD_MARK_ENABLED() __builtin_expect (add_mark_semaphore, 0) +#define _stap_add_mark_semaphore add_mark_semaphore +#else +#define _STAP_ADD_MARK_ENABLED() __builtin_expect (_stap_add_mark_semaphore, 0) +#endif +__extension__ extern unsigned short _stap_add_mark_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); +#define _STAP_ADD_MARK(arg1) \ +DTRACE_PROBE1(_stap,add_mark,arg1) + +/* _STAP_TIMING_NS_BEGIN ( int tag) */ +#if defined STAP_SDT_V1 +#define _STAP_TIMING_NS_BEGIN_ENABLED() __builtin_expect (timing_ns_begin_semaphore, 0) +#define _stap_timing_ns_begin_semaphore timing_ns_begin_semaphore +#else +#define _STAP_TIMING_NS_BEGIN_ENABLED() __builtin_expect (_stap_timing_ns_begin_semaphore, 0) +#endif +__extension__ extern unsigned short _stap_timing_ns_begin_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); +#define _STAP_TIMING_NS_BEGIN(arg1) \ +DTRACE_PROBE1(_stap,timing_ns_begin,arg1) + +/* _STAP_TIMING_NS_END ( int tag) */ +#if defined STAP_SDT_V1 +#define _STAP_TIMING_NS_END_ENABLED() __builtin_expect (timing_ns_end_semaphore, 0) +#define _stap_timing_ns_end_semaphore timing_ns_end_semaphore +#else +#define _STAP_TIMING_NS_END_ENABLED() __builtin_expect (_stap_timing_ns_end_semaphore, 0) +#endif +__extension__ extern unsigned short _stap_timing_ns_end_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); +#define _STAP_TIMING_NS_END(arg1) \ +DTRACE_PROBE1(_stap,timing_ns_end,arg1) + diff --git a/src/core/profiling/stap_timers.c b/src/core/profiling/stap_timers.c new file mode 100644 index 0000000000..52fb58a279 --- /dev/null +++ b/src/core/profiling/stap_timers.c @@ -0,0 +1,57 @@ +/* + * + * Copyright 2015, 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 + +#ifdef GRPC_STAP_PROFILER + +#include "src/core/profiling/timers.h" + +#include +/* Generated from src/core/profiling/stap_probes.d */ +#include "src/core/profiling/stap_probes.h" + +/* Latency profiler API implementation. */ +void grpc_timer_add_mark(int tag, void* id, const char *file, int line) { + _STAP_ADD_MARK(tag); +} + +void grpc_timer_begin(int tag, void* id, const char *file, int line) { + _STAP_TIMING_NS_BEGIN(tag); +} + +void grpc_timer_end(int tag, void* id, const char *file, int line) { + _STAP_TIMING_NS_END(tag); +} + +#endif /* GRPC_STAP_PROFILER */ diff --git a/src/core/profiling/timers.c b/src/core/profiling/timers.c deleted file mode 100644 index 7cc79bd22b..0000000000 --- a/src/core/profiling/timers.c +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * Copyright 2015, 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. - * - */ - -#ifdef GRPC_LATENCY_PROFILER - -#include "src/core/profiling/timers.h" -#include "src/core/profiling/timers_preciseclock.h" - -#include -#include -#include -#include -#include - -typedef struct grpc_timer_entry { - grpc_precise_clock tm; - const char* tag; - void* id; - const char* file; - int line; -} grpc_timer_entry; - -struct grpc_timers_log { - gpr_mu mu; - grpc_timer_entry* log; - int num_entries; - int capacity; - int capacity_limit; - FILE* fp; -}; - -grpc_timers_log* grpc_timers_log_global = NULL; - -grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE* dump) { - grpc_timers_log* log = gpr_malloc(sizeof(*log)); - - /* TODO (vpai): Allow allocation below limit */ - log->log = gpr_malloc(capacity_limit * sizeof(*log->log)); - - /* TODO (vpai): Improve concurrency, do per-thread logging? */ - gpr_mu_init(&log->mu); - - log->num_entries = 0; - log->capacity = log->capacity_limit = capacity_limit; - - log->fp = dump; - - return log; -} - -static void log_report_locked(grpc_timers_log* log) { - FILE* fp = log->fp; - int i; - for (i = 0; i < log->num_entries; i++) { - 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, - entry->line); - } - - /* Now clear out the log */ - log->num_entries = 0; -} - -void grpc_timers_log_destroy(grpc_timers_log* log) { - gpr_mu_lock(&log->mu); - log_report_locked(log); - gpr_mu_unlock(&log->mu); - - gpr_free(log->log); - gpr_mu_destroy(&log->mu); - - gpr_free(log); -} - -void grpc_timers_log_add(grpc_timers_log* log, const char* tag, void* id, - const char* file, int line) { - grpc_timer_entry* entry; - - /* TODO (vpai) : Improve concurrency */ - gpr_mu_lock(&log->mu); - if (log->num_entries == log->capacity_limit) { - log_report_locked(log); - } - - entry = &log->log[log->num_entries++]; - - grpc_precise_clock_now(&entry->tm); - entry->tag = tag; - entry->id = id; - entry->file = file; - entry->line = line; - - gpr_mu_unlock(&log->mu); -} - -void grpc_timers_log_global_init(void) { - grpc_timers_log_global = grpc_timers_log_create(100000, stdout); -} - -void grpc_timers_log_global_destroy(void) { - grpc_timers_log_destroy(grpc_timers_log_global); -} -#else /* !GRPC_LATENCY_PROFILER */ -void grpc_timers_log_global_init(void) {} -void grpc_timers_log_global_destroy(void) {} -#endif /* GRPC_LATENCY_PROFILER */ diff --git a/src/core/profiling/timers.h b/src/core/profiling/timers.h index 8fe8a8fe99..a78bbea4ec 100644 --- a/src/core/profiling/timers.h +++ b/src/core/profiling/timers.h @@ -34,52 +34,78 @@ #ifndef GRPC_CORE_PROFILING_TIMERS_H #define GRPC_CORE_PROFILING_TIMERS_H -#include - -#ifdef GRPC_STAP_PROFILER -#include -/* Generated from src/core/profiling/stap_probes.d */ -#include "src/core/profiling/stap_probes.h" - -#define GRPC_STAP_TIMING_NS_BEGIN(tag) _STAP_TIMING_NS_BEGIN(tag) -#define GRPC_STAP_TIMING_NS_END(tag) _STAP_TIMING_NS_END(tag) - -#else /* !GRPC_STAP_PROFILER */ -#define GRPC_STAP_BEGIN_NS(x, s) \ - do { \ - } while (0) -#define GRPC_STAP_END_NS(x, s) \ - do { \ - } while (0) -#endif /* GRPC_STAP_PROFILER */ - #ifdef __cplusplus extern "C" { #endif -#ifdef GRPC_LATENCY_PROFILER +void grpc_timers_global_init(void); +void grpc_timers_global_destroy(void); -typedef struct grpc_timers_log grpc_timers_log; +void grpc_timer_add_mark(int tag, void* id, const char *file, int line); +void grpc_timer_begin(int tag, void* id, const char *file, int line); +void grpc_timer_end(int tag, void* id, const char *file, int line); -grpc_timers_log* grpc_timers_log_create(int capacity_limit, FILE* dump); -void grpc_timers_log_add(grpc_timers_log*, const char* tag, void* id, - const char* file, int line); -void grpc_timers_log_destroy(grpc_timers_log *); +enum profiling_tags { + /* Re. Protos. */ + PTAG_PROTO_SERIALIZE = 100, + PTAG_PROTO_DESERIALIZE = 101, -extern grpc_timers_log *grpc_timers_log_global; + /* Re. sockets. */ + PTAG_HANDLE_READ = 200, + PTAG_SENDMSG = 201, + PTAG_RECVMSG = 202, + PTAG_POLL_FINISHED = 203, + PTAG_TCP_CB_WRITE = 204, + PTAG_TCP_WRITE = 205, -#define GRPC_TIMER_MARK(x, s) \ - grpc_timers_log_add(grpc_timers_log_global, #x, ((void *)(gpr_intptr)(s)), \ - __FILE__, __LINE__) + /* C++ */ + PTAG_CPP_CALL_CREATED = 300, + PTAG_CPP_PERFORM_OPS = 301, -#else /* !GRPC_LATENCY_PROFILER */ -#define GRPC_TIMER_MARK(x, s) \ - do { \ - } while (0) -#endif /* GRPC_LATENCY_PROFILER */ + /* > 1024 Unassigned reserved. For any miscellaneous use. + * Use addition to generate tags from this base or take advantage of the 10 + * zero'd bits for OR-ing. */ + PTAG_OTHER_BASE = 1024 +}; + +#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER)) +/* No profiling. No-op all the things. */ +#define GRPC_TIMER_MARK(tag, id) \ + do {} while(0) + +#define GRPC_TIMER_BEGIN(tag, id) \ + do {} while(0) + +#define GRPC_TIMER_END(tag, id) \ + do {} while(0) + +#else /* at least one profiler requested... */ +/* ... hopefully only one. */ +#if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER) +#error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive." +#endif + +/* Generic profiling interface. */ +#define GRPC_TIMER_MARK(tag, id) \ + grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__) + +#define GRPC_TIMER_BEGIN(tag, id) \ + grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__) + +#define GRPC_TIMER_END(tag, id) \ + grpc_timer_end(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__) + +#ifdef GRPC_STAP_PROFILER +/* Empty placeholder for now. */ +#endif /* GRPC_STAP_PROFILER */ + +#ifdef GRPC_BASIC_PROFILER +typedef struct grpc_timers_log grpc_timers_log; + +extern grpc_timers_log *grpc_timers_log_global; +#endif /* GRPC_BASIC_PROFILER */ -void grpc_timers_log_global_init(void); -void grpc_timers_log_global_destroy(void); +#endif /* at least one profiler requested. */ #ifdef __cplusplus } diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index 73b3670ccc..c44dcce7de 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -198,7 +198,7 @@ grpc_channel *grpc_channel_create(const char *target, #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; int n = 0; - GRPC_STAP_TIMING_NS_BEGIN(1); + GRPC_TIMER_BEGIN(PTAG_OTHER_BASE + 2, NULL); filters[n++] = &grpc_client_surface_filter; if (grpc_channel_args_is_census_enabled(args)) { filters[n++] = &grpc_client_census_filter; @@ -214,6 +214,6 @@ grpc_channel *grpc_channel_create(const char *target, grpc_client_setup_create_and_attach(grpc_channel_get_channel_stack(channel), args, mdctx, initiate_setup, done_setup, s); - GRPC_STAP_TIMING_NS_END(1); + GRPC_TIMER_END(PTAG_OTHER_BASE + 2, NULL); return channel; } diff --git a/src/core/surface/init.c b/src/core/surface/init.c index 5a119a47cc..bfee28e5fc 100644 --- a/src/core/surface/init.c +++ b/src/core/surface/init.c @@ -64,7 +64,7 @@ void grpc_init(void) { grpc_iomgr_init(); grpc_tracer_init("GRPC_TRACE"); census_init(); - grpc_timers_log_global_init(); + grpc_timers_global_init(); } gpr_mu_unlock(&g_init_mu); } @@ -74,7 +74,7 @@ void grpc_shutdown(void) { if (--g_initializations == 0) { grpc_iomgr_shutdown(); census_shutdown(); - grpc_timers_log_global_destroy(); + grpc_timers_global_destroy(); } gpr_mu_unlock(&g_init_mu); } diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index c541ddfb48..3d9d1307a4 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -70,7 +70,7 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context, ? target_.c_str() : context->authority().c_str(), context->raw_deadline()); - GRPC_TIMER_MARK(CALL_CREATED, c_call); + GRPC_TIMER_MARK(PTAG_CPP_CALL_CREATED, c_call); context->set_call(c_call, shared_from_this()); return Call(c_call, this, cq); } @@ -79,11 +79,11 @@ void Channel::PerformOpsOnCall(CallOpBuffer* buf, Call* call) { static const size_t MAX_OPS = 8; size_t nops = MAX_OPS; grpc_op ops[MAX_OPS]; - GRPC_TIMER_MARK(PERFORM_OPS_BEGIN, call->call()); + GRPC_TIMER_BEGIN(PTAG_CPP_PERFORM_OPS, call->call()); buf->FillOps(ops, &nops); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call->call(), ops, nops, buf)); - GRPC_TIMER_MARK(PERFORM_OPS_END, call->call()); + GRPC_TIMER_END(PTAG_CPP_PERFORM_OPS, call->call()); } void* Channel::RegisterMethod(const char* method) { diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index 9878133331..41d64276e2 100644 --- a/src/cpp/common/call.cc +++ b/src/cpp/common/call.cc @@ -232,13 +232,13 @@ void CallOpBuffer::FillOps(grpc_op* ops, size_t* nops) { } if (send_message_ || send_message_buffer_) { if (send_message_) { - GRPC_TIMER_MARK(SER_PROTO_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_PROTO_SERIALIZE, 0); bool success = SerializeProto(*send_message_, &send_buf_); if (!success) { abort(); // TODO handle parse failure } - GRPC_TIMER_MARK(SER_PROTO_END, 0); + GRPC_TIMER_END(PTAG_PROTO_SERIALIZE, 0); } else { send_buf_ = send_message_buffer_->buffer(); } @@ -310,10 +310,10 @@ bool CallOpBuffer::FinalizeResult(void** tag, bool* status) { if (recv_buf_) { got_message = *status; if (recv_message_) { - GRPC_TIMER_MARK(DESER_PROTO_BEGIN, 0); + GRPC_TIMER_BEGIN(PTAG_PROTO_DESERIALIZE, 0); *status = *status && DeserializeProto(recv_buf_, recv_message_); grpc_byte_buffer_destroy(recv_buf_); - GRPC_TIMER_MARK(DESER_PROTO_END, 0); + GRPC_TIMER_END(PTAG_PROTO_DESERIALIZE, 0); } else { recv_message_buffer_->set_buffer(recv_buf_); } diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 1d39378595..c84b9d8d84 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -124,12 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { std::unique_ptr req; std::unique_ptr res; if (has_request_payload_) { - GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_.call()); + GRPC_TIMER_BEGIN(PTAG_PROTO_DESERIALIZE, call_.call()); req.reset(method_->AllocateRequestProto()); if (!DeserializeProto(request_payload_, req.get())) { abort(); // for now } - GRPC_TIMER_MARK(DESER_PROTO_END, call_.call()); + GRPC_TIMER_END(PTAG_PROTO_DESERIALIZE, call_.call()); } if (has_response_payload_) { res.reset(method_->AllocateResponseProto()); @@ -343,9 +343,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { bool orig_status = *status; if (*status && request_) { if (payload_) { - GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_); + GRPC_TIMER_BEGIN(PTAG_PROTO_DESERIALIZE, call_); *status = DeserializeProto(payload_, request_); - GRPC_TIMER_MARK(DESER_PROTO_END, call_); + GRPC_TIMER_END(PTAG_PROTO_DESERIALIZE, call_); } else { *status = false; } diff --git a/templates/Makefile.template b/templates/Makefile.template index 8fe8854d67..cd5eee6e5c 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -101,14 +101,23 @@ CPPFLAGS_opt = -O2 LDFLAGS_opt = DEFINES_opt = NDEBUG -VALID_CONFIG_latprof = 1 -CC_latprof = $(DEFAULT_CC) -CXX_latprof = $(DEFAULT_CXX) -LD_latprof = $(DEFAULT_CC) -LDXX_latprof = $(DEFAULT_CXX) -CPPFLAGS_latprof = -O2 -DGRPC_LATENCY_PROFILER -LDFLAGS_latprof = -DEFINES_latprof = NDEBUG +VALID_CONFIG_basicprof = 1 +CC_basicprof = $(DEFAULT_CC) +CXX_basicprof = $(DEFAULT_CXX) +LD_basicprof = $(DEFAULT_CC) +LDXX_basicprof = $(DEFAULT_CXX) +CPPFLAGS_basicprof = -O2 -DGRPC_BASIC_PROFILER +LDFLAGS_basicprof = +DEFINES_basicprof = NDEBUG + +VALID_CONFIG_stapprof = 1 +CC_stapprof = $(DEFAULT_CC) +CXX_stapprof = $(DEFAULT_CXX) +LD_stapprof = $(DEFAULT_CC) +LDXX_stapprof = $(DEFAULT_CXX) +CPPFLAGS_stapprof = -O2 -DGRPC_STAP_PROFILER +LDFLAGS_stapprof = +DEFINES_stapprof = NDEBUG VALID_CONFIG_dbg = 1 CC_dbg = $(DEFAULT_CC) @@ -408,7 +417,6 @@ HAS_SYSTEMTAP = false ifeq ($(HAS_SYSTEMTAP_HEADERS),true) ifeq ($(HAS_DTRACE),true) HAS_SYSTEMTAP = true -DEFINES += GRPC_STAP_PROFILER endif endif @@ -591,6 +599,17 @@ protoc_dep_message: @echo " make run_dep_checks" @echo +systemtap_dep_error: + @echo + @echo "DEPENDENCY ERROR" + @echo + @echo "Under the '$(CONFIG)' configutation, the target you are trying " + @echo "to build requires systemtap 2.7+ (on Linux) or dtrace (on other " + @echo "platforms such as Solaris and *BSD). " + @echo + @echo "Please consult INSTALL to get more information." + @echo + stop: @false @@ -879,13 +898,15 @@ endif % endfor +ifeq ($(CONFIG), stapprof) ifeq ($(HAS_SYSTEMTAP),true) $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d $(E) "[DTRACE] Compiling $<" $(Q) mkdir -p `dirname $@` $(Q) $(DTRACE) -C -h -s $< -o $@ - -src/core/profiling/timers.h: $(GENDIR)/src/core/profiling/stap_probes.h +else +$(GENDIR)/src/core/profiling/stap_probes.h: systemtap_dep_error stop +endif endif $(OBJDIR)/$(CONFIG)/%.o : %.c @@ -908,6 +929,17 @@ $(OBJDIR)/$(CONFIG)/%.o : %.cc $(Q) mkdir -p `dirname $@` $(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -MMD -MF $(addsuffix .dep, $(basename $@)) -c -o $@ $< +ifeq ($(CONFIG), stapprof) +ifeq ($(HAS_SYSTEMTAP),true) +$(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d + $(E) "[DTRACE] Compiling $<" + $(Q) mkdir -p `dirname $@` + $(Q) $(DTRACE) -C -h -s $< -o $@ +else +$(GENDIR)/src/core/profiling/stap_probes.c: systemtap_dep_error stop +endif +endif + install: install_c install_cxx install-plugins install-certs verify-install diff --git a/vsprojects/grpc/grpc.vcxproj b/vsprojects/grpc/grpc.vcxproj index fc7744f2b7..83a44a37f6 100644 --- a/vsprojects/grpc/grpc.vcxproj +++ b/vsprojects/grpc/grpc.vcxproj @@ -341,7 +341,9 @@ - + + + diff --git a/vsprojects/grpc/grpc.vcxproj.filters b/vsprojects/grpc/grpc.vcxproj.filters index 1dfca58cb5..c29355f6b1 100644 --- a/vsprojects/grpc/grpc.vcxproj.filters +++ b/vsprojects/grpc/grpc.vcxproj.filters @@ -217,7 +217,10 @@ src\core\json - + + src\core\profiling + + src\core\profiling diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj index 670b109e6f..07debcccba 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj @@ -286,7 +286,9 @@ - + + + diff --git a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters index 7c94d4d51e..c886f87c88 100644 --- a/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -160,7 +160,10 @@ src\core\json - + + src\core\profiling + + src\core\profiling -- cgit v1.2.3 From f3764292f0ffa00713063c852384f57300b4064b Mon Sep 17 00:00:00 2001 From: Julien Boeuf Date: Wed, 29 Apr 2015 11:35:07 -0700 Subject: Ref the cache default creds so that we do not crash next time we use it... --- src/core/security/google_default_credentials.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/security/google_default_credentials.c b/src/core/security/google_default_credentials.c index d2f46ddd07..0e4b9fc9d3 100644 --- a/src/core/security/google_default_credentials.c +++ b/src/core/security/google_default_credentials.c @@ -163,7 +163,7 @@ grpc_credentials *grpc_google_default_credentials_create(void) { gpr_mu_lock(&g_mu); if (default_credentials != NULL) { - result = default_credentials; + result = grpc_credentials_ref(default_credentials); serving_cached_credentials = 1; goto end; } -- cgit v1.2.3 From bbc0b775e137e6865c9213086c61b84e7415a9ec Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 29 Apr 2015 14:10:05 -0700 Subject: Merge comments. See below. - Added ptag ignore annotation threshold - prefixed everythig with grpc_ - removed spurious annotations in channel_create.c and client_channel.c - removed stap_probes.h (it's generated from stap_probes.d by make) - Updated Makefile and its template with the right way to generate stap probe headers from its .d definition. --- Makefile | 3 ++- src/core/channel/client_channel.c | 4 --- src/core/iomgr/pollset_posix.c | 2 +- src/core/iomgr/tcp_posix.c | 20 +++++++-------- src/core/profiling/basic_timers.c | 4 ++- src/core/profiling/stap_probes.h | 43 ------------------------------- src/core/profiling/timers.h | 53 +++++++++++++++++++++++---------------- src/core/surface/channel_create.c | 8 ++---- src/cpp/client/channel.cc | 6 ++--- src/cpp/common/call.cc | 8 +++--- src/cpp/server/server.cc | 8 +++--- templates/Makefile.template | 3 ++- 12 files changed, 62 insertions(+), 100 deletions(-) delete mode 100644 src/core/profiling/stap_probes.h (limited to 'src/core') diff --git a/Makefile b/Makefile index d0a1284eb0..1b6c44f737 100644 --- a/Makefile +++ b/Makefile @@ -2814,7 +2814,8 @@ $(GENDIR)/test/proto/test.grpc.pb.cc: test/proto/test.proto $(PROTOBUF_DEP) $(PR endif -ifeq ($(CONFIG), stapprof) +ifeq ($(CONFIG),stapprof) +src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h ifeq ($(HAS_SYSTEMTAP),true) $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d $(E) "[DTRACE] Compiling $<" diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 7be89e5349..bc481e59ca 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -39,9 +39,7 @@ #include "src/core/channel/child_channel.h" #include "src/core/channel/connected_channel.h" #include "src/core/iomgr/iomgr.h" -#include "src/core/profiling/timers.h" #include "src/core/support/string.h" - #include #include #include @@ -129,7 +127,6 @@ static void complete_activate(grpc_call_element *elem, grpc_call_op *op) { static void start_rpc(grpc_call_element *elem, grpc_call_op *op) { call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; - GRPC_TIMER_BEGIN(PTAG_OTHER_BASE + 1, NULL); gpr_mu_lock(&chand->mu); if (calld->state == CALL_CANCELLED) { gpr_mu_unlock(&chand->mu); @@ -175,7 +172,6 @@ static void start_rpc(grpc_call_element *elem, grpc_call_op *op) { grpc_transport_setup_initiate(chand->transport_setup); } } - GRPC_TIMER_BEGIN(PTAG_OTHER_BASE + 1, NULL); } static void remove_waiting_child(channel_data *chand, call_data *calld) { diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 4985dcf739..4d1bcad9e2 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -411,7 +411,7 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher); r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout); - GRPC_TIMER_MARK(PTAG_POLL_FINISHED, r); + GRPC_TIMER_MARK(GRPC_PTAG_POLL_FINISHED, r); grpc_fd_end_poll(&fd_watcher); diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index 7626a51184..40897fb8f8 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -327,7 +327,7 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { gpr_slice *final_slices; size_t final_nslices; - GRPC_TIMER_BEGIN(PTAG_HANDLE_READ, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_HANDLE_READ, 0); slice_state_init(&read_state, static_read_slices, INLINE_SLICE_BUFFER_SIZE, 0); @@ -350,11 +350,11 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { msg.msg_controllen = 0; msg.msg_flags = 0; - GRPC_TIMER_BEGIN(PTAG_RECVMSG, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_RECVMSG, 0); do { read_bytes = recvmsg(tcp->fd, &msg, 0); } while (read_bytes < 0 && errno == EINTR); - GRPC_TIMER_END(PTAG_RECVMSG, 0); + GRPC_TIMER_END(GRPC_PTAG_RECVMSG, 0); if (read_bytes < allocated_bytes) { /* TODO(klempner): Consider a second read first, in hopes of getting a @@ -406,7 +406,7 @@ static void grpc_tcp_handle_read(void *arg /* grpc_tcp */, int success) { ++iov_size; } } - GRPC_TIMER_END(PTAG_HANDLE_READ, 0); + GRPC_TIMER_END(GRPC_PTAG_HANDLE_READ, 0); } static void grpc_tcp_notify_on_read(grpc_endpoint *ep, grpc_endpoint_read_cb cb, @@ -438,12 +438,12 @@ static grpc_endpoint_write_status grpc_tcp_flush(grpc_tcp *tcp) { msg.msg_controllen = 0; msg.msg_flags = 0; - GRPC_TIMER_BEGIN(PTAG_SENDMSG, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_SENDMSG, 0); do { /* TODO(klempner): Cork if this is a partial write */ sent_length = sendmsg(tcp->fd, &msg, 0); } while (sent_length < 0 && errno == EINTR); - GRPC_TIMER_END(PTAG_SENDMSG, 0); + GRPC_TIMER_END(GRPC_PTAG_SENDMSG, 0); if (sent_length < 0) { if (errno == EAGAIN) { @@ -479,7 +479,7 @@ static void grpc_tcp_handle_write(void *arg /* grpc_tcp */, int success) { return; } - GRPC_TIMER_BEGIN(PTAG_TCP_CB_WRITE, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_TCP_CB_WRITE, 0); write_status = grpc_tcp_flush(tcp); if (write_status == GRPC_ENDPOINT_WRITE_PENDING) { grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_closure); @@ -495,7 +495,7 @@ static void grpc_tcp_handle_write(void *arg /* grpc_tcp */, int success) { cb(tcp->write_user_data, cb_status); grpc_tcp_unref(tcp); } - GRPC_TIMER_END(PTAG_TCP_CB_WRITE, 0); + GRPC_TIMER_END(GRPC_PTAG_TCP_CB_WRITE, 0); } static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep, @@ -518,7 +518,7 @@ static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep, } } - GRPC_TIMER_BEGIN(PTAG_TCP_WRITE, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_TCP_WRITE, 0); GPR_ASSERT(tcp->write_cb == NULL); slice_state_init(&tcp->write_state, slices, nslices, nslices); @@ -532,7 +532,7 @@ static grpc_endpoint_write_status grpc_tcp_write(grpc_endpoint *ep, grpc_fd_notify_on_write(tcp->em_fd, &tcp->write_closure); } - GRPC_TIMER_END(PTAG_TCP_WRITE, 0); + GRPC_TIMER_END(GRPC_PTAG_TCP_WRITE, 0); return status; } diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c index b33afa7e8c..f290875f78 100644 --- a/src/core/profiling/basic_timers.c +++ b/src/core/profiling/basic_timers.c @@ -129,7 +129,9 @@ static void grpc_timers_log_add(grpc_timers_log* log, int tag, void* id, /* Latency profiler API implementation. */ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) { - grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line); + if (tag <= GRPC_PTAG_IGNORE_THRESHOLD) { + grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line); + } } void grpc_timer_begin(int tag, void* id, const char *file, int line) {} diff --git a/src/core/profiling/stap_probes.h b/src/core/profiling/stap_probes.h deleted file mode 100644 index ba8020c5a3..0000000000 --- a/src/core/profiling/stap_probes.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Generated by the Systemtap dtrace wrapper */ - -#define _SDT_HAS_SEMAPHORES 1 - - -#define STAP_HAS_SEMAPHORES 1 /* deprecated */ - - -#include - -/* _STAP_ADD_MARK ( int tag) */ -#if defined STAP_SDT_V1 -#define _STAP_ADD_MARK_ENABLED() __builtin_expect (add_mark_semaphore, 0) -#define _stap_add_mark_semaphore add_mark_semaphore -#else -#define _STAP_ADD_MARK_ENABLED() __builtin_expect (_stap_add_mark_semaphore, 0) -#endif -__extension__ extern unsigned short _stap_add_mark_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); -#define _STAP_ADD_MARK(arg1) \ -DTRACE_PROBE1(_stap,add_mark,arg1) - -/* _STAP_TIMING_NS_BEGIN ( int tag) */ -#if defined STAP_SDT_V1 -#define _STAP_TIMING_NS_BEGIN_ENABLED() __builtin_expect (timing_ns_begin_semaphore, 0) -#define _stap_timing_ns_begin_semaphore timing_ns_begin_semaphore -#else -#define _STAP_TIMING_NS_BEGIN_ENABLED() __builtin_expect (_stap_timing_ns_begin_semaphore, 0) -#endif -__extension__ extern unsigned short _stap_timing_ns_begin_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); -#define _STAP_TIMING_NS_BEGIN(arg1) \ -DTRACE_PROBE1(_stap,timing_ns_begin,arg1) - -/* _STAP_TIMING_NS_END ( int tag) */ -#if defined STAP_SDT_V1 -#define _STAP_TIMING_NS_END_ENABLED() __builtin_expect (timing_ns_end_semaphore, 0) -#define _stap_timing_ns_end_semaphore timing_ns_end_semaphore -#else -#define _STAP_TIMING_NS_END_ENABLED() __builtin_expect (_stap_timing_ns_end_semaphore, 0) -#endif -__extension__ extern unsigned short _stap_timing_ns_end_semaphore __attribute__ ((unused)) __attribute__ ((section (".probes"))); -#define _STAP_TIMING_NS_END(arg1) \ -DTRACE_PROBE1(_stap,timing_ns_end,arg1) - diff --git a/src/core/profiling/timers.h b/src/core/profiling/timers.h index a78bbea4ec..d0b8286c03 100644 --- a/src/core/profiling/timers.h +++ b/src/core/profiling/timers.h @@ -45,27 +45,30 @@ void grpc_timer_add_mark(int tag, void* id, const char *file, int line); void grpc_timer_begin(int tag, void* id, const char *file, int line); void grpc_timer_end(int tag, void* id, const char *file, int line); -enum profiling_tags { +enum grpc_profiling_tags { + /* Any GRPC_PTAG_* >= than the threshold won't generate any profiling mark. */ + GRPC_PTAG_IGNORE_THRESHOLD = 1000000, + /* Re. Protos. */ - PTAG_PROTO_SERIALIZE = 100, - PTAG_PROTO_DESERIALIZE = 101, + GRPC_PTAG_PROTO_SERIALIZE = 100 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_PROTO_DESERIALIZE = 101 + GRPC_PTAG_IGNORE_THRESHOLD, /* Re. sockets. */ - PTAG_HANDLE_READ = 200, - PTAG_SENDMSG = 201, - PTAG_RECVMSG = 202, - PTAG_POLL_FINISHED = 203, - PTAG_TCP_CB_WRITE = 204, - PTAG_TCP_WRITE = 205, + GRPC_PTAG_HANDLE_READ = 200 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_SENDMSG = 201 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_RECVMSG = 202 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_POLL_FINISHED = 203 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_TCP_CB_WRITE = 204 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_TCP_WRITE = 205 + GRPC_PTAG_IGNORE_THRESHOLD, /* C++ */ - PTAG_CPP_CALL_CREATED = 300, - PTAG_CPP_PERFORM_OPS = 301, + GRPC_PTAG_CPP_CALL_CREATED = 300 + GRPC_PTAG_IGNORE_THRESHOLD, + GRPC_PTAG_CPP_PERFORM_OPS = 301 + GRPC_PTAG_IGNORE_THRESHOLD, /* > 1024 Unassigned reserved. For any miscellaneous use. - * Use addition to generate tags from this base or take advantage of the 10 - * zero'd bits for OR-ing. */ - PTAG_OTHER_BASE = 1024 + * Use addition to generate tags from this base or take advantage of the 10 + * zero'd bits for OR-ing. */ + GRPC_PTAG_OTHER_BASE = 1024 }; #if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER)) @@ -86,14 +89,20 @@ enum profiling_tags { #endif /* Generic profiling interface. */ -#define GRPC_TIMER_MARK(tag, id) \ - grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__) - -#define GRPC_TIMER_BEGIN(tag, id) \ - grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__) - -#define GRPC_TIMER_END(tag, id) \ - grpc_timer_end(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__) +#define GRPC_TIMER_MARK(tag, id) \ + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \ + grpc_timer_add_mark(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \ + } + +#define GRPC_TIMER_BEGIN(tag, id) \ + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \ + grpc_timer_begin(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \ + } + +#define GRPC_TIMER_END(tag, id) \ + if (tag < GRPC_PTAG_IGNORE_THRESHOLD) { \ + grpc_timer_end(tag, ((void *)(gpr_intptr)(id)), __FILE__, __LINE__); \ + } #ifdef GRPC_STAP_PROFILER /* Empty placeholder for now. */ diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c index c44dcce7de..3104b1d00d 100644 --- a/src/core/surface/channel_create.c +++ b/src/core/surface/channel_create.c @@ -31,7 +31,6 @@ * */ - #include "src/core/iomgr/sockaddr.h" #include @@ -49,12 +48,10 @@ #include "src/core/iomgr/endpoint.h" #include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/tcp_client.h" -#include "src/core/profiling/timers.h" -#include "src/core/support/string.h" #include "src/core/surface/channel.h" #include "src/core/surface/client.h" +#include "src/core/support/string.h" #include "src/core/transport/chttp2_transport.h" - #include #include #include @@ -198,7 +195,6 @@ grpc_channel *grpc_channel_create(const char *target, #define MAX_FILTERS 3 const grpc_channel_filter *filters[MAX_FILTERS]; int n = 0; - GRPC_TIMER_BEGIN(PTAG_OTHER_BASE + 2, NULL); filters[n++] = &grpc_client_surface_filter; if (grpc_channel_args_is_census_enabled(args)) { filters[n++] = &grpc_client_census_filter; @@ -214,6 +210,6 @@ grpc_channel *grpc_channel_create(const char *target, grpc_client_setup_create_and_attach(grpc_channel_get_channel_stack(channel), args, mdctx, initiate_setup, done_setup, s); - GRPC_TIMER_END(PTAG_OTHER_BASE + 2, NULL); + return channel; } diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc index 3d9d1307a4..475a20d883 100644 --- a/src/cpp/client/channel.cc +++ b/src/cpp/client/channel.cc @@ -70,7 +70,7 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context, ? target_.c_str() : context->authority().c_str(), context->raw_deadline()); - GRPC_TIMER_MARK(PTAG_CPP_CALL_CREATED, c_call); + GRPC_TIMER_MARK(GRPC_PTAG_CPP_CALL_CREATED, c_call); context->set_call(c_call, shared_from_this()); return Call(c_call, this, cq); } @@ -79,11 +79,11 @@ void Channel::PerformOpsOnCall(CallOpBuffer* buf, Call* call) { static const size_t MAX_OPS = 8; size_t nops = MAX_OPS; grpc_op ops[MAX_OPS]; - GRPC_TIMER_BEGIN(PTAG_CPP_PERFORM_OPS, call->call()); + GRPC_TIMER_BEGIN(GRPC_PTAG_CPP_PERFORM_OPS, call->call()); buf->FillOps(ops, &nops); GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call->call(), ops, nops, buf)); - GRPC_TIMER_END(PTAG_CPP_PERFORM_OPS, call->call()); + GRPC_TIMER_END(GRPC_PTAG_CPP_PERFORM_OPS, call->call()); } void* Channel::RegisterMethod(const char* method) { diff --git a/src/cpp/common/call.cc b/src/cpp/common/call.cc index 41d64276e2..a60282316a 100644 --- a/src/cpp/common/call.cc +++ b/src/cpp/common/call.cc @@ -232,13 +232,13 @@ void CallOpBuffer::FillOps(grpc_op* ops, size_t* nops) { } if (send_message_ || send_message_buffer_) { if (send_message_) { - GRPC_TIMER_BEGIN(PTAG_PROTO_SERIALIZE, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_SERIALIZE, 0); bool success = SerializeProto(*send_message_, &send_buf_); if (!success) { abort(); // TODO handle parse failure } - GRPC_TIMER_END(PTAG_PROTO_SERIALIZE, 0); + GRPC_TIMER_END(GRPC_PTAG_PROTO_SERIALIZE, 0); } else { send_buf_ = send_message_buffer_->buffer(); } @@ -310,10 +310,10 @@ bool CallOpBuffer::FinalizeResult(void** tag, bool* status) { if (recv_buf_) { got_message = *status; if (recv_message_) { - GRPC_TIMER_BEGIN(PTAG_PROTO_DESERIALIZE, 0); + GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, 0); *status = *status && DeserializeProto(recv_buf_, recv_message_); grpc_byte_buffer_destroy(recv_buf_); - GRPC_TIMER_END(PTAG_PROTO_DESERIALIZE, 0); + GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, 0); } else { recv_message_buffer_->set_buffer(recv_buf_); } diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index de536ef2cf..34aac4c584 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -124,12 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { std::unique_ptr req; std::unique_ptr res; if (has_request_payload_) { - GRPC_TIMER_BEGIN(PTAG_PROTO_DESERIALIZE, call_.call()); + GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, call_.call()); req.reset(method_->AllocateRequestProto()); if (!DeserializeProto(request_payload_, req.get())) { abort(); // for now } - GRPC_TIMER_END(PTAG_PROTO_DESERIALIZE, call_.call()); + GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, call_.call()); } if (has_response_payload_) { res.reset(method_->AllocateResponseProto()); @@ -346,9 +346,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { bool orig_status = *status; if (*status && request_) { if (payload_) { - GRPC_TIMER_BEGIN(PTAG_PROTO_DESERIALIZE, call_); + GRPC_TIMER_BEGIN(GRPC_PTAG_PROTO_DESERIALIZE, call_); *status = DeserializeProto(payload_, request_); - GRPC_TIMER_END(PTAG_PROTO_DESERIALIZE, call_); + GRPC_TIMER_END(GRPC_PTAG_PROTO_DESERIALIZE, call_); } else { *status = false; } diff --git a/templates/Makefile.template b/templates/Makefile.template index fa1ff2b9bb..4c63fb2ed9 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -898,7 +898,8 @@ endif % endfor -ifeq ($(CONFIG), stapprof) +ifeq ($(CONFIG),stapprof) +src/core/profiling/stap_timers.c: $(GENDIR)/src/core/profiling/stap_probes.h ifeq ($(HAS_SYSTEMTAP),true) $(GENDIR)/src/core/profiling/stap_probes.h: src/core/profiling/stap_probes.d $(E) "[DTRACE] Compiling $<" -- cgit v1.2.3 From 5f5fd6719b4397c96ae8910088d00b2632f9aec6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Apr 2015 14:12:17 -0700 Subject: Remove ungeneratable enum values and union members --- include/grpc/grpc.h | 32 ------ src/core/surface/completion_queue.c | 96 +--------------- src/core/surface/event_string.c | 45 -------- test/core/end2end/cq_verifier.c | 220 ------------------------------------ test/core/end2end/cq_verifier.h | 13 --- 5 files changed, 1 insertion(+), 405 deletions(-) (limited to 'src/core') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 532fd2d157..91e3d3018d 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -198,15 +198,6 @@ typedef struct grpc_metadata { typedef enum grpc_completion_type { GRPC_QUEUE_SHUTDOWN, /* Shutting down */ GRPC_OP_COMPLETE, /* operation completion */ - GRPC_READ, /* A read has completed */ - GRPC_WRITE_ACCEPTED, /* A write has been accepted by - flow control */ - GRPC_FINISH_ACCEPTED, /* writes_done or write_status has been accepted */ - GRPC_CLIENT_METADATA_READ, /* The metadata array sent by server received at - client */ - GRPC_FINISHED, /* An RPC has finished. The event contains status. - On the server this will be OK or Cancelled. */ - GRPC_SERVER_RPC_NEW, /* A new RPC has arrived at the server */ GRPC_SERVER_SHUTDOWN, /* The server has finished shutting down */ GRPC_COMPLETION_DO_NOT_USE /* must be last, forces users to include a default: case */ @@ -219,30 +210,7 @@ typedef struct grpc_event { /* Data associated with the completion type. Field names match the type of completion as listed in grpc_completion_type. */ union { - /* Contains a pointer to the buffer that was read, or NULL at the end of a - stream. */ - grpc_byte_buffer *read; - grpc_op_error write_accepted; - grpc_op_error finish_accepted; - grpc_op_error invoke_accepted; grpc_op_error op_complete; - struct { - size_t count; - grpc_metadata *elements; - } client_metadata_read; - struct { - grpc_status_code status; - const char *details; - size_t metadata_count; - grpc_metadata *metadata_elements; - } finished; - struct { - const char *method; - const char *host; - gpr_timespec deadline; - size_t metadata_count; - grpc_metadata *metadata_elements; - } server_rpc_new; } data; } grpc_event; diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c index c1c97af337..3e9031807e 100644 --- a/src/core/surface/completion_queue.c +++ b/src/core/surface/completion_queue.c @@ -183,111 +183,17 @@ void grpc_cq_end_server_shutdown(grpc_completion_queue *cc, void *tag) { gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); } -void grpc_cq_end_read(grpc_completion_queue *cc, void *tag, grpc_call *call, - grpc_event_finish_func on_finish, void *user_data, - grpc_byte_buffer *read) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_READ, tag, call, on_finish, user_data); - ev->base.data.read = read; - end_op_locked(cc, GRPC_READ); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - -void grpc_cq_end_write_accepted(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_WRITE_ACCEPTED, tag, call, on_finish, user_data); - ev->base.data.write_accepted = error; - end_op_locked(cc, GRPC_WRITE_ACCEPTED); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - -void grpc_cq_end_op_complete(grpc_completion_queue *cc, void *tag, - grpc_call *call, grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_OP_COMPLETE, tag, call, on_finish, user_data); - ev->base.data.write_accepted = error; - end_op_locked(cc, GRPC_OP_COMPLETE); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - void grpc_cq_end_op(grpc_completion_queue *cc, void *tag, grpc_call *call, grpc_event_finish_func on_finish, void *user_data, grpc_op_error error) { event *ev; gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); ev = add_locked(cc, GRPC_OP_COMPLETE, tag, call, on_finish, user_data); - ev->base.data.write_accepted = error; + ev->base.data.op_complete = error; end_op_locked(cc, GRPC_OP_COMPLETE); gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); } -void grpc_cq_end_finish_accepted(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_FINISH_ACCEPTED, tag, call, on_finish, user_data); - ev->base.data.finish_accepted = error; - end_op_locked(cc, GRPC_FINISH_ACCEPTED); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - -void grpc_cq_end_client_metadata_read(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, size_t count, - grpc_metadata *elements) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_CLIENT_METADATA_READ, tag, call, on_finish, - user_data); - ev->base.data.client_metadata_read.count = count; - ev->base.data.client_metadata_read.elements = elements; - end_op_locked(cc, GRPC_CLIENT_METADATA_READ); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - -void grpc_cq_end_finished(grpc_completion_queue *cc, void *tag, grpc_call *call, - grpc_event_finish_func on_finish, void *user_data, - grpc_status_code status, const char *details, - grpc_metadata *metadata_elements, - size_t metadata_count) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_FINISHED, tag, call, on_finish, user_data); - ev->base.data.finished.status = status; - ev->base.data.finished.details = details; - ev->base.data.finished.metadata_count = metadata_count; - ev->base.data.finished.metadata_elements = metadata_elements; - end_op_locked(cc, GRPC_FINISHED); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - -void grpc_cq_end_new_rpc(grpc_completion_queue *cc, void *tag, grpc_call *call, - grpc_event_finish_func on_finish, void *user_data, - const char *method, const char *host, - gpr_timespec deadline, size_t metadata_count, - grpc_metadata *metadata_elements) { - event *ev; - gpr_mu_lock(GRPC_POLLSET_MU(&cc->pollset)); - ev = add_locked(cc, GRPC_SERVER_RPC_NEW, tag, call, on_finish, user_data); - ev->base.data.server_rpc_new.method = method; - ev->base.data.server_rpc_new.host = host; - ev->base.data.server_rpc_new.deadline = deadline; - ev->base.data.server_rpc_new.metadata_count = metadata_count; - ev->base.data.server_rpc_new.metadata_elements = metadata_elements; - end_op_locked(cc, GRPC_SERVER_RPC_NEW); - gpr_mu_unlock(GRPC_POLLSET_MU(&cc->pollset)); -} - /* Create a GRPC_QUEUE_SHUTDOWN event without queuing it anywhere */ static event *create_shutdown_event(void) { event *ev = gpr_malloc(sizeof(event)); diff --git a/src/core/surface/event_string.c b/src/core/surface/event_string.c index 0fa3f166e2..30bdff6b85 100644 --- a/src/core/surface/event_string.c +++ b/src/core/surface/event_string.c @@ -62,7 +62,6 @@ static void adderr(gpr_strvec *buf, grpc_op_error err) { char *grpc_event_string(grpc_event *ev) { char *out; - char *tmp; gpr_strvec buf; if (ev == NULL) return gpr_strdup("null"); @@ -76,55 +75,11 @@ char *grpc_event_string(grpc_event *ev) { case GRPC_QUEUE_SHUTDOWN: gpr_strvec_add(&buf, gpr_strdup("QUEUE_SHUTDOWN")); break; - case GRPC_READ: - gpr_strvec_add(&buf, gpr_strdup("READ: ")); - addhdr(&buf, ev); - if (ev->data.read) { - gpr_asprintf(&tmp, " %d bytes", - (int)grpc_byte_buffer_length(ev->data.read)); - gpr_strvec_add(&buf, tmp); - } else { - gpr_strvec_add(&buf, gpr_strdup(" end-of-stream")); - } - break; case GRPC_OP_COMPLETE: gpr_strvec_add(&buf, gpr_strdup("OP_COMPLETE: ")); addhdr(&buf, ev); adderr(&buf, ev->data.op_complete); break; - case GRPC_WRITE_ACCEPTED: - gpr_strvec_add(&buf, gpr_strdup("WRITE_ACCEPTED: ")); - addhdr(&buf, ev); - adderr(&buf, ev->data.write_accepted); - break; - case GRPC_FINISH_ACCEPTED: - gpr_strvec_add(&buf, gpr_strdup("FINISH_ACCEPTED: ")); - addhdr(&buf, ev); - adderr(&buf, ev->data.write_accepted); - break; - case GRPC_CLIENT_METADATA_READ: - gpr_strvec_add(&buf, gpr_strdup("CLIENT_METADATA_READ: ")); - addhdr(&buf, ev); - gpr_asprintf(&tmp, " %d elements", - (int)ev->data.client_metadata_read.count); - gpr_strvec_add(&buf, tmp); - break; - case GRPC_FINISHED: - gpr_strvec_add(&buf, gpr_strdup("FINISHED: ")); - addhdr(&buf, ev); - gpr_asprintf(&tmp, " status=%d details='%s' %d metadata elements", - ev->data.finished.status, ev->data.finished.details, - (int)ev->data.finished.metadata_count); - gpr_strvec_add(&buf, tmp); - break; - case GRPC_SERVER_RPC_NEW: - gpr_strvec_add(&buf, gpr_strdup("SERVER_RPC_NEW: ")); - addhdr(&buf, ev); - gpr_asprintf(&tmp, " method='%s' host='%s' %d metadata elements", - ev->data.server_rpc_new.method, ev->data.server_rpc_new.host, - (int)ev->data.server_rpc_new.metadata_count); - gpr_strvec_add(&buf, tmp); - break; case GRPC_COMPLETION_DO_NOT_USE: gpr_strvec_add(&buf, gpr_strdup("DO_NOT_USE (this is a bug)")); addhdr(&buf, ev); diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 9369dfd7ec..f291e73e3b 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -61,23 +61,7 @@ typedef struct expectation { grpc_completion_type type; void *tag; union { - grpc_op_error finish_accepted; - grpc_op_error write_accepted; grpc_op_error op_complete; - struct { - const char *method; - const char *host; - gpr_timespec deadline; - grpc_call **output_call; - metadata *metadata; - } server_rpc_new; - metadata *client_metadata_read; - struct { - grpc_status_code status; - const char *details; - metadata *metadata; - } finished; - gpr_slice *read; } data; } expectation; @@ -121,17 +105,6 @@ int contains_metadata(grpc_metadata_array *array, const char *key, return has_metadata(array->metadata, array->count, key, value); } -static void verify_and_destroy_metadata(metadata *md, grpc_metadata *elems, - size_t count) { - size_t i; - for (i = 0; i < md->count; i++) { - GPR_ASSERT(has_metadata(elems, count, md->keys[i], md->values[i])); - } - gpr_free(md->keys); - gpr_free(md->values); - gpr_free(md); -} - static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) { size_t i; size_t len = 0; @@ -168,60 +141,13 @@ int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) { return byte_buffer_eq_slice(bb, gpr_slice_from_copied_string(str)); } -static int string_equivalent(const char *a, const char *b) { - if (a == NULL) return b == NULL || b[0] == 0; - if (b == NULL) return a[0] == 0; - return strcmp(a, b) == 0; -} - static void verify_matches(expectation *e, grpc_event *ev) { GPR_ASSERT(e->type == ev->type); switch (e->type) { - case GRPC_FINISH_ACCEPTED: - GPR_ASSERT(e->data.finish_accepted == ev->data.finish_accepted); - break; - case GRPC_WRITE_ACCEPTED: - GPR_ASSERT(e->data.write_accepted == ev->data.write_accepted); - break; - case GRPC_SERVER_RPC_NEW: - GPR_ASSERT(string_equivalent(e->data.server_rpc_new.method, - ev->data.server_rpc_new.method)); - GPR_ASSERT(string_equivalent(e->data.server_rpc_new.host, - ev->data.server_rpc_new.host)); - GPR_ASSERT(gpr_time_cmp(e->data.server_rpc_new.deadline, - ev->data.server_rpc_new.deadline) <= 0); - *e->data.server_rpc_new.output_call = ev->call; - verify_and_destroy_metadata(e->data.server_rpc_new.metadata, - ev->data.server_rpc_new.metadata_elements, - ev->data.server_rpc_new.metadata_count); - break; - case GRPC_CLIENT_METADATA_READ: - verify_and_destroy_metadata(e->data.client_metadata_read, - ev->data.client_metadata_read.elements, - ev->data.client_metadata_read.count); - break; - case GRPC_FINISHED: - if (e->data.finished.status != GRPC_STATUS__DO_NOT_USE) { - GPR_ASSERT(e->data.finished.status == ev->data.finished.status); - GPR_ASSERT(string_equivalent(e->data.finished.details, - ev->data.finished.details)); - } - verify_and_destroy_metadata(e->data.finished.metadata, - ev->data.finished.metadata_elements, - ev->data.finished.metadata_count); - break; case GRPC_QUEUE_SHUTDOWN: gpr_log(GPR_ERROR, "premature queue shutdown"); abort(); break; - case GRPC_READ: - if (e->data.read) { - GPR_ASSERT(byte_buffer_eq_slice(ev->data.read, *e->data.read)); - gpr_free(e->data.read); - } else { - GPR_ASSERT(ev->data.read == NULL); - } - break; case GRPC_OP_COMPLETE: GPR_ASSERT(e->data.op_complete == ev->data.op_complete); break; @@ -234,66 +160,14 @@ static void verify_matches(expectation *e, grpc_event *ev) { } } -static void metadata_expectation(gpr_strvec *buf, metadata *md) { - size_t i; - char *tmp; - - if (!md) { - gpr_strvec_add(buf, gpr_strdup("nil")); - } else { - for (i = 0; i < md->count; i++) { - gpr_asprintf(&tmp, "%c%s:%s", i ? ',' : '{', md->keys[i], md->values[i]); - gpr_strvec_add(buf, tmp); - } - if (md->count) { - gpr_strvec_add(buf, gpr_strdup("}")); - } - } -} - static void expectation_to_strvec(gpr_strvec *buf, expectation *e) { - gpr_timespec timeout; char *tmp; switch (e->type) { - case GRPC_FINISH_ACCEPTED: - gpr_asprintf(&tmp, "GRPC_FINISH_ACCEPTED result=%d", - e->data.finish_accepted); - gpr_strvec_add(buf, tmp); - break; - case GRPC_WRITE_ACCEPTED: - gpr_asprintf(&tmp, "GRPC_WRITE_ACCEPTED result=%d", - e->data.write_accepted); - gpr_strvec_add(buf, tmp); - break; case GRPC_OP_COMPLETE: gpr_asprintf(&tmp, "GRPC_OP_COMPLETE result=%d", e->data.op_complete); gpr_strvec_add(buf, tmp); break; - case GRPC_SERVER_RPC_NEW: - timeout = gpr_time_sub(e->data.server_rpc_new.deadline, gpr_now()); - gpr_asprintf(&tmp, "GRPC_SERVER_RPC_NEW method=%s host=%s timeout=%fsec", - e->data.server_rpc_new.method, e->data.server_rpc_new.host, - timeout.tv_sec + 1e-9 * timeout.tv_nsec); - gpr_strvec_add(buf, tmp); - break; - case GRPC_CLIENT_METADATA_READ: - gpr_strvec_add(buf, gpr_strdup("GRPC_CLIENT_METADATA_READ ")); - metadata_expectation(buf, e->data.client_metadata_read); - break; - case GRPC_FINISHED: - gpr_asprintf(&tmp, "GRPC_FINISHED status=%d details=%s ", - e->data.finished.status, e->data.finished.details); - gpr_strvec_add(buf, tmp); - metadata_expectation(buf, e->data.finished.metadata); - break; - case GRPC_READ: - gpr_strvec_add(buf, gpr_strdup("GRPC_READ data=")); - gpr_strvec_add( - buf, - gpr_hexdump((char *)GPR_SLICE_START_PTR(*e->data.read), - GPR_SLICE_LENGTH(*e->data.read), GPR_HEXDUMP_PLAINTEXT)); - break; case GRPC_SERVER_SHUTDOWN: gpr_strvec_add(buf, gpr_strdup("GRPC_SERVER_SHUTDOWN")); break; @@ -395,104 +269,10 @@ static expectation *add(cq_verifier *v, grpc_completion_type type, void *tag) { return e; } -static metadata *metadata_from_args(va_list args) { - metadata *md = gpr_malloc(sizeof(metadata)); - const char *key, *value; - md->count = 0; - md->cap = 0; - md->keys = NULL; - md->values = NULL; - - for (;;) { - key = va_arg(args, const char *); - if (!key) return md; - value = va_arg(args, const char *); - GPR_ASSERT(value); - - if (md->cap == md->count) { - md->cap = GPR_MAX(md->cap + 1, md->cap * 3 / 2); - md->keys = gpr_realloc(md->keys, sizeof(char *) * md->cap); - md->values = gpr_realloc(md->values, sizeof(char *) * md->cap); - } - md->keys[md->count] = (char *)key; - md->values[md->count] = (char *)value; - md->count++; - } -} - -void cq_expect_write_accepted(cq_verifier *v, void *tag, grpc_op_error result) { - add(v, GRPC_WRITE_ACCEPTED, tag)->data.write_accepted = result; -} - void cq_expect_completion(cq_verifier *v, void *tag, grpc_op_error result) { add(v, GRPC_OP_COMPLETE, tag)->data.op_complete = result; } -void cq_expect_finish_accepted(cq_verifier *v, void *tag, - grpc_op_error result) { - add(v, GRPC_FINISH_ACCEPTED, tag)->data.finish_accepted = result; -} - -void cq_expect_read(cq_verifier *v, void *tag, gpr_slice bytes) { - expectation *e = add(v, GRPC_READ, tag); - e->data.read = gpr_malloc(sizeof(gpr_slice)); - *e->data.read = bytes; -} - -void cq_expect_empty_read(cq_verifier *v, void *tag) { - expectation *e = add(v, GRPC_READ, tag); - e->data.read = NULL; -} - -void cq_expect_server_rpc_new(cq_verifier *v, grpc_call **output_call, - void *tag, const char *method, const char *host, - gpr_timespec deadline, ...) { - va_list args; - expectation *e = add(v, GRPC_SERVER_RPC_NEW, tag); - e->data.server_rpc_new.method = method; - e->data.server_rpc_new.host = host; - e->data.server_rpc_new.deadline = deadline; - e->data.server_rpc_new.output_call = output_call; - - va_start(args, deadline); - e->data.server_rpc_new.metadata = metadata_from_args(args); - va_end(args); -} - -void cq_expect_client_metadata_read(cq_verifier *v, void *tag, ...) { - va_list args; - expectation *e = add(v, GRPC_CLIENT_METADATA_READ, tag); - - va_start(args, tag); - e->data.client_metadata_read = metadata_from_args(args); - va_end(args); -} - -static void finished_internal(cq_verifier *v, void *tag, - grpc_status_code status, const char *details, - va_list args) { - expectation *e = add(v, GRPC_FINISHED, tag); - e->data.finished.status = status; - e->data.finished.details = details; - e->data.finished.metadata = metadata_from_args(args); -} - -void cq_expect_finished_with_status(cq_verifier *v, void *tag, - grpc_status_code status, - const char *details, ...) { - va_list args; - va_start(args, details); - finished_internal(v, tag, status, details, args); - va_end(args); -} - -void cq_expect_finished(cq_verifier *v, void *tag, ...) { - va_list args; - va_start(args, tag); - finished_internal(v, tag, GRPC_STATUS__DO_NOT_USE, NULL, args); - va_end(args); -} - void cq_expect_server_shutdown(cq_verifier *v, void *tag) { add(v, GRPC_SERVER_SHUTDOWN, tag); } diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index c1e25d8aa4..bae3c6caf0 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -57,20 +57,7 @@ void cq_verify_empty(cq_verifier *v); Any functions taking ... expect a NULL terminated list of key/value pairs (each pair using two parameter slots) of metadata that MUST be present in the event. */ -void cq_expect_write_accepted(cq_verifier *v, void *tag, grpc_op_error result); -void cq_expect_finish_accepted(cq_verifier *v, void *tag, grpc_op_error result); -void cq_expect_read(cq_verifier *v, void *tag, gpr_slice bytes); -void cq_expect_empty_read(cq_verifier *v, void *tag); void cq_expect_completion(cq_verifier *v, void *tag, grpc_op_error result); -/* *output_call is set the the server call instance */ -void cq_expect_server_rpc_new(cq_verifier *v, grpc_call **output_call, - void *tag, const char *method, const char *host, - gpr_timespec deadline, ...); -void cq_expect_client_metadata_read(cq_verifier *v, void *tag, ...); -void cq_expect_finished_with_status(cq_verifier *v, void *tag, - grpc_status_code status_code, - const char *details, ...); -void cq_expect_finished(cq_verifier *v, void *tag, ...); void cq_expect_server_shutdown(cq_verifier *v, void *tag); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); -- cgit v1.2.3 From 900e45140753b1f0589346f5f420918d8eb39303 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 29 Apr 2015 14:17:10 -0700 Subject: Remove ungeneratable enum values and union members --- src/core/surface/call.c | 4 ++-- src/core/surface/completion_queue.h | 41 ------------------------------------- src/core/surface/server.c | 10 ++++----- 3 files changed, 7 insertions(+), 48 deletions(-) (limited to 'src/core') diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 189a2fd2b3..5513a63332 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -1138,7 +1138,7 @@ static void set_cancelled_value(grpc_status_code status, void *dest) { } static void finish_batch(grpc_call *call, grpc_op_error result, void *tag) { - grpc_cq_end_op_complete(call->cq, tag, call, do_nothing, NULL, GRPC_OP_OK); + grpc_cq_end_op(call->cq, tag, call, do_nothing, NULL, GRPC_OP_OK); } grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, @@ -1153,7 +1153,7 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, if (nops == 0) { grpc_cq_begin_op(call->cq, call, GRPC_OP_COMPLETE); - grpc_cq_end_op_complete(call->cq, tag, call, do_nothing, NULL, GRPC_OP_OK); + grpc_cq_end_op(call->cq, tag, call, do_nothing, NULL, GRPC_OP_OK); return GRPC_CALL_OK; } diff --git a/src/core/surface/completion_queue.h b/src/core/surface/completion_queue.h index 41024cda14..a0d7eeaac6 100644 --- a/src/core/surface/completion_queue.h +++ b/src/core/surface/completion_queue.h @@ -62,48 +62,7 @@ void grpc_cq_begin_op(grpc_completion_queue *cc, grpc_call *call, Other parameters match the data member of grpc_event */ -/* Queue a GRPC_READ operation */ -void grpc_cq_end_read(grpc_completion_queue *cc, void *tag, grpc_call *call, - grpc_event_finish_func on_finish, void *user_data, - grpc_byte_buffer *read); -/* Queue a GRPC_INVOKE_ACCEPTED operation */ -void grpc_cq_end_invoke_accepted(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error); -/* Queue a GRPC_WRITE_ACCEPTED operation */ -void grpc_cq_end_write_accepted(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error); -/* Queue a GRPC_FINISH_ACCEPTED operation */ -void grpc_cq_end_finish_accepted(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error); /* Queue a GRPC_OP_COMPLETED operation */ -void grpc_cq_end_op_complete(grpc_completion_queue *cc, void *tag, - grpc_call *call, grpc_event_finish_func on_finish, - void *user_data, grpc_op_error error); -/* Queue a GRPC_CLIENT_METADATA_READ operation */ -void grpc_cq_end_client_metadata_read(grpc_completion_queue *cc, void *tag, - grpc_call *call, - grpc_event_finish_func on_finish, - void *user_data, size_t count, - grpc_metadata *elements); - -void grpc_cq_end_finished(grpc_completion_queue *cc, void *tag, grpc_call *call, - grpc_event_finish_func on_finish, void *user_data, - grpc_status_code status, const char *details, - grpc_metadata *metadata_elements, - size_t metadata_count); - -void grpc_cq_end_new_rpc(grpc_completion_queue *cc, void *tag, grpc_call *call, - grpc_event_finish_func on_finish, void *user_data, - const char *method, const char *host, - gpr_timespec deadline, size_t metadata_count, - grpc_metadata *metadata_elements); - void grpc_cq_end_op(grpc_completion_queue *cc, void *tag, grpc_call *call, grpc_event_finish_func on_finish, void *user_data, grpc_op_error error); diff --git a/src/core/surface/server.c b/src/core/surface/server.c index ac89589dc8..01644b4471 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -1118,14 +1118,14 @@ static void fail_call(grpc_server *server, requested_call *rc) { case BATCH_CALL: *rc->data.batch.call = NULL; rc->data.batch.initial_metadata->count = 0; - grpc_cq_end_op_complete(server->unregistered_cq, rc->tag, NULL, - do_nothing, NULL, GRPC_OP_ERROR); + grpc_cq_end_op(server->unregistered_cq, rc->tag, NULL, do_nothing, NULL, + GRPC_OP_ERROR); break; case REGISTERED_CALL: *rc->data.registered.call = NULL; rc->data.registered.initial_metadata->count = 0; - grpc_cq_end_op_complete(rc->data.registered.registered_method->cq, - rc->tag, NULL, do_nothing, NULL, GRPC_OP_ERROR); + grpc_cq_end_op(rc->data.registered.registered_method->cq, rc->tag, NULL, + do_nothing, NULL, GRPC_OP_ERROR); break; } } @@ -1135,7 +1135,7 @@ static void publish_registered_or_batch(grpc_call *call, grpc_op_error status, grpc_call_element *elem = grpc_call_stack_element(grpc_call_get_call_stack(call), 0); call_data *calld = elem->call_data; - grpc_cq_end_op_complete(calld->cq_new, tag, call, do_nothing, NULL, status); + grpc_cq_end_op(calld->cq_new, tag, call, do_nothing, NULL, status); } const grpc_channel_args *grpc_server_get_channel_args(grpc_server *server) { -- cgit v1.2.3 From 7af45f2821504f19244140d4ea9bf69e5d6bf67c Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 29 Apr 2015 16:22:09 -0700 Subject: Fixed bad merge on basic_timers.c --- src/core/profiling/basic_timers.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/core') diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c index 7ad67f4831..8dd944cd36 100644 --- a/src/core/profiling/basic_timers.c +++ b/src/core/profiling/basic_timers.c @@ -47,7 +47,6 @@ typedef struct grpc_timer_entry { grpc_precise_clock tm; - int tag; gpr_thd_id thd; int tag; void* id; -- cgit v1.2.3 From 31e3a6fc69aea5b5af34d86783866d113f9169c3 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 29 Apr 2015 16:36:25 -0700 Subject: Removed redundant if from basic_timers.c --- src/core/profiling/basic_timers.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c index 8dd944cd36..d89bba7b87 100644 --- a/src/core/profiling/basic_timers.c +++ b/src/core/profiling/basic_timers.c @@ -132,9 +132,7 @@ static void grpc_timers_log_add(grpc_timers_log* log, int tag, void* id, /* Latency profiler API implementation. */ void grpc_timer_add_mark(int tag, void* id, const char* file, int line) { - if (tag <= GRPC_PTAG_IGNORE_THRESHOLD) { - grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line); - } + grpc_timers_log_add(grpc_timers_log_global, tag, id, file, line); } void grpc_timer_begin(int tag, void* id, const char *file, int line) {} -- cgit v1.2.3 From 3874ad0833d670d73db88a7afd65145ff2c0f2ae Mon Sep 17 00:00:00 2001 From: zeliard Date: Thu, 30 Apr 2015 16:05:45 +0900 Subject: make initializing overlapped-struct obvious for preventing a ciritical bug --- src/core/iomgr/tcp_windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c index 71534eaa3d..940cd5bcde 100644 --- a/src/core/iomgr/tcp_windows.c +++ b/src/core/iomgr/tcp_windows.c @@ -289,7 +289,7 @@ static grpc_endpoint_write_status win_write(grpc_endpoint *ep, return ret; } - memset(&socket->write_info, 0, sizeof(OVERLAPPED)); + memset(&socket->write_info.overlapped, 0, sizeof(OVERLAPPED)); status = WSASend(socket->socket, buffers, tcp->write_slices.count, &bytes_sent, 0, &socket->write_info.overlapped, NULL); if (allocated) gpr_free(allocated); -- cgit v1.2.3 From 06d64cda3cc215af965f518809a0f3b1ebcfc024 Mon Sep 17 00:00:00 2001 From: zeliard Date: Thu, 30 Apr 2015 18:02:06 +0900 Subject: implement gpr_cpu_num_cores() and gpr_cpu_current_cpu() on Windows --- src/core/support/cpu_windows.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/core') diff --git a/src/core/support/cpu_windows.c b/src/core/support/cpu_windows.c index cb454ccd3b..4f7103d282 100644 --- a/src/core/support/cpu_windows.c +++ b/src/core/support/cpu_windows.c @@ -34,19 +34,17 @@ #include #ifdef GPR_WIN32 - +#include #include unsigned gpr_cpu_num_cores(void) { - /* TODO(jtattermusch): implement */ - gpr_log(GPR_ERROR, "Cannot determine number of CPUs: assuming 1"); - return 1; + SYSTEM_INFO si; + GetSystemInfo(&si); + return si.dwNumberOfProcessors; } unsigned gpr_cpu_current_cpu(void) { - /* TODO(jtattermusch): implement */ - gpr_log(GPR_ERROR, "Cannot determine current CPU"); - return 0; + return GetCurrentProcessorNumber(); } #endif /* GPR_WIN32 */ -- cgit v1.2.3 From 3b1e37d16df885474b5c1b7cc2728bfe6ab3a62e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 30 Apr 2015 09:12:31 -0700 Subject: Fix errant empty data frame after trailers With the metadata batching changes recently, I introduced a bug whereby the http2 stream encoder would end up not being able to set the close bit on a header frame, and instead placed it on a new data frame, which is illegal by the HTTP2 spec. --- src/core/transport/chttp2/stream_encoder.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/transport/chttp2/stream_encoder.c b/src/core/transport/chttp2/stream_encoder.c index cf1e66bf8b..cf78ac50cc 100644 --- a/src/core/transport/chttp2/stream_encoder.c +++ b/src/core/transport/chttp2/stream_encoder.c @@ -122,6 +122,12 @@ static void begin_frame(framer_state *st, frame_type type) { st->output_length_at_start_of_frame = st->output->length; } +static void begin_new_frame(framer_state *st, frame_type type) { + finish_frame(st, 1, 0); + st->last_was_header = 0; + begin_frame(st, type); +} + /* make sure that the current frame is of the type desired, and has sufficient space to add at least about_to_add bytes -- finishes the current frame if needed */ @@ -571,6 +577,7 @@ void grpc_chttp2_encode(grpc_stream_op *ops, size_t ops_count, int eof, a metadata element that needs to be unreffed back into the metadata slot. THIS MAY NOT BE THE SAME ELEMENT (if a decoder table slot got updated). After this loop, we'll do a batch unref of elements. */ + begin_new_frame(&st, HEADER); need_unref |= op->data.metadata.garbage.head != NULL; grpc_metadata_batch_assert_ok(&op->data.metadata); for (l = op->data.metadata.list.head; l; l = l->next) { @@ -580,9 +587,6 @@ void grpc_chttp2_encode(grpc_stream_op *ops, size_t ops_count, int eof, if (gpr_time_cmp(op->data.metadata.deadline, gpr_inf_future) != 0) { deadline_enc(compressor, op->data.metadata.deadline, &st); } - ensure_frame_type(&st, HEADER, 0); - finish_frame(&st, 1, 0); - st.last_was_header = 0; /* force a new header frame */ curop++; break; case GRPC_OP_SLICE: -- cgit v1.2.3 From 67bfefdbd13fa1f8370d0da33ef52612fa338038 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 30 Apr 2015 09:32:37 -0700 Subject: Ensure call alarms are cancelled when the underlying stream closes --- src/core/surface/call.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/core') diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 6ca1b4e9a1..50333eac17 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -727,6 +727,10 @@ static void call_on_done_recv(void *pc, int success) { if (call->recv_state == GRPC_STREAM_CLOSED) { GPR_ASSERT(call->read_state <= READ_STATE_STREAM_CLOSED); call->read_state = READ_STATE_STREAM_CLOSED; + if (call->have_alarm) { + grpc_alarm_cancel(&call->alarm); + call->have_alarm = 0; + } } finish_read_ops(call); } else { -- cgit v1.2.3 From ff4ee964d4741c5239a458c366e762e3b3cb3ccf Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 30 Apr 2015 17:08:46 -0700 Subject: Remove another old function --- src/core/surface/channel.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/core') diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 78f9144c19..be9da2b7f9 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -128,13 +128,6 @@ static grpc_call *grpc_channel_create_call_internal( GPR_ARRAY_SIZE(send_metadata), deadline); } -grpc_call *grpc_channel_create_call_old(grpc_channel *channel, - const char *method, const char *host, - gpr_timespec absolute_deadline) { - return grpc_channel_create_call(channel, NULL, method, host, - absolute_deadline); -} - grpc_call *grpc_channel_create_call(grpc_channel *channel, grpc_completion_queue *cq, const char *method, const char *host, -- cgit v1.2.3 From 81b67112b8616d8fc5fdb64e2f4a3d57159a23cd Mon Sep 17 00:00:00 2001 From: Simon Koo Date: Fri, 1 May 2015 09:40:00 +0900 Subject: make Windows.h lowercase for cross compiling from Linux --- src/core/support/cpu_windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/support/cpu_windows.c b/src/core/support/cpu_windows.c index 4f7103d282..f56bab3f8b 100644 --- a/src/core/support/cpu_windows.c +++ b/src/core/support/cpu_windows.c @@ -34,7 +34,7 @@ #include #ifdef GPR_WIN32 -#include +#include #include unsigned gpr_cpu_num_cores(void) { -- cgit v1.2.3