grpc 1.49.1-x86_64-linux → 1.50.0.pre1-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +1 -1
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/lib/grpc/2.6/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/2.7/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.0/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/3.1/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/grpc_c.so +0 -0
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +33 -19
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -1,78 +0,0 @@
|
|
1
|
-
// Copyright 2021 The gRPC Authors
|
2
|
-
//
|
3
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
// you may not use this file except in compliance with the License.
|
5
|
-
// You may obtain a copy of the License at
|
6
|
-
//
|
7
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
//
|
9
|
-
// Unless required by applicable law or agreed to in writing, software
|
10
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
// See the License for the specific language governing permissions and
|
13
|
-
// limitations under the License.
|
14
|
-
#ifndef GRPC_CORE_LIB_EVENT_ENGINE_PROMISE_H
|
15
|
-
#define GRPC_CORE_LIB_EVENT_ENGINE_PROMISE_H
|
16
|
-
#include <grpc/support/port_platform.h>
|
17
|
-
|
18
|
-
#include "absl/time/time.h"
|
19
|
-
|
20
|
-
#include <grpc/support/log.h>
|
21
|
-
|
22
|
-
#include "src/core/lib/gprpp/sync.h"
|
23
|
-
|
24
|
-
namespace grpc_event_engine {
|
25
|
-
namespace experimental {
|
26
|
-
|
27
|
-
/// A minimal promise implementation.
|
28
|
-
///
|
29
|
-
/// This is light-duty, syntactical sugar around cv wait & signal, which is
|
30
|
-
/// useful in some cases. A more robust implementation is being worked on
|
31
|
-
/// separately.
|
32
|
-
template <typename T>
|
33
|
-
class Promise {
|
34
|
-
public:
|
35
|
-
Promise() = default;
|
36
|
-
// Initialize a default value that will be returned if WaitWithTimeout times
|
37
|
-
// out
|
38
|
-
explicit Promise(T&& val) : val_(val) {}
|
39
|
-
// The getter will wait until the setter has been called, and will return the
|
40
|
-
// value passed during Set.
|
41
|
-
T& Get() { return WaitWithTimeout(absl::Hours(1)); }
|
42
|
-
// The getter will wait with timeout until the setter has been called, and
|
43
|
-
// will return the value passed during Set.
|
44
|
-
T& WaitWithTimeout(absl::Duration d) {
|
45
|
-
grpc_core::MutexLock lock(&mu_);
|
46
|
-
if (!set_) {
|
47
|
-
cv_.WaitWithTimeout(&mu_, d);
|
48
|
-
}
|
49
|
-
return val_;
|
50
|
-
}
|
51
|
-
// This setter can only be called exactly once without a Reset.
|
52
|
-
// Will automatically unblock getters.
|
53
|
-
void Set(T&& val) {
|
54
|
-
grpc_core::MutexLock lock(&mu_);
|
55
|
-
GPR_ASSERT(!set_);
|
56
|
-
val_ = std::move(val);
|
57
|
-
set_ = true;
|
58
|
-
cv_.SignalAll();
|
59
|
-
}
|
60
|
-
|
61
|
-
// Can only be called after a set operation.
|
62
|
-
void Reset() {
|
63
|
-
grpc_core::MutexLock lock(&mu_);
|
64
|
-
GPR_ASSERT(set_);
|
65
|
-
set_ = false;
|
66
|
-
}
|
67
|
-
|
68
|
-
private:
|
69
|
-
grpc_core::Mutex mu_;
|
70
|
-
grpc_core::CondVar cv_;
|
71
|
-
T val_;
|
72
|
-
bool set_ = false;
|
73
|
-
};
|
74
|
-
|
75
|
-
} // namespace experimental
|
76
|
-
} // namespace grpc_event_engine
|
77
|
-
|
78
|
-
#endif // GRPC_CORE_LIB_EVENT_ENGINE_PROMISE_H
|
@@ -1,74 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 gRPC authors.
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#ifdef GPR_WINDOWS_ENV
|
22
|
-
|
23
|
-
#include <windows.h>
|
24
|
-
|
25
|
-
#include <grpc/support/alloc.h>
|
26
|
-
#include <grpc/support/log.h>
|
27
|
-
#include <grpc/support/string_util.h>
|
28
|
-
|
29
|
-
#include "src/core/lib/gpr/env.h"
|
30
|
-
#include "src/core/lib/gpr/string.h"
|
31
|
-
#include "src/core/lib/gpr/string_windows.h"
|
32
|
-
|
33
|
-
char* gpr_getenv(const char* name) {
|
34
|
-
char* result = NULL;
|
35
|
-
DWORD size;
|
36
|
-
LPTSTR tresult = NULL;
|
37
|
-
LPTSTR tname = gpr_char_to_tchar(name);
|
38
|
-
DWORD ret;
|
39
|
-
|
40
|
-
ret = GetEnvironmentVariable(tname, NULL, 0);
|
41
|
-
if (ret == 0) {
|
42
|
-
gpr_free(tname);
|
43
|
-
return NULL;
|
44
|
-
}
|
45
|
-
size = ret * (DWORD)sizeof(TCHAR);
|
46
|
-
tresult = (LPTSTR)gpr_malloc(size);
|
47
|
-
ret = GetEnvironmentVariable(tname, tresult, size);
|
48
|
-
gpr_free(tname);
|
49
|
-
if (ret == 0) {
|
50
|
-
gpr_free(tresult);
|
51
|
-
return NULL;
|
52
|
-
}
|
53
|
-
result = gpr_tchar_to_char(tresult);
|
54
|
-
gpr_free(tresult);
|
55
|
-
return result;
|
56
|
-
}
|
57
|
-
|
58
|
-
void gpr_setenv(const char* name, const char* value) {
|
59
|
-
LPTSTR tname = gpr_char_to_tchar(name);
|
60
|
-
LPTSTR tvalue = gpr_char_to_tchar(value);
|
61
|
-
BOOL res = SetEnvironmentVariable(tname, tvalue);
|
62
|
-
gpr_free(tname);
|
63
|
-
gpr_free(tvalue);
|
64
|
-
GPR_ASSERT(res);
|
65
|
-
}
|
66
|
-
|
67
|
-
void gpr_unsetenv(const char* name) {
|
68
|
-
LPTSTR tname = gpr_char_to_tchar(name);
|
69
|
-
BOOL res = SetEnvironmentVariable(tname, NULL);
|
70
|
-
gpr_free(tname);
|
71
|
-
GPR_ASSERT(res);
|
72
|
-
}
|
73
|
-
|
74
|
-
#endif /* GPR_WINDOWS_ENV */
|
@@ -1,32 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 gRPC authors.
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
|
-
#ifndef GRPC_CORE_LIB_GPR_STRING_WINDOWS_H
|
20
|
-
#define GRPC_CORE_LIB_GPR_STRING_WINDOWS_H
|
21
|
-
|
22
|
-
#include <grpc/support/port_platform.h>
|
23
|
-
|
24
|
-
#ifdef GPR_WINDOWS
|
25
|
-
|
26
|
-
/* These allocate new strings using gpr_malloc to convert from and to utf-8. */
|
27
|
-
LPTSTR gpr_char_to_tchar(LPCSTR input);
|
28
|
-
LPSTR gpr_tchar_to_char(LPCTSTR input);
|
29
|
-
|
30
|
-
#endif /* GPR_WINDOWS */
|
31
|
-
|
32
|
-
#endif /* GRPC_CORE_LIB_GPR_STRING_WINDOWS_H */
|
@@ -1,295 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 gRPC authors.
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#include "src/core/lib/profiling/timers.h"
|
22
|
-
|
23
|
-
#ifdef GRPC_BASIC_PROFILER
|
24
|
-
|
25
|
-
#include <inttypes.h>
|
26
|
-
#include <pthread.h>
|
27
|
-
#include <stdio.h>
|
28
|
-
#include <string.h>
|
29
|
-
|
30
|
-
#include <grpc/support/alloc.h>
|
31
|
-
#include <grpc/support/log.h>
|
32
|
-
#include <grpc/support/sync.h>
|
33
|
-
#include <grpc/support/time.h>
|
34
|
-
|
35
|
-
#include "src/core/lib/gpr/tls.h"
|
36
|
-
#include "src/core/lib/gprpp/global_config.h"
|
37
|
-
#include "src/core/lib/profiling/timers.h"
|
38
|
-
|
39
|
-
typedef enum { BEGIN = '{', END = '}', MARK = '.' } marker_type;
|
40
|
-
|
41
|
-
typedef struct gpr_timer_entry {
|
42
|
-
gpr_timespec tm;
|
43
|
-
const char* tagstr;
|
44
|
-
const char* file;
|
45
|
-
short line;
|
46
|
-
char type;
|
47
|
-
uint8_t important;
|
48
|
-
int thd;
|
49
|
-
} gpr_timer_entry;
|
50
|
-
|
51
|
-
#define MAX_COUNT 1000000
|
52
|
-
|
53
|
-
typedef struct gpr_timer_log {
|
54
|
-
size_t num_entries;
|
55
|
-
struct gpr_timer_log* next;
|
56
|
-
struct gpr_timer_log* prev;
|
57
|
-
gpr_timer_entry log[MAX_COUNT];
|
58
|
-
} gpr_timer_log;
|
59
|
-
|
60
|
-
typedef struct gpr_timer_log_list {
|
61
|
-
gpr_timer_log* head;
|
62
|
-
/* valid iff head!=NULL */
|
63
|
-
gpr_timer_log* tail;
|
64
|
-
} gpr_timer_log_list;
|
65
|
-
|
66
|
-
static GPR_THREAD_LOCAL(gpr_timer_log*) g_thread_log;
|
67
|
-
static gpr_once g_once_init = GPR_ONCE_INIT;
|
68
|
-
static FILE* output_file;
|
69
|
-
static const char* output_filename_or_null = NULL;
|
70
|
-
static pthread_mutex_t g_mu;
|
71
|
-
static pthread_cond_t g_cv;
|
72
|
-
static gpr_timer_log_list g_in_progress_logs;
|
73
|
-
static gpr_timer_log_list g_done_logs;
|
74
|
-
static int g_shutdown;
|
75
|
-
static pthread_t g_writing_thread;
|
76
|
-
static GPR_THREAD_LOCAL(int) g_thread_id;
|
77
|
-
static int g_next_thread_id;
|
78
|
-
static int g_writing_enabled = 1;
|
79
|
-
|
80
|
-
GPR_GLOBAL_CONFIG_DEFINE_STRING(grpc_latency_trace, "latency_trace.txt",
|
81
|
-
"Output file name for latency trace")
|
82
|
-
|
83
|
-
static const char* output_filename() {
|
84
|
-
if (output_filename_or_null == NULL) {
|
85
|
-
grpc_core::UniquePtr<char> value =
|
86
|
-
GPR_GLOBAL_CONFIG_GET(grpc_latency_trace);
|
87
|
-
if (strlen(value.get()) > 0) {
|
88
|
-
output_filename_or_null = value.release();
|
89
|
-
} else {
|
90
|
-
output_filename_or_null = "latency_trace.txt";
|
91
|
-
}
|
92
|
-
}
|
93
|
-
return output_filename_or_null;
|
94
|
-
}
|
95
|
-
|
96
|
-
static int timer_log_push_back(gpr_timer_log_list* list, gpr_timer_log* log) {
|
97
|
-
if (list->head == NULL) {
|
98
|
-
list->head = list->tail = log;
|
99
|
-
log->next = log->prev = NULL;
|
100
|
-
return 1;
|
101
|
-
} else {
|
102
|
-
log->prev = list->tail;
|
103
|
-
log->next = NULL;
|
104
|
-
list->tail->next = log;
|
105
|
-
list->tail = log;
|
106
|
-
return 0;
|
107
|
-
}
|
108
|
-
}
|
109
|
-
|
110
|
-
static gpr_timer_log* timer_log_pop_front(gpr_timer_log_list* list) {
|
111
|
-
gpr_timer_log* out = list->head;
|
112
|
-
if (out != NULL) {
|
113
|
-
list->head = out->next;
|
114
|
-
if (list->head != NULL) {
|
115
|
-
list->head->prev = NULL;
|
116
|
-
} else {
|
117
|
-
list->tail = NULL;
|
118
|
-
}
|
119
|
-
}
|
120
|
-
return out;
|
121
|
-
}
|
122
|
-
|
123
|
-
static void timer_log_remove(gpr_timer_log_list* list, gpr_timer_log* log) {
|
124
|
-
if (log->prev == NULL) {
|
125
|
-
list->head = log->next;
|
126
|
-
if (list->head != NULL) {
|
127
|
-
list->head->prev = NULL;
|
128
|
-
}
|
129
|
-
} else {
|
130
|
-
log->prev->next = log->next;
|
131
|
-
}
|
132
|
-
if (log->next == NULL) {
|
133
|
-
list->tail = log->prev;
|
134
|
-
if (list->tail != NULL) {
|
135
|
-
list->tail->next = NULL;
|
136
|
-
}
|
137
|
-
} else {
|
138
|
-
log->next->prev = log->prev;
|
139
|
-
}
|
140
|
-
}
|
141
|
-
|
142
|
-
static void write_log(gpr_timer_log* log) {
|
143
|
-
size_t i;
|
144
|
-
if (output_file == NULL) {
|
145
|
-
output_file = fopen(output_filename(), "w");
|
146
|
-
}
|
147
|
-
for (i = 0; i < log->num_entries; i++) {
|
148
|
-
gpr_timer_entry* entry = &(log->log[i]);
|
149
|
-
if (gpr_time_cmp(entry->tm, gpr_time_0(entry->tm.clock_type)) < 0) {
|
150
|
-
entry->tm = gpr_time_0(entry->tm.clock_type);
|
151
|
-
}
|
152
|
-
fprintf(output_file,
|
153
|
-
"{\"t\": %" PRId64
|
154
|
-
".%09d, \"thd\": \"%d\", \"type\": \"%c\", \"tag\": "
|
155
|
-
"\"%s\", \"file\": \"%s\", \"line\": %d, \"imp\": %d}\n",
|
156
|
-
entry->tm.tv_sec, entry->tm.tv_nsec, entry->thd, entry->type,
|
157
|
-
entry->tagstr, entry->file, entry->line, entry->important);
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
static void* writing_thread(void* unused) {
|
162
|
-
gpr_timer_log* log;
|
163
|
-
pthread_mutex_lock(&g_mu);
|
164
|
-
for (;;) {
|
165
|
-
while ((log = timer_log_pop_front(&g_done_logs)) == NULL && !g_shutdown) {
|
166
|
-
pthread_cond_wait(&g_cv, &g_mu);
|
167
|
-
}
|
168
|
-
if (log != NULL) {
|
169
|
-
pthread_mutex_unlock(&g_mu);
|
170
|
-
write_log(log);
|
171
|
-
free(log);
|
172
|
-
pthread_mutex_lock(&g_mu);
|
173
|
-
}
|
174
|
-
if (g_shutdown) {
|
175
|
-
pthread_mutex_unlock(&g_mu);
|
176
|
-
return NULL;
|
177
|
-
}
|
178
|
-
}
|
179
|
-
}
|
180
|
-
|
181
|
-
static void flush_logs(gpr_timer_log_list* list) {
|
182
|
-
gpr_timer_log* log;
|
183
|
-
while ((log = timer_log_pop_front(list)) != NULL) {
|
184
|
-
write_log(log);
|
185
|
-
free(log);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
|
189
|
-
static void finish_writing(void) {
|
190
|
-
pthread_mutex_lock(&g_mu);
|
191
|
-
g_shutdown = 1;
|
192
|
-
pthread_cond_signal(&g_cv);
|
193
|
-
pthread_mutex_unlock(&g_mu);
|
194
|
-
pthread_join(g_writing_thread, NULL);
|
195
|
-
|
196
|
-
gpr_log(GPR_INFO, "flushing logs");
|
197
|
-
|
198
|
-
pthread_mutex_lock(&g_mu);
|
199
|
-
flush_logs(&g_done_logs);
|
200
|
-
flush_logs(&g_in_progress_logs);
|
201
|
-
pthread_mutex_unlock(&g_mu);
|
202
|
-
|
203
|
-
if (output_file) {
|
204
|
-
fclose(output_file);
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
|
-
void gpr_timers_set_log_filename(const char* filename) {
|
209
|
-
output_filename_or_null = filename;
|
210
|
-
}
|
211
|
-
|
212
|
-
static void init_output() {
|
213
|
-
pthread_attr_t attr;
|
214
|
-
pthread_attr_init(&attr);
|
215
|
-
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
216
|
-
pthread_create(&g_writing_thread, &attr, &writing_thread, NULL);
|
217
|
-
pthread_attr_destroy(&attr);
|
218
|
-
|
219
|
-
atexit(finish_writing);
|
220
|
-
}
|
221
|
-
|
222
|
-
static void rotate_log() {
|
223
|
-
/* Using malloc here, as this code could end up being called by gpr_malloc */
|
224
|
-
gpr_timer_log* log = static_cast<gpr_timer_log*>(malloc(sizeof(*log)));
|
225
|
-
gpr_once_init(&g_once_init, init_output);
|
226
|
-
log->num_entries = 0;
|
227
|
-
pthread_mutex_lock(&g_mu);
|
228
|
-
if (g_thread_log != NULL) {
|
229
|
-
timer_log_remove(&g_in_progress_logs, g_thread_log);
|
230
|
-
if (timer_log_push_back(&g_done_logs, g_thread_log)) {
|
231
|
-
pthread_cond_signal(&g_cv);
|
232
|
-
}
|
233
|
-
} else {
|
234
|
-
g_thread_id = g_next_thread_id++;
|
235
|
-
}
|
236
|
-
timer_log_push_back(&g_in_progress_logs, log);
|
237
|
-
pthread_mutex_unlock(&g_mu);
|
238
|
-
g_thread_log = log;
|
239
|
-
}
|
240
|
-
|
241
|
-
static void gpr_timers_log_add(const char* tagstr, marker_type type,
|
242
|
-
int important, const char* file, int line) {
|
243
|
-
gpr_timer_entry* entry;
|
244
|
-
|
245
|
-
if (!g_writing_enabled) {
|
246
|
-
return;
|
247
|
-
}
|
248
|
-
|
249
|
-
if (g_thread_log == NULL || g_thread_log->num_entries == MAX_COUNT) {
|
250
|
-
rotate_log();
|
251
|
-
}
|
252
|
-
|
253
|
-
entry = &g_thread_log->log[g_thread_log->num_entries++];
|
254
|
-
|
255
|
-
entry->tm = gpr_now(GPR_CLOCK_PRECISE);
|
256
|
-
entry->tagstr = tagstr;
|
257
|
-
entry->type = type;
|
258
|
-
entry->file = file;
|
259
|
-
entry->line = (short)line;
|
260
|
-
entry->important = important != 0;
|
261
|
-
entry->thd = g_thread_id;
|
262
|
-
}
|
263
|
-
|
264
|
-
/* Latency profiler API implementation. */
|
265
|
-
void gpr_timer_add_mark(const char* tagstr, int important, const char* file,
|
266
|
-
int line) {
|
267
|
-
gpr_timers_log_add(tagstr, MARK, important, file, line);
|
268
|
-
}
|
269
|
-
|
270
|
-
void gpr_timer_begin(const char* tagstr, int important, const char* file,
|
271
|
-
int line) {
|
272
|
-
gpr_timers_log_add(tagstr, BEGIN, important, file, line);
|
273
|
-
}
|
274
|
-
|
275
|
-
void gpr_timer_end(const char* tagstr, int important, const char* file,
|
276
|
-
int line) {
|
277
|
-
gpr_timers_log_add(tagstr, END, important, file, line);
|
278
|
-
}
|
279
|
-
|
280
|
-
void gpr_timer_set_enabled(int enabled) { g_writing_enabled = enabled; }
|
281
|
-
|
282
|
-
/* Basic profiler specific API functions. */
|
283
|
-
void gpr_timers_global_init(void) {}
|
284
|
-
|
285
|
-
void gpr_timers_global_destroy(void) {}
|
286
|
-
|
287
|
-
#else /* !GRPC_BASIC_PROFILER */
|
288
|
-
void gpr_timers_global_init(void) {}
|
289
|
-
|
290
|
-
void gpr_timers_global_destroy(void) {}
|
291
|
-
|
292
|
-
void gpr_timers_set_log_filename(const char* /*filename*/) {}
|
293
|
-
|
294
|
-
void gpr_timer_set_enabled(int /*enabled*/) {}
|
295
|
-
#endif /* GRPC_BASIC_PROFILER */
|
@@ -1,50 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 gRPC authors.
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
|
-
#include <grpc/support/port_platform.h>
|
20
|
-
|
21
|
-
#ifdef GRPC_STAP_PROFILER
|
22
|
-
|
23
|
-
#include <sys/sdt.h>
|
24
|
-
|
25
|
-
#include "src/core/lib/profiling/timers.h"
|
26
|
-
/* Generated from src/core/profiling/stap_probes.d */
|
27
|
-
#include "src/core/lib/profiling/stap_probes.h"
|
28
|
-
|
29
|
-
/* Latency profiler API implementation. */
|
30
|
-
void gpr_timer_add_mark(int tag, const char* tagstr, void* id, const char* file,
|
31
|
-
int line) {
|
32
|
-
_STAP_ADD_MARK(tag);
|
33
|
-
}
|
34
|
-
|
35
|
-
void gpr_timer_add_important_mark(int tag, const char* tagstr, void* id,
|
36
|
-
const char* file, int line) {
|
37
|
-
_STAP_ADD_IMPORTANT_MARK(tag);
|
38
|
-
}
|
39
|
-
|
40
|
-
void gpr_timer_begin(int tag, const char* tagstr, void* id, const char* file,
|
41
|
-
int line) {
|
42
|
-
_STAP_TIMING_NS_BEGIN(tag);
|
43
|
-
}
|
44
|
-
|
45
|
-
void gpr_timer_end(int tag, const char* tagstr, void* id, const char* file,
|
46
|
-
int line) {
|
47
|
-
_STAP_TIMING_NS_END(tag);
|
48
|
-
}
|
49
|
-
|
50
|
-
#endif /* GRPC_STAP_PROFILER */
|
@@ -1,94 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
*
|
3
|
-
* Copyright 2015 gRPC authors.
|
4
|
-
*
|
5
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
* you may not use this file except in compliance with the License.
|
7
|
-
* You may obtain a copy of the License at
|
8
|
-
*
|
9
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
*
|
11
|
-
* Unless required by applicable law or agreed to in writing, software
|
12
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
* See the License for the specific language governing permissions and
|
15
|
-
* limitations under the License.
|
16
|
-
*
|
17
|
-
*/
|
18
|
-
|
19
|
-
#ifndef GRPC_CORE_LIB_PROFILING_TIMERS_H
|
20
|
-
#define GRPC_CORE_LIB_PROFILING_TIMERS_H
|
21
|
-
|
22
|
-
void gpr_timers_global_init(void);
|
23
|
-
void gpr_timers_global_destroy(void);
|
24
|
-
|
25
|
-
void gpr_timer_add_mark(const char* tagstr, int important, const char* file,
|
26
|
-
int line);
|
27
|
-
void gpr_timer_begin(const char* tagstr, int important, const char* file,
|
28
|
-
int line);
|
29
|
-
void gpr_timer_end(const char* tagstr, int important, const char* file,
|
30
|
-
int line);
|
31
|
-
|
32
|
-
void gpr_timers_set_log_filename(const char* filename);
|
33
|
-
|
34
|
-
void gpr_timer_set_enabled(int enabled);
|
35
|
-
|
36
|
-
#if !(defined(GRPC_STAP_PROFILER) + defined(GRPC_BASIC_PROFILER) + \
|
37
|
-
defined(GRPC_CUSTOM_PROFILER))
|
38
|
-
/* No profiling. No-op all the things. */
|
39
|
-
#define GPR_TIMER_MARK(tag, important) \
|
40
|
-
do { \
|
41
|
-
} while (0)
|
42
|
-
|
43
|
-
#define GPR_TIMER_SCOPE(tag, important) \
|
44
|
-
do { \
|
45
|
-
} while (0)
|
46
|
-
|
47
|
-
#else /* at least one profiler requested... */
|
48
|
-
/* ... hopefully only one. */
|
49
|
-
#if defined(GRPC_STAP_PROFILER) && defined(GRPC_BASIC_PROFILER)
|
50
|
-
#error "GRPC_STAP_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive."
|
51
|
-
#endif
|
52
|
-
#if defined(GRPC_STAP_PROFILER) && defined(GRPC_CUSTOM_PROFILER)
|
53
|
-
#error "GRPC_STAP_PROFILER and GRPC_CUSTOM_PROFILER are mutually exclusive."
|
54
|
-
#endif
|
55
|
-
#if defined(GRPC_CUSTOM_PROFILER) && defined(GRPC_BASIC_PROFILER)
|
56
|
-
#error "GRPC_CUSTOM_PROFILER and GRPC_BASIC_PROFILER are mutually exclusive."
|
57
|
-
#endif
|
58
|
-
|
59
|
-
/* Generic profiling interface. */
|
60
|
-
#define GPR_TIMER_MARK(tag, important) \
|
61
|
-
gpr_timer_add_mark(tag, important, __FILE__, __LINE__);
|
62
|
-
|
63
|
-
#ifdef GRPC_STAP_PROFILER
|
64
|
-
/* Empty placeholder for now. */
|
65
|
-
#endif /* GRPC_STAP_PROFILER */
|
66
|
-
|
67
|
-
#ifdef GRPC_BASIC_PROFILER
|
68
|
-
/* Empty placeholder for now. */
|
69
|
-
#endif /* GRPC_BASIC_PROFILER */
|
70
|
-
|
71
|
-
namespace grpc {
|
72
|
-
class ProfileScope {
|
73
|
-
public:
|
74
|
-
ProfileScope(const char* desc, bool important, const char* file, int line)
|
75
|
-
: desc_(desc) {
|
76
|
-
gpr_timer_begin(desc_, important ? 1 : 0, file, line);
|
77
|
-
}
|
78
|
-
~ProfileScope() { gpr_timer_end(desc_, 0, "n/a", 0); }
|
79
|
-
|
80
|
-
private:
|
81
|
-
const char* const desc_;
|
82
|
-
};
|
83
|
-
} // namespace grpc
|
84
|
-
|
85
|
-
#define GPR_TIMER_SCOPE_NAME_INTERNAL(prefix, line) prefix##line
|
86
|
-
#define GPR_TIMER_SCOPE_NAME(prefix, line) \
|
87
|
-
GPR_TIMER_SCOPE_NAME_INTERNAL(prefix, line)
|
88
|
-
#define GPR_TIMER_SCOPE(tag, important) \
|
89
|
-
::grpc::ProfileScope GPR_TIMER_SCOPE_NAME(_profile_scope_, __LINE__)( \
|
90
|
-
(tag), (important), __FILE__, __LINE__)
|
91
|
-
|
92
|
-
#endif /* at least one profiler requested. */
|
93
|
-
|
94
|
-
#endif /* GRPC_CORE_LIB_PROFILING_TIMERS_H */
|