diff --git a/BUILD b/BUILD index 7c01d6b0bbc..146e0b38647 100644 --- a/BUILD +++ b/BUILD @@ -44,6 +44,7 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "gpr", srcs = [ + "src/core/profiling/timers.h", "src/core/support/block_annotate.h", "src/core/support/env.h", "src/core/support/file.h", @@ -53,6 +54,8 @@ cc_library( "src/core/support/string_win32.h", "src/core/support/thd_internal.h", "src/core/support/time_precise.h", + "src/core/profiling/basic_timers.c", + "src/core/profiling/stap_timers.c", "src/core/support/alloc.c", "src/core/support/cmdline.c", "src/core/support/cpu_iphone.c", @@ -218,7 +221,6 @@ cc_library( "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", - "src/core/profiling/timers.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -356,8 +358,6 @@ cc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", - "src/core/profiling/basic_timers.c", - "src/core/profiling/stap_timers.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", "src/core/surface/byte_buffer_queue.c", @@ -504,7 +504,6 @@ cc_library( "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", - "src/core/profiling/timers.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -622,8 +621,6 @@ cc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", - "src/core/profiling/basic_timers.c", - "src/core/profiling/stap_timers.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", "src/core/surface/byte_buffer_queue.c", @@ -961,6 +958,8 @@ cc_library( objc_library( name = "gpr_objc", srcs = [ + "src/core/profiling/basic_timers.c", + "src/core/profiling/stap_timers.c", "src/core/support/alloc.c", "src/core/support/cmdline.c", "src/core/support/cpu_iphone.c", @@ -1028,6 +1027,7 @@ objc_library( "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/profiling/timers.h", "src/core/support/block_annotate.h", "src/core/support/env.h", "src/core/support/file.h", @@ -1147,8 +1147,6 @@ objc_library( "src/core/json/json_reader.c", "src/core/json/json_string.c", "src/core/json/json_writer.c", - "src/core/profiling/basic_timers.c", - "src/core/profiling/stap_timers.c", "src/core/surface/api_trace.c", "src/core/surface/byte_buffer.c", "src/core/surface/byte_buffer_queue.c", @@ -1292,7 +1290,6 @@ objc_library( "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", - "src/core/profiling/timers.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", diff --git a/Makefile b/Makefile index 6d6dc71acce..788fdb52155 100644 --- a/Makefile +++ b/Makefile @@ -3893,6 +3893,8 @@ clean: LIBGPR_SRC = \ + src/core/profiling/basic_timers.c \ + src/core/profiling/stap_timers.c \ src/core/support/alloc.c \ src/core/support/cmdline.c \ src/core/support/cpu_iphone.c \ @@ -4118,8 +4120,6 @@ LIBGRPC_SRC = \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ - src/core/profiling/basic_timers.c \ - src/core/profiling/stap_timers.c \ src/core/surface/api_trace.c \ src/core/surface/byte_buffer.c \ src/core/surface/byte_buffer_queue.c \ @@ -4400,8 +4400,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ - src/core/profiling/basic_timers.c \ - src/core/profiling/stap_timers.c \ src/core/surface/api_trace.c \ src/core/surface/byte_buffer.c \ src/core/surface/byte_buffer_queue.c \ diff --git a/build.yaml b/build.yaml index 503d7a80c75..0cba1730d1b 100644 --- a/build.yaml +++ b/build.yaml @@ -177,7 +177,6 @@ filegroups: - src/core/json/json_common.h - src/core/json/json_reader.h - src/core/json/json_writer.h - - src/core/profiling/timers.h - src/core/statistics/census_interface.h - src/core/statistics/census_rpc_stats.h - src/core/surface/api_trace.h @@ -292,8 +291,6 @@ filegroups: - src/core/json/json_reader.c - src/core/json/json_string.c - src/core/json/json_writer.c - - src/core/profiling/basic_timers.c - - src/core/profiling/stap_timers.c - src/core/surface/api_trace.c - src/core/surface/byte_buffer.c - src/core/surface/byte_buffer_queue.c @@ -392,6 +389,7 @@ libs: - include/grpc/support/tls_pthread.h - include/grpc/support/useful.h headers: + - src/core/profiling/timers.h - src/core/support/block_annotate.h - src/core/support/env.h - src/core/support/file.h @@ -402,6 +400,8 @@ libs: - src/core/support/thd_internal.h - src/core/support/time_precise.h src: + - src/core/profiling/basic_timers.c + - src/core/profiling/stap_timers.c - src/core/support/alloc.c - src/core/support/cmdline.c - src/core/support/cpu_iphone.c diff --git a/gRPC.podspec b/gRPC.podspec index 5b93281b417..12642b58693 100644 --- a/gRPC.podspec +++ b/gRPC.podspec @@ -63,7 +63,8 @@ Pod::Spec.new do |s| # Core cross-platform gRPC library, written in C. s.subspec 'C-Core' do |ss| - ss.source_files = 'src/core/support/block_annotate.h', + ss.source_files = 'src/core/profiling/timers.h', + 'src/core/support/block_annotate.h', 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', @@ -99,6 +100,8 @@ Pod::Spec.new do |s| 'grpc/support/tls_msvc.h', 'grpc/support/tls_pthread.h', 'grpc/support/useful.h', + 'src/core/profiling/basic_timers.c', + 'src/core/profiling/stap_timers.c', 'src/core/support/alloc.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', @@ -222,7 +225,6 @@ Pod::Spec.new do |s| 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', - 'src/core/profiling/timers.h', 'src/core/statistics/census_interface.h', 'src/core/statistics/census_rpc_stats.h', 'src/core/surface/api_trace.h', @@ -367,8 +369,6 @@ Pod::Spec.new do |s| 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', - 'src/core/profiling/basic_timers.c', - 'src/core/profiling/stap_timers.c', 'src/core/surface/api_trace.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', @@ -419,7 +419,8 @@ Pod::Spec.new do |s| 'src/core/census/operation.c', 'src/core/census/tracing.c' - ss.private_header_files = 'src/core/support/block_annotate.h', + ss.private_header_files = 'src/core/profiling/timers.h', + 'src/core/support/block_annotate.h', 'src/core/support/env.h', 'src/core/support/file.h', 'src/core/support/murmur_hash.h', @@ -513,7 +514,6 @@ Pod::Spec.new do |s| 'src/core/json/json_common.h', 'src/core/json/json_reader.h', 'src/core/json/json_writer.h', - 'src/core/profiling/timers.h', 'src/core/statistics/census_interface.h', 'src/core/statistics/census_rpc_stats.h', 'src/core/surface/api_trace.h', diff --git a/grpc.gyp b/grpc.gyp index 668a6e12f32..8bb148d57d8 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -94,6 +94,8 @@ 'dependencies': [ ], 'sources': [ + 'src/core/profiling/basic_timers.c', + 'src/core/profiling/stap_timers.c', 'src/core/support/alloc.c', 'src/core/support/cmdline.c', 'src/core/support/cpu_iphone.c', @@ -239,8 +241,6 @@ 'src/core/json/json_reader.c', 'src/core/json/json_string.c', 'src/core/json/json_writer.c', - 'src/core/profiling/basic_timers.c', - 'src/core/profiling/stap_timers.c', 'src/core/surface/api_trace.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_queue.c', diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 79c56580843..1bdba5b3c01 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -237,7 +237,7 @@ static void picked_target(grpc_exec_ctx *exec_ctx, void *arg, call_data *calld = arg; grpc_pollset *pollset; - GRPC_TIMER_BEGIN("picked_target", 0); + GPR_TIMER_BEGIN("picked_target", 0); if (calld->picked_channel == NULL) { /* treat this like a cancellation */ @@ -260,7 +260,7 @@ static void picked_target(grpc_exec_ctx *exec_ctx, void *arg, } } - GRPC_TIMER_END("picked_target", 0); + GPR_TIMER_END("picked_target", 0); } static grpc_closure *merge_into_waiting_op(grpc_call_element *elem, @@ -321,7 +321,7 @@ static void perform_transport_stream_op(grpc_exec_ctx *exec_ctx, grpc_subchannel_call *subchannel_call; grpc_lb_policy *lb_policy; grpc_transport_stream_op op2; - GRPC_TIMER_BEGIN("perform_transport_stream_op", 0); + GPR_TIMER_BEGIN("perform_transport_stream_op", 0); GPR_ASSERT(elem->filter == &grpc_client_channel_filter); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); @@ -434,7 +434,7 @@ static void perform_transport_stream_op(grpc_exec_ctx *exec_ctx, break; } - GRPC_TIMER_END("perform_transport_stream_op", 0); + GPR_TIMER_END("perform_transport_stream_op", 0); } static void cc_start_transport_stream_op(grpc_exec_ctx *exec_ctx, diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c index 6c1ed2931fb..477e6075960 100644 --- a/src/core/channel/compress_filter.c +++ b/src/core/channel/compress_filter.c @@ -272,13 +272,13 @@ static void process_send_ops(grpc_call_element *elem, static void compress_start_transport_stream_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op *op) { - GRPC_TIMER_BEGIN("compress_start_transport_stream_op", 0); + GPR_TIMER_BEGIN("compress_start_transport_stream_op", 0); if (op->send_ops && op->send_ops->nops > 0) { process_send_ops(elem, op->send_ops); } - GRPC_TIMER_END("compress_start_transport_stream_op", 0); + GPR_TIMER_END("compress_start_transport_stream_op", 0); /* pass control down the stack */ grpc_call_next_op(exec_ctx, elem, op); diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index 9a7f8c45be7..f78a5cc3159 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -163,10 +163,10 @@ static void hc_mutate_op(grpc_call_element *elem, static void hc_start_transport_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op *op) { - GRPC_TIMER_BEGIN("hc_start_transport_op", 0); + GPR_TIMER_BEGIN("hc_start_transport_op", 0); GRPC_CALL_LOG_OP(GPR_INFO, elem, op); hc_mutate_op(elem, op); - GRPC_TIMER_END("hc_start_transport_op", 0); + GPR_TIMER_END("hc_start_transport_op", 0); grpc_call_next_op(exec_ctx, elem, op); } diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index 16a0c1d3ac0..99e5066a4ef 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -231,10 +231,10 @@ static void hs_start_transport_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op *op) { GRPC_CALL_LOG_OP(GPR_INFO, elem, op); - GRPC_TIMER_BEGIN("hs_start_transport_op", 0); + GPR_TIMER_BEGIN("hs_start_transport_op", 0); hs_mutate_op(elem, op); grpc_call_next_op(exec_ctx, elem, op); - GRPC_TIMER_END("hs_start_transport_op", 0); + GPR_TIMER_END("hs_start_transport_op", 0); } /* Constructor for call_data */ diff --git a/src/core/iomgr/exec_ctx.c b/src/core/iomgr/exec_ctx.c index 1ad39885e43..410b34c5213 100644 --- a/src/core/iomgr/exec_ctx.c +++ b/src/core/iomgr/exec_ctx.c @@ -39,20 +39,20 @@ int grpc_exec_ctx_flush(grpc_exec_ctx *exec_ctx) { int did_something = 0; - GRPC_TIMER_BEGIN("grpc_exec_ctx_flush", 0); + GPR_TIMER_BEGIN("grpc_exec_ctx_flush", 0); while (!grpc_closure_list_empty(exec_ctx->closure_list)) { grpc_closure *c = exec_ctx->closure_list.head; exec_ctx->closure_list.head = exec_ctx->closure_list.tail = NULL; while (c != NULL) { grpc_closure *next = c->next; did_something++; - GRPC_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0); + GPR_TIMER_BEGIN("grpc_exec_ctx_flush.cb", 0); c->cb(exec_ctx, c->cb_arg, c->success); - GRPC_TIMER_END("grpc_exec_ctx_flush.cb", 0); + GPR_TIMER_END("grpc_exec_ctx_flush.cb", 0); c = next; } } - GRPC_TIMER_END("grpc_exec_ctx_flush", 0); + GPR_TIMER_END("grpc_exec_ctx_flush", 0); return did_something; } diff --git a/src/core/iomgr/pollset_multipoller_with_epoll.c b/src/core/iomgr/pollset_multipoller_with_epoll.c index e8743918951..2aafd21dfb5 100644 --- a/src/core/iomgr/pollset_multipoller_with_epoll.c +++ b/src/core/iomgr/pollset_multipoller_with_epoll.c @@ -183,11 +183,11 @@ static void multipoll_with_epoll_pollset_maybe_work_and_unlock( /* TODO(vpai): Consider first doing a 0 timeout poll here to avoid even going into the blocking annotation if possible */ - GRPC_TIMER_BEGIN("poll", 0); + GPR_TIMER_BEGIN("poll", 0); GRPC_SCHEDULING_START_BLOCKING_REGION; poll_rv = grpc_poll_function(pfds, 2, timeout_ms); GRPC_SCHEDULING_END_BLOCKING_REGION; - GRPC_TIMER_END("poll", 0); + GPR_TIMER_END("poll", 0); if (poll_rv < 0) { if (errno != EINTR) { diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 6c813bf27af..4d8bc5374f9 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -101,12 +101,12 @@ static void push_front_worker(grpc_pollset *p, grpc_pollset_worker *worker) { void grpc_pollset_kick_ext(grpc_pollset *p, grpc_pollset_worker *specific_worker, gpr_uint32 flags) { - GRPC_TIMER_BEGIN("grpc_pollset_kick_ext", 0); + GPR_TIMER_BEGIN("grpc_pollset_kick_ext", 0); /* pollset->mu already held */ if (specific_worker != NULL) { if (specific_worker == GRPC_POLLSET_KICK_BROADCAST) { - GRPC_TIMER_BEGIN("grpc_pollset_kick_ext.broadcast", 0); + GPR_TIMER_BEGIN("grpc_pollset_kick_ext.broadcast", 0); GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); for (specific_worker = p->root_worker.next; specific_worker != &p->root_worker; @@ -114,16 +114,16 @@ void grpc_pollset_kick_ext(grpc_pollset *p, grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); } p->kicked_without_pollers = 1; - GRPC_TIMER_END("grpc_pollset_kick_ext.broadcast", 0); + GPR_TIMER_END("grpc_pollset_kick_ext.broadcast", 0); } else if (gpr_tls_get(&g_current_thread_worker) != (gpr_intptr)specific_worker) { - GRPC_TIMER_MARK("different_thread_worker", 0); + GPR_TIMER_MARK("different_thread_worker", 0); if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) { specific_worker->reevaluate_polling_on_wakeup = 1; } grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); } else if ((flags & GRPC_POLLSET_CAN_KICK_SELF) != 0) { - GRPC_TIMER_MARK("kick_yoself", 0); + GPR_TIMER_MARK("kick_yoself", 0); if ((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) != 0) { specific_worker->reevaluate_polling_on_wakeup = 1; } @@ -131,12 +131,12 @@ void grpc_pollset_kick_ext(grpc_pollset *p, } } else if (gpr_tls_get(&g_current_thread_poller) != (gpr_intptr)p) { GPR_ASSERT((flags & GRPC_POLLSET_REEVALUATE_POLLING_ON_WAKEUP) == 0); - GRPC_TIMER_MARK("kick_anonymous", 0); + GPR_TIMER_MARK("kick_anonymous", 0); specific_worker = pop_front_worker(p); if (specific_worker != NULL) { if (gpr_tls_get(&g_current_thread_worker) == (gpr_intptr)specific_worker) { - GRPC_TIMER_MARK("kick_anonymous_not_self", 0); + GPR_TIMER_MARK("kick_anonymous_not_self", 0); push_back_worker(p, specific_worker); specific_worker = pop_front_worker(p); if ((flags & GRPC_POLLSET_CAN_KICK_SELF) == 0 && @@ -147,17 +147,17 @@ void grpc_pollset_kick_ext(grpc_pollset *p, } } if (specific_worker != NULL) { - GRPC_TIMER_MARK("finally_kick", 0); + GPR_TIMER_MARK("finally_kick", 0); push_back_worker(p, specific_worker); grpc_wakeup_fd_wakeup(&specific_worker->wakeup_fd); } } else { - GRPC_TIMER_MARK("kicked_no_pollers", 0); + GPR_TIMER_MARK("kicked_no_pollers", 0); p->kicked_without_pollers = 1; } } - GRPC_TIMER_END("grpc_pollset_kick_ext", 0); + GPR_TIMER_END("grpc_pollset_kick_ext", 0); } void grpc_pollset_kick(grpc_pollset *p, grpc_pollset_worker *specific_worker) { @@ -238,7 +238,7 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, int locked = 1; int queued_work = 0; int keep_polling = 0; - GRPC_TIMER_BEGIN("grpc_pollset_work", 0); + GPR_TIMER_BEGIN("grpc_pollset_work", 0); /* this must happen before we (potentially) drop pollset->mu */ worker->next = worker->prev = NULL; worker->reevaluate_polling_on_wakeup = 0; @@ -283,10 +283,10 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, } gpr_tls_set(&g_current_thread_poller, (gpr_intptr)pollset); gpr_tls_set(&g_current_thread_worker, (gpr_intptr)worker); - GRPC_TIMER_BEGIN("maybe_work_and_unlock", 0); + GPR_TIMER_BEGIN("maybe_work_and_unlock", 0); pollset->vtable->maybe_work_and_unlock(exec_ctx, pollset, worker, deadline, now); - GRPC_TIMER_END("maybe_work_and_unlock", 0); + GPR_TIMER_END("maybe_work_and_unlock", 0); locked = 0; gpr_tls_set(&g_current_thread_poller, 0); gpr_tls_set(&g_current_thread_worker, 0); @@ -341,7 +341,7 @@ void grpc_pollset_work(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, gpr_mu_lock(&pollset->mu); } } - GRPC_TIMER_END("grpc_pollset_work", 0); + GPR_TIMER_END("grpc_pollset_work", 0); } void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, @@ -576,11 +576,11 @@ static void basic_pollset_maybe_work_and_unlock(grpc_exec_ctx *exec_ctx, even going into the blocking annotation if possible */ /* poll fd count (argument 2) is shortened by one if we have no events to poll on - such that it only includes the kicker */ - GRPC_TIMER_BEGIN("poll", 0); + GPR_TIMER_BEGIN("poll", 0); GRPC_SCHEDULING_START_BLOCKING_REGION; r = grpc_poll_function(pfd, nfds, timeout); GRPC_SCHEDULING_END_BLOCKING_REGION; - GRPC_TIMER_END("poll", 0); + GPR_TIMER_END("poll", 0); if (r < 0) { gpr_log(GPR_ERROR, "poll() failed: %s", strerror(errno)); diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c index 9e3773bcd44..915553d5098 100644 --- a/src/core/iomgr/tcp_posix.c +++ b/src/core/iomgr/tcp_posix.c @@ -180,7 +180,7 @@ static void tcp_continue_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { GPR_ASSERT(!tcp->finished_edge); GPR_ASSERT(tcp->iov_size <= MAX_READ_IOVEC); GPR_ASSERT(tcp->incoming_buffer->count <= MAX_READ_IOVEC); - GRPC_TIMER_BEGIN("tcp_continue_read", 0); + GPR_TIMER_BEGIN("tcp_continue_read", 0); while (tcp->incoming_buffer->count < (size_t)tcp->iov_size) { gpr_slice_buffer_add_indexed(tcp->incoming_buffer, @@ -199,11 +199,11 @@ static void tcp_continue_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { msg.msg_controllen = 0; msg.msg_flags = 0; - GRPC_TIMER_BEGIN("recvmsg", 1); + GPR_TIMER_BEGIN("recvmsg", 1); do { read_bytes = recvmsg(tcp->fd, &msg, 0); } while (read_bytes < 0 && errno == EINTR); - GRPC_TIMER_END("recvmsg", 0); + GPR_TIMER_END("recvmsg", 0); if (read_bytes < 0) { /* NB: After calling call_read_cb a parallel call of the read handler may @@ -240,7 +240,7 @@ static void tcp_continue_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { TCP_UNREF(exec_ctx, tcp, "read"); } - GRPC_TIMER_END("tcp_continue_read", 0); + GPR_TIMER_END("tcp_continue_read", 0); } static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */, @@ -316,12 +316,12 @@ static flush_result tcp_flush(grpc_tcp *tcp) { msg.msg_controllen = 0; msg.msg_flags = 0; - GRPC_TIMER_BEGIN("sendmsg", 1); + GPR_TIMER_BEGIN("sendmsg", 1); do { /* TODO(klempner): Cork if this is a partial write */ sent_length = sendmsg(tcp->fd, &msg, SENDMSG_FLAGS); } while (sent_length < 0 && errno == EINTR); - GRPC_TIMER_END("sendmsg", 0); + GPR_TIMER_END("sendmsg", 0); if (sent_length < 0) { if (errno == EAGAIN) { @@ -376,9 +376,9 @@ static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */, } else { cb = tcp->write_cb; tcp->write_cb = NULL; - GRPC_TIMER_BEGIN("tcp_handle_write.cb", 0); + GPR_TIMER_BEGIN("tcp_handle_write.cb", 0); cb->cb(exec_ctx, cb->cb_arg, status == FLUSH_DONE); - GRPC_TIMER_END("tcp_handle_write.cb", 0); + GPR_TIMER_END("tcp_handle_write.cb", 0); TCP_UNREF(exec_ctx, tcp, "write"); } } @@ -399,11 +399,11 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, } } - GRPC_TIMER_BEGIN("tcp_write", 0); + GPR_TIMER_BEGIN("tcp_write", 0); GPR_ASSERT(tcp->write_cb == NULL); if (buf->length == 0) { - GRPC_TIMER_END("tcp_write", 0); + GPR_TIMER_END("tcp_write", 0); grpc_exec_ctx_enqueue(exec_ctx, cb, 1); return; } @@ -420,7 +420,7 @@ static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_exec_ctx_enqueue(exec_ctx, cb, status == FLUSH_DONE); } - GRPC_TIMER_END("tcp_write", 0); + GPR_TIMER_END("tcp_write", 0); } static void tcp_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, diff --git a/src/core/iomgr/wakeup_fd_eventfd.c b/src/core/iomgr/wakeup_fd_eventfd.c index 48eb1afb3d8..f67379e4fcf 100644 --- a/src/core/iomgr/wakeup_fd_eventfd.c +++ b/src/core/iomgr/wakeup_fd_eventfd.c @@ -39,9 +39,11 @@ #include #include -#include "src/core/iomgr/wakeup_fd_posix.h" #include +#include "src/core/iomgr/wakeup_fd_posix.h" +#include "src/core/profiling/timers.h" + static void eventfd_create(grpc_wakeup_fd* fd_info) { int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); /* TODO(klempner): Handle failure more gracefully */ @@ -60,9 +62,11 @@ static void eventfd_consume(grpc_wakeup_fd* fd_info) { static void eventfd_wakeup(grpc_wakeup_fd* fd_info) { int err; + GPR_TIMER_BEGIN("eventfd_wakeup", 0); do { err = eventfd_write(fd_info->read_fd, 1); } while (err < 0 && errno == EINTR); + GPR_TIMER_END("eventfd_wakeup", 0); } static void eventfd_destroy(grpc_wakeup_fd* fd_info) { diff --git a/src/core/profiling/basic_timers.c b/src/core/profiling/basic_timers.c index 8a68277cca2..b49cdd07b3e 100644 --- a/src/core/profiling/basic_timers.c +++ b/src/core/profiling/basic_timers.c @@ -46,18 +46,18 @@ typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type; -typedef struct grpc_timer_entry { +typedef struct gpr_timer_entry { gpr_timespec tm; const char *tagstr; const char *file; int line; char type; gpr_uint8 important; -} grpc_timer_entry; +} gpr_timer_entry; -#define MAX_COUNT (1024 * 1024 / sizeof(grpc_timer_entry)) +#define MAX_COUNT (1024 * 1024 / sizeof(gpr_timer_entry)) -static __thread grpc_timer_entry g_log[MAX_COUNT]; +static __thread gpr_timer_entry g_log[MAX_COUNT]; static __thread int g_count; static gpr_once g_once_init = GPR_ONCE_INIT; static FILE *output_file; @@ -74,7 +74,7 @@ static void log_report() { int i; gpr_once_init(&g_once_init, init_output); for (i = 0; i < g_count; i++) { - grpc_timer_entry *entry = &(g_log[i]); + gpr_timer_entry *entry = &(g_log[i]); fprintf(output_file, "{\"t\": %ld.%09d, \"thd\": \"%p\", \"type\": \"%c\", \"tag\": " "\"%s\", \"file\": \"%s\", \"line\": %d, \"imp\": %d}\n", @@ -87,9 +87,9 @@ static void log_report() { g_count = 0; } -static void grpc_timers_log_add(const char *tagstr, marker_type type, - int important, const char *file, int line) { - grpc_timer_entry *entry; +static void gpr_timers_log_add(const char *tagstr, marker_type type, + int important, const char *file, int line) { + gpr_timer_entry *entry; /* TODO (vpai) : Improve concurrency */ if (g_count == MAX_COUNT) { @@ -107,28 +107,28 @@ static void grpc_timers_log_add(const char *tagstr, marker_type type, } /* Latency profiler API implementation. */ -void grpc_timer_add_mark(const char *tagstr, int important, const char *file, - int line) { - grpc_timers_log_add(tagstr, MARK, important, file, line); +void gpr_timer_add_mark(const char *tagstr, int important, const char *file, + int line) { + gpr_timers_log_add(tagstr, MARK, important, file, line); } -void grpc_timer_begin(const char *tagstr, int important, const char *file, - int line) { - grpc_timers_log_add(tagstr, BEGIN, important, file, line); +void gpr_timer_begin(const char *tagstr, int important, const char *file, + int line) { + gpr_timers_log_add(tagstr, BEGIN, important, file, line); } -void grpc_timer_end(const char *tagstr, int important, const char *file, - int line) { - grpc_timers_log_add(tagstr, END, important, file, line); +void gpr_timer_end(const char *tagstr, int important, const char *file, + int line) { + gpr_timers_log_add(tagstr, END, important, file, line); } /* Basic profiler specific API functions. */ -void grpc_timers_global_init(void) {} +void gpr_timers_global_init(void) {} -void grpc_timers_global_destroy(void) {} +void gpr_timers_global_destroy(void) {} #else /* !GRPC_BASIC_PROFILER */ -void grpc_timers_global_init(void) {} +void gpr_timers_global_init(void) {} -void grpc_timers_global_destroy(void) {} +void gpr_timers_global_destroy(void) {} #endif /* GRPC_BASIC_PROFILER */ diff --git a/src/core/profiling/stap_timers.c b/src/core/profiling/stap_timers.c index 6868a674a98..efcd1af4a1c 100644 --- a/src/core/profiling/stap_timers.c +++ b/src/core/profiling/stap_timers.c @@ -42,23 +42,23 @@ #include "src/core/profiling/stap_probes.h" /* Latency profiler API implementation. */ -void grpc_timer_add_mark(int tag, const char *tagstr, void *id, - const char *file, int line) { +void gpr_timer_add_mark(int tag, const char *tagstr, void *id, const char *file, + int line) { _STAP_ADD_MARK(tag); } -void grpc_timer_add_important_mark(int tag, const char *tagstr, void *id, - const char *file, int line) { +void gpr_timer_add_important_mark(int tag, const char *tagstr, void *id, + const char *file, int line) { _STAP_ADD_IMPORTANT_MARK(tag); } -void grpc_timer_begin(int tag, const char *tagstr, void *id, const char *file, - int line) { +void gpr_timer_begin(int tag, const char *tagstr, void *id, const char *file, + int line) { _STAP_TIMING_NS_BEGIN(tag); } -void grpc_timer_end(int tag, const char *tagstr, void *id, const char *file, - int line) { +void gpr_timer_end(int tag, const char *tagstr, void *id, const char *file, + int line) { _STAP_TIMING_NS_END(tag); } diff --git a/src/core/profiling/timers.h b/src/core/profiling/timers.h index 94251fbcf54..1ea7f71dc36 100644 --- a/src/core/profiling/timers.h +++ b/src/core/profiling/timers.h @@ -38,28 +38,28 @@ extern "C" { #endif -void grpc_timers_global_init(void); -void grpc_timers_global_destroy(void); +void gpr_timers_global_init(void); +void gpr_timers_global_destroy(void); -void grpc_timer_add_mark(const char *tagstr, int important, const char *file, - int line); -void grpc_timer_begin(const char *tagstr, int important, const char *file, - int line); -void grpc_timer_end(const char *tagstr, int important, const char *file, - int line); +void gpr_timer_add_mark(const char *tagstr, int important, const char *file, + int line); +void gpr_timer_begin(const char *tagstr, int important, const char *file, + int line); +void gpr_timer_end(const char *tagstr, int important, const char *file, + int line); #if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER)) /* No profiling. No-op all the things. */ -#define GRPC_TIMER_MARK(tag, important) \ - do { \ +#define GPR_TIMER_MARK(tag, important) \ + do { \ } while (0) -#define GRPC_TIMER_BEGIN(tag, important) \ - do { \ +#define GPR_TIMER_BEGIN(tag, important) \ + do { \ } while (0) -#define GRPC_TIMER_END(tag, important) \ - do { \ +#define GPR_TIMER_END(tag, important) \ + do { \ } while (0) #else /* at least one profiler requested... */ @@ -69,14 +69,14 @@ void grpc_timer_end(const char *tagstr, int important, const char *file, #endif /* Generic profiling interface. */ -#define GRPC_TIMER_MARK(tag, important) \ - grpc_timer_add_mark(tag, important, __FILE__, __LINE__); +#define GPR_TIMER_MARK(tag, important) \ + gpr_timer_add_mark(tag, important, __FILE__, __LINE__); -#define GRPC_TIMER_BEGIN(tag, important) \ - grpc_timer_begin(tag, important, __FILE__, __LINE__); +#define GPR_TIMER_BEGIN(tag, important) \ + gpr_timer_begin(tag, important, __FILE__, __LINE__); -#define GRPC_TIMER_END(tag, important) \ - grpc_timer_end(tag, important, __FILE__, __LINE__); +#define GPR_TIMER_END(tag, important) \ + gpr_timer_end(tag, important, __FILE__, __LINE__); #ifdef GRPC_STAP_PROFILER /* Empty placeholder for now. */ @@ -95,17 +95,17 @@ namespace grpc { class ProfileScope { public: ProfileScope(const char *desc, bool important) : desc_(desc) { - GRPC_TIMER_BEGIN(desc_, important ? 1 : 0); + GPR_TIMER_BEGIN(desc_, important ? 1 : 0); } - ~ProfileScope() { GRPC_TIMER_END(desc_, 0); } + ~ProfileScope() { GPR_TIMER_END(desc_, 0); } private: const char *const desc_; }; } -#define GRPC_TIMER_SCOPE(tag, important) \ - ProfileScope _profile_scope_##__LINE__((tag), (important)) +#define GPR_TIMER_SCOPE(tag, important) \ + ::grpc::ProfileScope _profile_scope_##__LINE__((tag), (important)) #endif #endif /* GRPC_CORE_PROFILING_TIMERS_H */ diff --git a/src/core/support/alloc.c b/src/core/support/alloc.c index beb0e780d0c..bfcb77956b3 100644 --- a/src/core/support/alloc.c +++ b/src/core/support/alloc.c @@ -39,28 +39,28 @@ void *gpr_malloc(size_t size) { void *p; - GRPC_TIMER_BEGIN("gpr_malloc", 0); + GPR_TIMER_BEGIN("gpr_malloc", 0); p = malloc(size); if (!p) { abort(); } - GRPC_TIMER_END("gpr_malloc", 0); + GPR_TIMER_END("gpr_malloc", 0); return p; } void gpr_free(void *p) { - GRPC_TIMER_BEGIN("gpr_free", 0); + GPR_TIMER_BEGIN("gpr_free", 0); free(p); - GRPC_TIMER_END("gpr_free", 0); + GPR_TIMER_END("gpr_free", 0); } void *gpr_realloc(void *p, size_t size) { - GRPC_TIMER_BEGIN("gpr_realloc", 0); + GPR_TIMER_BEGIN("gpr_realloc", 0); p = realloc(p, size); if (!p) { abort(); } - GRPC_TIMER_END("gpr_realloc", 0); + GPR_TIMER_END("gpr_realloc", 0); return p; } diff --git a/src/core/support/sync_posix.c b/src/core/support/sync_posix.c index f356bec9846..39c96feb137 100644 --- a/src/core/support/sync_posix.c +++ b/src/core/support/sync_posix.c @@ -47,15 +47,15 @@ void gpr_mu_init(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_init(mu, NULL) == 0); } void gpr_mu_destroy(gpr_mu* mu) { GPR_ASSERT(pthread_mutex_destroy(mu) == 0); } void gpr_mu_lock(gpr_mu* mu) { - GRPC_TIMER_BEGIN("gpr_mu_lock", 0); + GPR_TIMER_BEGIN("gpr_mu_lock", 0); GPR_ASSERT(pthread_mutex_lock(mu) == 0); - GRPC_TIMER_END("gpr_mu_lock", 0); + GPR_TIMER_END("gpr_mu_lock", 0); } void gpr_mu_unlock(gpr_mu* mu) { - GRPC_TIMER_BEGIN("gpr_mu_unlock", 0); + GPR_TIMER_BEGIN("gpr_mu_unlock", 0); GPR_ASSERT(pthread_mutex_unlock(mu) == 0); - GRPC_TIMER_END("gpr_mu_unlock", 0); + GPR_TIMER_END("gpr_mu_unlock", 0); } int gpr_mu_trylock(gpr_mu* mu) { diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 73c526022d1..9efcb90a56b 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -307,7 +307,7 @@ grpc_call *grpc_call_create(grpc_channel *channel, grpc_call *parent_call, grpc_channel_stack *channel_stack = grpc_channel_get_channel_stack(channel); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_call *call; - GRPC_TIMER_BEGIN("grpc_call_create", 0); + GPR_TIMER_BEGIN("grpc_call_create", 0); call = gpr_malloc(sizeof(grpc_call) + channel_stack->call_stack_size); memset(call, 0, sizeof(grpc_call)); gpr_mu_init(&call->mu); @@ -402,7 +402,7 @@ grpc_call *grpc_call_create(grpc_channel *channel, grpc_call *parent_call, set_deadline_alarm(&exec_ctx, call, send_deadline); } grpc_exec_ctx_finish(&exec_ctx); - GRPC_TIMER_END("grpc_call_create", 0); + GPR_TIMER_END("grpc_call_create", 0); return call; } @@ -464,7 +464,7 @@ void grpc_call_internal_ref(grpc_call *c) { static void destroy_call(grpc_exec_ctx *exec_ctx, grpc_call *call) { size_t i; grpc_call *c = call; - GRPC_TIMER_BEGIN("destroy_call", 0); + GPR_TIMER_BEGIN("destroy_call", 0); grpc_call_stack_destroy(exec_ctx, CALL_STACK_FROM_CALL(c)); GRPC_CHANNEL_INTERNAL_UNREF(exec_ctx, c->channel, "call"); gpr_mu_destroy(&c->mu); @@ -497,7 +497,7 @@ static void destroy_call(grpc_exec_ctx *exec_ctx, grpc_call *call) { GRPC_CQ_INTERNAL_UNREF(c->cq, "bind"); } gpr_free(c); - GRPC_TIMER_END("destroy_call", 0); + GPR_TIMER_END("destroy_call", 0); } #ifdef GRPC_CALL_REF_COUNT_DEBUG @@ -617,7 +617,7 @@ static void unlock(grpc_exec_ctx *exec_ctx, grpc_call *call) { const size_t MAX_RECV_PEEK_AHEAD = 65536; size_t buffered_bytes; - GRPC_TIMER_BEGIN("unlock", 0); + GPR_TIMER_BEGIN("unlock", 0); memset(&op, 0, sizeof(op)); @@ -690,7 +690,7 @@ static void unlock(grpc_exec_ctx *exec_ctx, grpc_call *call) { GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "completing"); } - GRPC_TIMER_END("unlock", 0); + GPR_TIMER_END("unlock", 0); } static void get_final_status(grpc_call *call, grpc_ioreq_data out) { @@ -840,7 +840,7 @@ static void early_out_write_ops(grpc_call *call) { static void call_on_done_send(grpc_exec_ctx *exec_ctx, void *pc, int success) { grpc_call *call = pc; - GRPC_TIMER_BEGIN("call_on_done_send", 0); + GPR_TIMER_BEGIN("call_on_done_send", 0); lock(call); if (call->last_send_contains & (1 << GRPC_IOREQ_SEND_INITIAL_METADATA)) { finish_ioreq_op(call, GRPC_IOREQ_SEND_INITIAL_METADATA, success); @@ -864,11 +864,11 @@ static void call_on_done_send(grpc_exec_ctx *exec_ctx, void *pc, int success) { call->sending = 0; unlock(exec_ctx, call); GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "sending"); - GRPC_TIMER_END("call_on_done_send", 0); + GPR_TIMER_END("call_on_done_send", 0); } static void finish_message(grpc_call *call) { - GRPC_TIMER_BEGIN("finish_message", 0); + GPR_TIMER_BEGIN("finish_message", 0); if (call->error_status_set == 0) { /* TODO(ctiller): this could be a lot faster if coded directly */ grpc_byte_buffer *byte_buffer; @@ -888,7 +888,7 @@ static void finish_message(grpc_call *call) { gpr_slice_buffer_reset_and_unref(&call->incoming_message); GPR_ASSERT(call->incoming_message.count == 0); call->reading_message = 0; - GRPC_TIMER_END("finish_message", 0); + GPR_TIMER_END("finish_message", 0); } static int begin_message(grpc_call *call, grpc_begin_message msg) { @@ -978,7 +978,7 @@ static void call_on_done_recv(grpc_exec_ctx *exec_ctx, void *pc, int success) { grpc_call *child_call; grpc_call *next_child_call; size_t i; - GRPC_TIMER_BEGIN("call_on_done_recv", 0); + GPR_TIMER_BEGIN("call_on_done_recv", 0); lock(call); call->receiving = 0; if (success) { @@ -988,19 +988,19 @@ static void call_on_done_recv(grpc_exec_ctx *exec_ctx, void *pc, int success) { case GRPC_NO_OP: break; case GRPC_OP_METADATA: - GRPC_TIMER_BEGIN("recv_metadata", 0); + GPR_TIMER_BEGIN("recv_metadata", 0); recv_metadata(exec_ctx, call, &op->data.metadata); - GRPC_TIMER_END("recv_metadata", 0); + GPR_TIMER_END("recv_metadata", 0); break; case GRPC_OP_BEGIN_MESSAGE: - GRPC_TIMER_BEGIN("begin_message", 0); + GPR_TIMER_BEGIN("begin_message", 0); success = begin_message(call, op->data.begin_message); - GRPC_TIMER_END("begin_message", 0); + GPR_TIMER_END("begin_message", 0); break; case GRPC_OP_SLICE: - GRPC_TIMER_BEGIN("add_slice_to_message", 0); + GPR_TIMER_BEGIN("add_slice_to_message", 0); success = add_slice_to_message(call, op->data.slice); - GRPC_TIMER_END("add_slice_to_message", 0); + GPR_TIMER_END("add_slice_to_message", 0); break; } } @@ -1046,7 +1046,7 @@ static void call_on_done_recv(grpc_exec_ctx *exec_ctx, void *pc, int success) { unlock(exec_ctx, call); GRPC_CALL_INTERNAL_UNREF(exec_ctx, call, "receiving"); - GRPC_TIMER_END("call_on_done_recv", 0); + GPR_TIMER_END("call_on_done_recv", 0); } static int prepare_application_metadata(grpc_call *call, size_t count, @@ -1524,25 +1524,25 @@ static void recv_metadata(grpc_exec_ctx *exec_ctx, grpc_call *call, grpc_mdelem *mdel = l->md; grpc_mdstr *key = mdel->key; if (key == grpc_channel_get_status_string(call->channel)) { - GRPC_TIMER_BEGIN("status", 0); + GPR_TIMER_BEGIN("status", 0); set_status_code(call, STATUS_FROM_WIRE, decode_status(mdel)); - GRPC_TIMER_END("status", 0); + GPR_TIMER_END("status", 0); } else if (key == grpc_channel_get_message_string(call->channel)) { - GRPC_TIMER_BEGIN("status-details", 0); + GPR_TIMER_BEGIN("status-details", 0); set_status_details(call, STATUS_FROM_WIRE, GRPC_MDSTR_REF(mdel->value)); - GRPC_TIMER_END("status-details", 0); + GPR_TIMER_END("status-details", 0); } else if (key == grpc_channel_get_compression_algorithm_string(call->channel)) { - GRPC_TIMER_BEGIN("compression_algorithm", 0); + GPR_TIMER_BEGIN("compression_algorithm", 0); set_compression_algorithm(call, decode_compression(mdel)); - GRPC_TIMER_END("compression_algorithm", 0); + GPR_TIMER_END("compression_algorithm", 0); } else if (key == grpc_channel_get_encodings_accepted_by_peer_string( call->channel)) { - GRPC_TIMER_BEGIN("encodings_accepted_by_peer", 0); + GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0); set_encodings_accepted_by_peer(call, mdel->value->slice); - GRPC_TIMER_END("encodings_accepted_by_peer", 0); + GPR_TIMER_END("encodings_accepted_by_peer", 0); } else { - GRPC_TIMER_BEGIN("report_up", 0); + GPR_TIMER_BEGIN("report_up", 0); dest = &call->buffered_metadata[is_trailing]; if (dest->count == dest->capacity) { dest->capacity = GPR_MAX(dest->capacity + 8, dest->capacity * 2); @@ -1563,15 +1563,15 @@ static void recv_metadata(grpc_exec_ctx *exec_ctx, grpc_call *call, } call->owned_metadata[call->owned_metadata_count++] = mdel; l->md = NULL; - GRPC_TIMER_END("report_up", 0); + GPR_TIMER_END("report_up", 0); } } if (gpr_time_cmp(md->deadline, gpr_inf_future(md->deadline.clock_type)) != 0 && !call->is_client) { - GRPC_TIMER_BEGIN("set_deadline_alarm", 0); + GPR_TIMER_BEGIN("set_deadline_alarm", 0); set_deadline_alarm(exec_ctx, call, md->deadline); - GRPC_TIMER_END("set_deadline_alarm", 0); + GPR_TIMER_END("set_deadline_alarm", 0); } if (!is_trailing) { call->read_state = READ_STATE_GOT_INITIAL_METADATA; @@ -1634,7 +1634,7 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, grpc_call_error error; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GRPC_TIMER_BEGIN("grpc_call_start_batch", 0); + GPR_TIMER_BEGIN("grpc_call_start_batch", 0); GRPC_API_TRACE( "grpc_call_start_batch(call=%p, ops=%p, nops=%lu, tag=%p, reserved=%p)", @@ -1873,7 +1873,7 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, finish_func, tag); done: grpc_exec_ctx_finish(&exec_ctx); - GRPC_TIMER_END("grpc_call_start_batch", 0); + GPR_TIMER_END("grpc_call_start_batch", 0); return error; } diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c index 7c0183257ca..bc32f554738 100644 --- a/src/core/surface/completion_queue.c +++ b/src/core/surface/completion_queue.c @@ -144,7 +144,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc, int i; grpc_pollset_worker *pluck_worker; - GRPC_TIMER_BEGIN("grpc_cq_end_op", 0); + GPR_TIMER_BEGIN("grpc_cq_end_op", 0); storage->tag = tag; storage->done = done; @@ -178,7 +178,7 @@ void grpc_cq_end_op(grpc_exec_ctx *exec_ctx, grpc_completion_queue *cc, grpc_pollset_shutdown(exec_ctx, &cc->pollset, &cc->pollset_destroy_done); } - GRPC_TIMER_END("grpc_cq_end_op", 0); + GPR_TIMER_END("grpc_cq_end_op", 0); } grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, @@ -189,7 +189,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, gpr_timespec now; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GRPC_TIMER_BEGIN("grpc_completion_queue_next", 0); + GPR_TIMER_BEGIN("grpc_completion_queue_next", 0); GRPC_API_TRACE( "grpc_completion_queue_next(" @@ -238,7 +238,7 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, GRPC_CQ_INTERNAL_UNREF(cc, "next"); grpc_exec_ctx_finish(&exec_ctx); - GRPC_TIMER_END("grpc_completion_queue_next", 0); + GPR_TIMER_END("grpc_completion_queue_next", 0); return ret; } @@ -278,7 +278,7 @@ grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cc, void *tag, int first_loop = 1; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - GRPC_TIMER_BEGIN("grpc_completion_queue_pluck", 0); + GPR_TIMER_BEGIN("grpc_completion_queue_pluck", 0); GRPC_API_TRACE( "grpc_completion_queue_pluck(" @@ -346,7 +346,7 @@ done: GRPC_CQ_INTERNAL_UNREF(cc, "pluck"); grpc_exec_ctx_finish(&exec_ctx); - GRPC_TIMER_END("grpc_completion_queue_pluck", 0); + GPR_TIMER_END("grpc_completion_queue_pluck", 0); return ret; } diff --git a/src/core/surface/init.c b/src/core/surface/init.c index 95011cab178..715c90a5e1d 100644 --- a/src/core/surface/init.c +++ b/src/core/surface/init.c @@ -115,7 +115,7 @@ void grpc_init(void) { gpr_log(GPR_ERROR, "Could not initialize census."); } } - grpc_timers_global_init(); + gpr_timers_global_init(); for (i = 0; i < g_number_of_plugins; i++) { if (g_all_of_the_plugins[i].init != NULL) { g_all_of_the_plugins[i].init(); @@ -133,7 +133,7 @@ void grpc_shutdown(void) { if (--g_initializations == 0) { grpc_iomgr_shutdown(); census_shutdown(); - grpc_timers_global_destroy(); + gpr_timers_global_destroy(); grpc_tracer_shutdown(); grpc_resolver_registry_shutdown(); for (i = 0; i < g_number_of_plugins; i++) { diff --git a/src/core/transport/chttp2/parsing.c b/src/core/transport/chttp2/parsing.c index e71d4fc87aa..04e48032273 100644 --- a/src/core/transport/chttp2/parsing.c +++ b/src/core/transport/chttp2/parsing.c @@ -69,7 +69,7 @@ void grpc_chttp2_prepare_to_read( grpc_chttp2_stream_global *stream_global; grpc_chttp2_stream_parsing *stream_parsing; - GRPC_TIMER_BEGIN("grpc_chttp2_prepare_to_read", 0); + GPR_TIMER_BEGIN("grpc_chttp2_prepare_to_read", 0); transport_parsing->next_stream_id = transport_global->next_stream_id; @@ -93,7 +93,7 @@ void grpc_chttp2_prepare_to_read( } } - GRPC_TIMER_END("grpc_chttp2_prepare_to_read", 0); + GPR_TIMER_END("grpc_chttp2_prepare_to_read", 0); } void grpc_chttp2_publish_reads( diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c index 4abe00bb7cf..69ad8854ba6 100644 --- a/src/core/transport/chttp2/writing.c +++ b/src/core/transport/chttp2/writing.c @@ -181,7 +181,7 @@ void grpc_chttp2_perform_writes( static void finalize_outbuf(grpc_chttp2_transport_writing *transport_writing) { grpc_chttp2_stream_writing *stream_writing; - GRPC_TIMER_BEGIN("finalize_outbuf", 0); + GPR_TIMER_BEGIN("finalize_outbuf", 0); while ( grpc_chttp2_list_pop_writing_stream(transport_writing, &stream_writing)) { @@ -212,7 +212,7 @@ static void finalize_outbuf(grpc_chttp2_transport_writing *transport_writing) { grpc_chttp2_list_add_written_stream(transport_writing, stream_writing); } - GRPC_TIMER_END("finalize_outbuf", 0); + GPR_TIMER_END("finalize_outbuf", 0); } void grpc_chttp2_cleanup_writing( diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index d39816b0117..effc3c4b3be 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -510,7 +510,7 @@ grpc_chttp2_stream_parsing *grpc_chttp2_parsing_accept_stream( static void lock(grpc_chttp2_transport *t) { gpr_mu_lock(&t->mu); } static void unlock(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { - GRPC_TIMER_BEGIN("unlock", 0); + GPR_TIMER_BEGIN("unlock", 0); unlock_check_read_write_state(exec_ctx, t); if (!t->writing_active && !t->closed && grpc_chttp2_unlocking_check_writes(&t->global, &t->writing)) { @@ -521,7 +521,7 @@ static void unlock(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { } gpr_mu_unlock(&t->mu); - GRPC_TIMER_END("unlock", 0); + GPR_TIMER_END("unlock", 0); } /* @@ -548,7 +548,7 @@ void grpc_chttp2_terminate_writing(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_writing *transport_writing = transport_writing_ptr; grpc_chttp2_transport *t = TRANSPORT_FROM_WRITING(transport_writing); - GRPC_TIMER_BEGIN("grpc_chttp2_terminate_writing", 0); + GPR_TIMER_BEGIN("grpc_chttp2_terminate_writing", 0); lock(t); @@ -572,15 +572,15 @@ void grpc_chttp2_terminate_writing(grpc_exec_ctx *exec_ctx, UNREF_TRANSPORT(exec_ctx, t, "writing"); - GRPC_TIMER_END("grpc_chttp2_terminate_writing", 0); + GPR_TIMER_END("grpc_chttp2_terminate_writing", 0); } static void writing_action(grpc_exec_ctx *exec_ctx, void *gt, int iomgr_success_ignored) { grpc_chttp2_transport *t = gt; - GRPC_TIMER_BEGIN("writing_action", 0); + GPR_TIMER_BEGIN("writing_action", 0); grpc_chttp2_perform_writes(exec_ctx, &t->writing, t->ep); - GRPC_TIMER_END("writing_action", 0); + GPR_TIMER_END("writing_action", 0); } void grpc_chttp2_add_incoming_goaway( @@ -650,7 +650,7 @@ static void maybe_start_some_streams( static void perform_stream_op_locked( grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global, grpc_transport_stream_op *op) { - GRPC_TIMER_BEGIN("perform_stream_op_locked", 0); + GPR_TIMER_BEGIN("perform_stream_op_locked", 0); if (op->cancel_with_status != GRPC_STATUS_OK) { cancel_from_api(transport_global, stream_global, op->cancel_with_status); } @@ -722,7 +722,7 @@ static void perform_stream_op_locked( } grpc_exec_ctx_enqueue(exec_ctx, op->on_consumed, 1); - GRPC_TIMER_END("perform_stream_op_locked", 0); + GPR_TIMER_END("perform_stream_op_locked", 0); } static void perform_stream_op(grpc_exec_ctx *exec_ctx, grpc_transport *gt, @@ -1113,7 +1113,7 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, int success) { int keep_reading = 0; grpc_chttp2_transport *t = tp; - GRPC_TIMER_BEGIN("recv_data", 0); + GPR_TIMER_BEGIN("recv_data", 0); lock(t); i = 0; @@ -1125,13 +1125,13 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, int success) { &t->parsing_stream_map); grpc_chttp2_prepare_to_read(&t->global, &t->parsing); gpr_mu_unlock(&t->mu); - GRPC_TIMER_BEGIN("recv_data.parse", 0); + GPR_TIMER_BEGIN("recv_data.parse", 0); for (; i < t->read_buffer.count && grpc_chttp2_perform_read(exec_ctx, &t->parsing, t->read_buffer.slices[i]); i++) ; - GRPC_TIMER_END("recv_data.parse", 0); + GPR_TIMER_END("recv_data.parse", 0); gpr_mu_lock(&t->mu); if (i != t->read_buffer.count) { drop_connection(exec_ctx, t); @@ -1169,7 +1169,7 @@ static void recv_data(grpc_exec_ctx *exec_ctx, void *tp, int success) { UNREF_TRANSPORT(exec_ctx, t, "recv_data"); } - GRPC_TIMER_END("recv_data", 0); + GPR_TIMER_END("recv_data", 0); } /* diff --git a/src/core/transport/stream_op.c b/src/core/transport/stream_op.c index 5c3c90b0541..6493e77bc51 100644 --- a/src/core/transport/stream_op.c +++ b/src/core/transport/stream_op.c @@ -302,7 +302,7 @@ void grpc_metadata_batch_filter(grpc_metadata_batch *batch, grpc_linked_mdelem *l; grpc_linked_mdelem *next; - GRPC_TIMER_BEGIN("grpc_metadata_batch_filter", 0); + GPR_TIMER_BEGIN("grpc_metadata_batch_filter", 0); assert_valid_list(&batch->list); assert_valid_list(&batch->garbage); @@ -333,5 +333,5 @@ void grpc_metadata_batch_filter(grpc_metadata_batch *batch, assert_valid_list(&batch->list); assert_valid_list(&batch->garbage); - GRPC_TIMER_END("grpc_metadata_batch_filter", 0); + GPR_TIMER_END("grpc_metadata_batch_filter", 0); } diff --git a/src/cpp/proto/proto_utils.cc b/src/cpp/proto/proto_utils.cc index a7b6fd241b5..b1330fde7f6 100644 --- a/src/cpp/proto/proto_utils.cc +++ b/src/cpp/proto/proto_utils.cc @@ -160,7 +160,7 @@ namespace grpc { Status SerializeProto(const grpc::protobuf::Message& msg, grpc_byte_buffer** bp) { - GRPC_TIMER_SCOPE("SerializeProto", 0); + GPR_TIMER_SCOPE("SerializeProto", 0); int byte_size = msg.ByteSize(); if (byte_size <= kMaxBufferLength) { gpr_slice slice = gpr_slice_malloc(byte_size); @@ -179,7 +179,7 @@ Status SerializeProto(const grpc::protobuf::Message& msg, Status DeserializeProto(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg, int max_message_size) { - GRPC_TIMER_SCOPE("DeserializeProto", 0); + GPR_TIMER_SCOPE("DeserializeProto", 0); if (!buffer) { return Status(StatusCode::INTERNAL, "No payload"); } diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 2cd1905a97d..aacc5c7387c 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -541,7 +541,7 @@ void Server::ScheduleCallback() { void Server::RunRpc() { // Wait for one more incoming rpc. bool ok; - GRPC_TIMER_SCOPE("Server::RunRpc", 0); + GPR_TIMER_SCOPE("Server::RunRpc", 0); auto* mrd = SyncRequest::Wait(&cq_, &ok); if (mrd) { ScheduleCallback(); @@ -557,7 +557,7 @@ void Server::RunRpc() { mrd->TeardownRequest(); } } - GRPC_TIMER_SCOPE("cd.Run()", 0); + GPR_TIMER_SCOPE("cd.Run()", 0); cd.Run(); } } diff --git a/test/core/profiling/timers_test.c b/test/core/profiling/timers_test.c index b79cde64bdb..7070fe465f1 100644 --- a/test/core/profiling/timers_test.c +++ b/test/core/profiling/timers_test.c @@ -54,15 +54,15 @@ void test_log_events(size_t num_seqs) { for (j = 0; j < advance; j++) { switch (state[i]) { case 0: - GRPC_TIMER_MARK(STATE_0, i); + GPR_TIMER_MARK(STATE_0, i); state[i]++; break; case 1: - GRPC_TIMER_MARK(STATE_1, i); + GPR_TIMER_MARK(STATE_1, i); state[i]++; break; case 2: - GRPC_TIMER_MARK(STATE_2, i); + GPR_TIMER_MARK(STATE_2, i); state[i]++; break; case 3: @@ -76,8 +76,8 @@ void test_log_events(size_t num_seqs) { int main(int argc, char **argv) { grpc_test_init(argc, argv); - grpc_timers_global_init(); + gpr_timers_global_init(); test_log_events(1000000); - grpc_timers_global_destroy(); + gpr_timers_global_destroy(); return 0; } diff --git a/test/cpp/qps/client_sync.cc b/test/cpp/qps/client_sync.cc index 6adf92a005c..3c33a1c5de4 100644 --- a/test/cpp/qps/client_sync.cc +++ b/test/cpp/qps/client_sync.cc @@ -101,7 +101,7 @@ class SynchronousUnaryClient GRPC_FINAL : public SynchronousClient { WaitToIssue(thread_idx); auto* stub = channels_[thread_idx % channels_.size()].get_stub(); double start = Timer::Now(); - GRPC_TIMER_SCOPE("SynchronousUnaryClient::ThreadFunc", 0); + GPR_TIMER_SCOPE("SynchronousUnaryClient::ThreadFunc", 0); grpc::ClientContext context; grpc::Status s = stub->UnaryCall(&context, request_, &responses_[thread_idx]); @@ -138,7 +138,7 @@ class SynchronousStreamingClient GRPC_FINAL : public SynchronousClient { bool ThreadFunc(Histogram* histogram, size_t thread_idx) GRPC_OVERRIDE { WaitToIssue(thread_idx); - GRPC_TIMER_SCOPE("SynchronousStreamingClient::ThreadFunc", 0); + GPR_TIMER_SCOPE("SynchronousStreamingClient::ThreadFunc", 0); double start = Timer::Now(); if (stream_[thread_idx]->Write(request_) && stream_[thread_idx]->Read(&responses_[thread_idx])) { diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 98d56f21eee..e742ec25713 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -852,7 +852,6 @@ src/core/json/json.h \ src/core/json/json_common.h \ src/core/json/json_reader.h \ src/core/json/json_writer.h \ -src/core/profiling/timers.h \ src/core/statistics/census_interface.h \ src/core/statistics/census_rpc_stats.h \ src/core/surface/api_trace.h \ @@ -990,8 +989,6 @@ src/core/json/json.c \ src/core/json/json_reader.c \ src/core/json/json_string.c \ src/core/json/json_writer.c \ -src/core/profiling/basic_timers.c \ -src/core/profiling/stap_timers.c \ src/core/surface/api_trace.c \ src/core/surface/byte_buffer.c \ src/core/surface/byte_buffer_queue.c \ @@ -1068,6 +1065,7 @@ include/grpc/support/tls_gcc.h \ include/grpc/support/tls_msvc.h \ include/grpc/support/tls_pthread.h \ include/grpc/support/useful.h \ +src/core/profiling/timers.h \ src/core/support/block_annotate.h \ src/core/support/env.h \ src/core/support/file.h \ @@ -1077,6 +1075,8 @@ src/core/support/string.h \ src/core/support/string_win32.h \ src/core/support/thd_internal.h \ src/core/support/time_precise.h \ +src/core/profiling/basic_timers.c \ +src/core/profiling/stap_timers.c \ src/core/support/alloc.c \ src/core/support/cmdline.c \ src/core/support/cpu_iphone.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index f2237e0fef7..c16477ccf84 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -12161,6 +12161,7 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/profiling/timers.h", "src/core/support/block_annotate.h", "src/core/support/env.h", "src/core/support/file.h", @@ -12201,6 +12202,9 @@ "include/grpc/support/tls_msvc.h", "include/grpc/support/tls_pthread.h", "include/grpc/support/useful.h", + "src/core/profiling/basic_timers.c", + "src/core/profiling/stap_timers.c", + "src/core/profiling/timers.h", "src/core/support/alloc.c", "src/core/support/block_annotate.h", "src/core/support/cmdline.c", @@ -12351,7 +12355,6 @@ "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", - "src/core/profiling/timers.h", "src/core/security/auth_filters.h", "src/core/security/base64.h", "src/core/security/credentials.h", @@ -12569,9 +12572,6 @@ "src/core/json/json_string.c", "src/core/json/json_writer.c", "src/core/json/json_writer.h", - "src/core/profiling/basic_timers.c", - "src/core/profiling/stap_timers.c", - "src/core/profiling/timers.h", "src/core/security/auth_filters.h", "src/core/security/base64.c", "src/core/security/base64.h", @@ -12856,7 +12856,6 @@ "src/core/json/json_common.h", "src/core/json/json_reader.h", "src/core/json/json_writer.h", - "src/core/profiling/timers.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.h", @@ -13059,9 +13058,6 @@ "src/core/json/json_string.c", "src/core/json/json_writer.c", "src/core/json/json_writer.h", - "src/core/profiling/basic_timers.c", - "src/core/profiling/stap_timers.c", - "src/core/profiling/timers.h", "src/core/statistics/census_interface.h", "src/core/statistics/census_rpc_stats.h", "src/core/surface/api_trace.c", diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 4c3b36abdc8..fa495db07b6 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -163,6 +163,7 @@ + @@ -174,6 +175,10 @@ + + + + diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 69391b4f991..ee03e454535 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -1,6 +1,12 @@ + + src\core\profiling + + + src\core\profiling + src\core\support @@ -200,6 +206,9 @@ + + src\core\profiling + src\core\support @@ -245,6 +254,9 @@ {c5e1baa7-de77-beb1-9675-942261648f79} + + {93b7086c-8c8a-6bbf-fb14-1f166bf0146a} + {bb116f2a-ea2a-c233-82da-0c54e3cbfec1} diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index 183edbc05bf..28e38f65be2 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -338,7 +338,6 @@ - @@ -575,10 +574,6 @@ - - - - diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index 66ce9ca05be..7ae7eca5226 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -292,12 +292,6 @@ src\core\json - - src\core\profiling - - - src\core\profiling - src\core\surface @@ -725,9 +719,6 @@ src\core\json - - src\core\profiling - src\core\statistics @@ -896,9 +887,6 @@ {e665cc0e-b994-d7c5-cc18-2007392019f0} - - {87674b72-0f05-0469-481a-bd8c7af9ad80} - {1d850ac6-e639-4eab-5338-4ba40272fcc9} diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index b527179f9f3..3fde42b90ad 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -317,7 +317,6 @@ - @@ -514,10 +513,6 @@ - - - - diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 7be3c9ec93b..6e9b1696691 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -232,12 +232,6 @@ src\core\json - - src\core\profiling - - - src\core\profiling - src\core\surface @@ -623,9 +617,6 @@ src\core\json - - src\core\profiling - src\core\statistics @@ -794,9 +785,6 @@ {443ffc61-1bea-2477-6e54-1ddf8c139264} - - {7f91d9bf-c9de-835a-d74d-b16f843b89a9} - {e084164c-a069-00e3-db35-4e0b1cd6f0b7}