grpc 1.49.1 → 1.50.0.pre1

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.

Files changed (270) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +54 -153
  3. data/include/grpc/event_engine/endpoint_config.h +11 -5
  4. data/include/grpc/event_engine/event_engine.h +1 -1
  5. data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
  6. data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
  7. data/include/grpc/impl/codegen/atm_windows.h +0 -2
  8. data/include/grpc/impl/codegen/grpc_types.h +6 -0
  9. data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
  10. data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
  11. data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
  12. data/src/core/ext/filters/client_channel/client_channel.h +1 -1
  13. data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
  14. data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
  15. data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
  16. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
  17. data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
  18. data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
  19. data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
  20. data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
  21. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
  22. data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
  23. data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
  24. data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
  25. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
  26. data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
  27. data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
  28. data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
  29. data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
  30. data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
  31. data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
  32. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
  33. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
  34. data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
  35. data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
  36. data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
  37. data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
  38. data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
  39. data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
  40. data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
  41. data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
  42. data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
  43. data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
  44. data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
  45. data/src/core/ext/filters/client_channel/subchannel.h +12 -3
  46. data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
  47. data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
  48. data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
  49. data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
  50. data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
  51. data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
  52. data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
  53. data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
  54. data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
  55. data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
  56. data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
  57. data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
  58. data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
  59. data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
  60. data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
  61. data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
  62. data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
  63. data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
  64. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
  65. data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
  66. data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
  67. data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
  68. data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
  69. data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
  70. data/src/core/ext/xds/certificate_provider_store.cc +63 -3
  71. data/src/core/ext/xds/certificate_provider_store.h +9 -1
  72. data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
  73. data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
  74. data/src/core/ext/xds/xds_api.cc +21 -17
  75. data/src/core/ext/xds/xds_api.h +7 -0
  76. data/src/core/ext/xds/xds_bootstrap.cc +5 -537
  77. data/src/core/ext/xds/xds_bootstrap.h +39 -111
  78. data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
  79. data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
  80. data/src/core/ext/xds/xds_client.cc +219 -145
  81. data/src/core/ext/xds/xds_client.h +19 -17
  82. data/src/core/ext/xds/xds_client_grpc.cc +18 -80
  83. data/src/core/ext/xds/xds_client_grpc.h +2 -25
  84. data/src/core/ext/xds/xds_client_stats.cc +4 -4
  85. data/src/core/ext/xds/xds_cluster.cc +87 -79
  86. data/src/core/ext/xds/xds_cluster.h +5 -5
  87. data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
  88. data/src/core/ext/xds/xds_common_types.cc +13 -5
  89. data/src/core/ext/xds/xds_endpoint.cc +8 -6
  90. data/src/core/ext/xds/xds_endpoint.h +3 -4
  91. data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
  92. data/src/core/ext/xds/xds_listener.cc +25 -20
  93. data/src/core/ext/xds/xds_listener.h +3 -4
  94. data/src/core/ext/xds/xds_resource_type.h +11 -8
  95. data/src/core/ext/xds/xds_route_config.cc +15 -16
  96. data/src/core/ext/xds/xds_route_config.h +3 -3
  97. data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
  98. data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
  99. data/src/core/lib/backoff/backoff.cc +2 -4
  100. data/src/core/lib/channel/call_finalization.h +1 -3
  101. data/src/core/lib/channel/channel_args.h +114 -14
  102. data/src/core/lib/channel/channel_trace.cc +3 -4
  103. data/src/core/lib/channel/promise_based_filter.cc +18 -19
  104. data/src/core/lib/channel/status_util.cc +27 -0
  105. data/src/core/lib/channel/status_util.h +10 -0
  106. data/src/core/lib/config/core_configuration.cc +5 -1
  107. data/src/core/lib/config/core_configuration.h +33 -0
  108. data/src/core/lib/debug/stats.cc +26 -30
  109. data/src/core/lib/debug/stats.h +2 -12
  110. data/src/core/lib/debug/stats_data.cc +118 -614
  111. data/src/core/lib/debug/stats_data.h +67 -465
  112. data/src/core/lib/debug/trace.cc +0 -2
  113. data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
  114. data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
  115. data/src/core/lib/event_engine/forkable.cc +1 -1
  116. data/src/core/lib/event_engine/poller.h +14 -12
  117. data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
  118. data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
  119. data/src/core/lib/event_engine/thread_pool.cc +131 -94
  120. data/src/core/lib/event_engine/thread_pool.h +56 -23
  121. data/src/core/lib/event_engine/time_util.cc +30 -0
  122. data/src/core/lib/event_engine/time_util.h +32 -0
  123. data/src/core/lib/event_engine/utils.cc +0 -5
  124. data/src/core/lib/event_engine/utils.h +0 -4
  125. data/src/core/lib/event_engine/windows/iocp.cc +13 -7
  126. data/src/core/lib/event_engine/windows/iocp.h +2 -1
  127. data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
  128. data/src/core/lib/experiments/config.cc +146 -0
  129. data/src/core/lib/experiments/config.h +43 -0
  130. data/src/core/lib/experiments/experiments.cc +75 -0
  131. data/src/core/lib/experiments/experiments.h +56 -0
  132. data/src/core/lib/gpr/alloc.cc +1 -9
  133. data/src/core/lib/gpr/log_windows.cc +0 -1
  134. data/src/core/lib/gpr/string_util_windows.cc +3 -30
  135. data/src/core/lib/gpr/sync_abseil.cc +0 -14
  136. data/src/core/lib/gpr/sync_posix.cc +0 -14
  137. data/src/core/lib/gpr/time_posix.cc +0 -6
  138. data/src/core/lib/gpr/time_precise.h +1 -1
  139. data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
  140. data/src/core/lib/gpr/useful.h +11 -0
  141. data/src/core/lib/{gpr → gprpp}/env.h +25 -12
  142. data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
  143. data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
  144. data/src/core/lib/gprpp/env_windows.cc +56 -0
  145. data/src/core/lib/gprpp/fork.cc +14 -22
  146. data/src/core/lib/gprpp/fork.h +0 -8
  147. data/src/core/lib/gprpp/global_config_env.cc +7 -6
  148. data/src/core/lib/gprpp/notification.h +67 -0
  149. data/src/core/lib/gprpp/packed_table.h +40 -0
  150. data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
  151. data/src/core/lib/gprpp/sorted_pack.h +98 -0
  152. data/src/core/lib/gprpp/status_helper.h +6 -0
  153. data/src/core/lib/gprpp/table.h +9 -1
  154. data/src/core/lib/gprpp/tchar.cc +49 -0
  155. data/src/core/lib/gprpp/tchar.h +33 -0
  156. data/src/core/lib/gprpp/time.cc +21 -0
  157. data/src/core/lib/gprpp/time.h +55 -0
  158. data/src/core/lib/gprpp/validation_errors.cc +61 -0
  159. data/src/core/lib/gprpp/validation_errors.h +110 -0
  160. data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
  161. data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
  162. data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
  163. data/src/core/lib/iomgr/call_combiner.cc +0 -8
  164. data/src/core/lib/iomgr/closure.h +0 -1
  165. data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
  166. data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
  167. data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
  168. data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
  169. data/src/core/lib/iomgr/exec_ctx.cc +0 -10
  170. data/src/core/lib/iomgr/exec_ctx.h +7 -31
  171. data/src/core/lib/iomgr/iocp_windows.cc +1 -2
  172. data/src/core/lib/iomgr/iomgr.cc +6 -8
  173. data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
  174. data/src/core/lib/iomgr/pollset.h +1 -1
  175. data/src/core/lib/iomgr/pollset_set.h +0 -1
  176. data/src/core/lib/iomgr/resolve_address.h +1 -0
  177. data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
  178. data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
  179. data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
  180. data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
  181. data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
  182. data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
  183. data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
  184. data/src/core/lib/iomgr/tcp_client.cc +6 -7
  185. data/src/core/lib/iomgr/tcp_client.h +11 -11
  186. data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
  187. data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
  188. data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
  189. data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
  190. data/src/core/lib/iomgr/tcp_posix.cc +131 -114
  191. data/src/core/lib/iomgr/tcp_posix.h +3 -1
  192. data/src/core/lib/iomgr/tcp_server.cc +5 -4
  193. data/src/core/lib/iomgr/tcp_server.h +9 -6
  194. data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
  195. data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
  196. data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
  197. data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
  198. data/src/core/lib/iomgr/tcp_windows.cc +0 -1
  199. data/src/core/lib/iomgr/tcp_windows.h +0 -1
  200. data/src/core/lib/iomgr/timer_generic.cc +4 -4
  201. data/src/core/lib/iomgr/timer_manager.cc +1 -2
  202. data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
  203. data/src/core/lib/json/json_object_loader.cc +21 -52
  204. data/src/core/lib/json/json_object_loader.h +56 -76
  205. data/src/core/lib/json/json_util.cc +2 -1
  206. data/src/core/lib/load_balancing/lb_policy.h +5 -5
  207. data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
  208. data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
  209. data/src/core/lib/promise/activity.h +2 -3
  210. data/src/core/lib/promise/context.h +1 -1
  211. data/src/core/lib/promise/sleep.cc +16 -4
  212. data/src/core/lib/promise/sleep.h +8 -2
  213. data/src/core/lib/resolver/resolver.h +13 -3
  214. data/src/core/lib/resource_quota/api.cc +9 -0
  215. data/src/core/lib/resource_quota/api.h +6 -0
  216. data/src/core/lib/resource_quota/arena.cc +1 -3
  217. data/src/core/lib/resource_quota/memory_quota.cc +8 -24
  218. data/src/core/lib/resource_quota/memory_quota.h +6 -19
  219. data/src/core/lib/resource_quota/periodic_update.cc +2 -3
  220. data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
  221. data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
  222. data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
  223. data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
  224. data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
  225. data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
  226. data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
  227. data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
  228. data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
  229. data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
  230. data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
  231. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
  232. data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
  233. data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
  234. data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
  235. data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
  236. data/src/core/lib/surface/call.cc +1 -11
  237. data/src/core/lib/surface/channel.cc +3 -2
  238. data/src/core/lib/surface/completion_queue.cc +16 -28
  239. data/src/core/lib/surface/completion_queue.h +1 -1
  240. data/src/core/lib/surface/completion_queue_factory.cc +5 -0
  241. data/src/core/lib/surface/init.cc +16 -11
  242. data/src/core/lib/surface/init_internally.cc +24 -0
  243. data/src/core/lib/surface/init_internally.h +28 -0
  244. data/src/core/lib/surface/server.cc +1 -7
  245. data/src/core/lib/surface/server.h +4 -6
  246. data/src/core/lib/surface/version.cc +2 -2
  247. data/src/core/lib/transport/bdp_estimator.cc +1 -3
  248. data/src/core/lib/transport/metadata_batch.cc +2 -3
  249. data/src/core/lib/transport/metadata_batch.h +9 -7
  250. data/src/core/lib/transport/parsed_metadata.h +4 -2
  251. data/src/core/lib/transport/status_conversion.cc +1 -3
  252. data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
  253. data/src/core/lib/transport/transport.h +0 -1
  254. data/src/core/lib/transport/transport_impl.h +0 -1
  255. data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
  256. data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
  257. data/src/ruby/lib/grpc/version.rb +1 -1
  258. data/src/ruby/spec/channel_spec.rb +5 -0
  259. data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
  260. data/src/ruby/spec/user_agent_spec.rb +1 -1
  261. metadata +33 -19
  262. data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
  263. data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
  264. data/src/core/ext/xds/certificate_provider_registry.h +0 -59
  265. data/src/core/lib/event_engine/promise.h +0 -78
  266. data/src/core/lib/gpr/env_windows.cc +0 -74
  267. data/src/core/lib/gpr/string_windows.h +0 -32
  268. data/src/core/lib/profiling/basic_timers.cc +0 -295
  269. data/src/core/lib/profiling/stap_timers.cc +0 -50
  270. data/src/core/lib/profiling/timers.h +0 -94
@@ -353,11 +353,11 @@ class LoadBalancingPolicy : public InternallyRefCounted<LoadBalancingPolicy> {
353
353
 
354
354
  /// Updates the policy with new data from the resolver. Will be invoked
355
355
  /// immediately after LB policy is constructed, and then again whenever
356
- /// the resolver returns a new result.
357
- // TODO(roth): Change this to return some indication as to whether the
358
- // update has been accepted, so that we can indicate to the resolver
359
- // whether it should go into backoff to retry the resolution.
360
- virtual void UpdateLocked(UpdateArgs) = 0; // NOLINT
356
+ /// the resolver returns a new result. The returned status indicates
357
+ /// whether the LB policy accepted the update; if non-OK, informs
358
+ /// polling-based resolvers that they should go into backoff delay and
359
+ /// eventually reattempt the resolution.
360
+ virtual absl::Status UpdateLocked(UpdateArgs) = 0; // NOLINT
361
361
 
362
362
  /// Tries to enter a READY connectivity state.
363
363
  /// This is a no-op by default, since most LB policies never go into
@@ -32,75 +32,53 @@
32
32
 
33
33
  #include <grpc/support/log.h>
34
34
 
35
- namespace grpc_core {
36
-
37
- namespace {
38
-
39
- class RegistryState {
40
- public:
41
- void RegisterLoadBalancingPolicyFactory(
42
- std::unique_ptr<LoadBalancingPolicyFactory> factory) {
43
- gpr_log(GPR_DEBUG, "registering LB policy factory for \"%s\"",
44
- std::string(factory->name()).c_str());
45
- GPR_ASSERT(factories_.find(factory->name()) == factories_.end());
46
- factories_.emplace(factory->name(), std::move(factory));
47
- }
48
-
49
- LoadBalancingPolicyFactory* GetLoadBalancingPolicyFactory(
50
- absl::string_view name) const {
51
- auto it = factories_.find(name);
52
- if (it == factories_.end()) return nullptr;
53
- return it->second.get();
54
- }
55
-
56
- private:
57
- std::map<absl::string_view, std::unique_ptr<LoadBalancingPolicyFactory>>
58
- factories_;
59
- };
60
-
61
- RegistryState* g_state = nullptr;
35
+ #include "src/core/lib/load_balancing/lb_policy.h"
62
36
 
63
- } // namespace
37
+ namespace grpc_core {
64
38
 
65
39
  //
66
40
  // LoadBalancingPolicyRegistry::Builder
67
41
  //
68
42
 
69
- void LoadBalancingPolicyRegistry::Builder::InitRegistry() {
70
- if (g_state == nullptr) g_state = new RegistryState();
71
- }
72
-
73
- void LoadBalancingPolicyRegistry::Builder::ShutdownRegistry() {
74
- delete g_state;
75
- g_state = nullptr;
76
- }
77
-
78
43
  void LoadBalancingPolicyRegistry::Builder::RegisterLoadBalancingPolicyFactory(
79
44
  std::unique_ptr<LoadBalancingPolicyFactory> factory) {
80
- InitRegistry();
81
- g_state->RegisterLoadBalancingPolicyFactory(std::move(factory));
45
+ gpr_log(GPR_DEBUG, "registering LB policy factory for \"%s\"",
46
+ std::string(factory->name()).c_str());
47
+ GPR_ASSERT(factories_.find(factory->name()) == factories_.end());
48
+ factories_.emplace(factory->name(), std::move(factory));
49
+ }
50
+
51
+ LoadBalancingPolicyRegistry LoadBalancingPolicyRegistry::Builder::Build() {
52
+ LoadBalancingPolicyRegistry out;
53
+ out.factories_ = std::move(factories_);
54
+ return out;
82
55
  }
83
56
 
84
57
  //
85
58
  // LoadBalancingPolicyRegistry
86
59
  //
87
60
 
61
+ LoadBalancingPolicyFactory*
62
+ LoadBalancingPolicyRegistry::GetLoadBalancingPolicyFactory(
63
+ absl::string_view name) const {
64
+ auto it = factories_.find(name);
65
+ if (it == factories_.end()) return nullptr;
66
+ return it->second.get();
67
+ }
68
+
88
69
  OrphanablePtr<LoadBalancingPolicy>
89
70
  LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
90
- absl::string_view name, LoadBalancingPolicy::Args args) {
91
- GPR_ASSERT(g_state != nullptr);
71
+ absl::string_view name, LoadBalancingPolicy::Args args) const {
92
72
  // Find factory.
93
- LoadBalancingPolicyFactory* factory =
94
- g_state->GetLoadBalancingPolicyFactory(name);
73
+ LoadBalancingPolicyFactory* factory = GetLoadBalancingPolicyFactory(name);
95
74
  if (factory == nullptr) return nullptr; // Specified name not found.
96
75
  // Create policy via factory.
97
76
  return factory->CreateLoadBalancingPolicy(std::move(args));
98
77
  }
99
78
 
100
79
  bool LoadBalancingPolicyRegistry::LoadBalancingPolicyExists(
101
- absl::string_view name, bool* requires_config) {
102
- GPR_ASSERT(g_state != nullptr);
103
- auto* factory = g_state->GetLoadBalancingPolicyFactory(name);
80
+ absl::string_view name, bool* requires_config) const {
81
+ auto* factory = GetLoadBalancingPolicyFactory(name);
104
82
  if (factory == nullptr) return false;
105
83
  // If requested, check if the load balancing policy allows an empty config.
106
84
  if (requires_config != nullptr) {
@@ -110,12 +88,11 @@ bool LoadBalancingPolicyRegistry::LoadBalancingPolicyExists(
110
88
  return true;
111
89
  }
112
90
 
113
- namespace {
114
-
115
91
  // Returns the JSON node of policy (with both policy name and config content)
116
92
  // given the JSON node of a LoadBalancingConfig array.
117
- absl::StatusOr<Json::Object::const_iterator> ParseLoadBalancingConfigHelper(
118
- const Json& lb_config_array) {
93
+ absl::StatusOr<Json::Object::const_iterator>
94
+ LoadBalancingPolicyRegistry::ParseLoadBalancingConfigHelper(
95
+ const Json& lb_config_array) const {
119
96
  if (lb_config_array.type() != Json::Type::ARRAY) {
120
97
  return absl::InvalidArgumentError("type should be array");
121
98
  }
@@ -146,16 +123,13 @@ absl::StatusOr<Json::Object::const_iterator> ParseLoadBalancingConfigHelper(
146
123
  "No known policies in list: ", absl::StrJoin(policies_tried, " ")));
147
124
  }
148
125
 
149
- } // namespace
150
-
151
126
  absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
152
- LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(const Json& json) {
153
- GPR_ASSERT(g_state != nullptr);
127
+ LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(const Json& json) const {
154
128
  auto policy = ParseLoadBalancingConfigHelper(json);
155
129
  if (!policy.ok()) return policy.status();
156
130
  // Find factory.
157
131
  LoadBalancingPolicyFactory* factory =
158
- g_state->GetLoadBalancingPolicyFactory((*policy)->first.c_str());
132
+ GetLoadBalancingPolicyFactory((*policy)->first.c_str());
159
133
  if (factory == nullptr) {
160
134
  return absl::FailedPreconditionError(absl::StrFormat(
161
135
  "Factory not found for policy \"%s\"", (*policy)->first));
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
22
+ #include <map>
22
23
  #include <memory>
23
24
 
24
25
  #include "absl/status/statusor.h"
@@ -39,30 +40,41 @@ class LoadBalancingPolicyRegistry {
39
40
  /// initialization and shutdown.
40
41
  class Builder {
41
42
  public:
42
- /// Global initialization and shutdown hooks.
43
- static void InitRegistry();
44
- static void ShutdownRegistry();
45
-
46
43
  /// Registers an LB policy factory. The factory will be used to create an
47
44
  /// LB policy whose name matches that of the factory.
48
- static void RegisterLoadBalancingPolicyFactory(
45
+ void RegisterLoadBalancingPolicyFactory(
49
46
  std::unique_ptr<LoadBalancingPolicyFactory> factory);
47
+
48
+ LoadBalancingPolicyRegistry Build();
49
+
50
+ private:
51
+ std::map<absl::string_view, std::unique_ptr<LoadBalancingPolicyFactory>>
52
+ factories_;
50
53
  };
51
54
 
52
55
  /// Creates an LB policy of the type specified by \a name.
53
- static OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
54
- absl::string_view name, LoadBalancingPolicy::Args args);
56
+ OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
57
+ absl::string_view name, LoadBalancingPolicy::Args args) const;
55
58
 
56
59
  /// Returns true if the LB policy factory specified by \a name exists in this
57
60
  /// registry. If the load balancing policy requires a config to be specified
58
61
  /// then sets \a requires_config to true.
59
- static bool LoadBalancingPolicyExists(absl::string_view name,
60
- bool* requires_config);
62
+ bool LoadBalancingPolicyExists(absl::string_view name,
63
+ bool* requires_config) const;
61
64
 
62
65
  /// Returns a parsed object of the load balancing policy to be used from a
63
66
  /// LoadBalancingConfig array \a json.
64
- static absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
65
- ParseLoadBalancingConfig(const Json& json);
67
+ absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
68
+ ParseLoadBalancingConfig(const Json& json) const;
69
+
70
+ private:
71
+ LoadBalancingPolicyFactory* GetLoadBalancingPolicyFactory(
72
+ absl::string_view name) const;
73
+ absl::StatusOr<Json::Object::const_iterator> ParseLoadBalancingConfigHelper(
74
+ const Json& lb_config_array) const;
75
+
76
+ std::map<absl::string_view, std::unique_ptr<LoadBalancingPolicyFactory>>
77
+ factories_;
66
78
  };
67
79
 
68
80
  } // namespace grpc_core
@@ -28,7 +28,6 @@
28
28
  #include "absl/status/status.h"
29
29
  #include "absl/types/optional.h"
30
30
  #include "absl/types/variant.h"
31
- #include "absl/utility/utility.h"
32
31
 
33
32
  #include <grpc/support/log.h>
34
33
 
@@ -100,7 +99,7 @@ class Waker {
100
99
  friend class AtomicWaker;
101
100
 
102
101
  Wakeable* Take() {
103
- return absl::exchange(wakeable_, activity_detail::unwakeable());
102
+ return std::exchange(wakeable_, activity_detail::unwakeable());
104
103
  }
105
104
 
106
105
  Wakeable* wakeable_;
@@ -315,7 +314,7 @@ class FreestandingActivity : public Activity, private Wakeable {
315
314
  // Check if we got an internal wakeup since the last time this function was
316
315
  // called.
317
316
  ActionDuringRun GotActionDuringRun() ABSL_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
318
- return absl::exchange(action_during_run_, ActionDuringRun::kNone);
317
+ return std::exchange(action_during_run_, ActionDuringRun::kNone);
319
318
  }
320
319
 
321
320
  // Implementors of Wakeable::Wakeup should call this after the wakeup has
@@ -77,7 +77,7 @@ T* GetContext() {
77
77
  // Given a promise and a context, return a promise that has that context set.
78
78
  template <typename T, typename F>
79
79
  promise_detail::WithContext<T, F> WithContext(F f, T* context) {
80
- return promise_detail::WithContext<T, F>(f, context);
80
+ return promise_detail::WithContext<T, F>(std::move(f), context);
81
81
  }
82
82
 
83
83
  } // namespace grpc_core
@@ -24,6 +24,7 @@
24
24
  #include "src/core/lib/gprpp/time.h"
25
25
  #include "src/core/lib/iomgr/exec_ctx.h"
26
26
  #include "src/core/lib/promise/activity.h"
27
+ #include "src/core/lib/promise/poll.h"
27
28
 
28
29
  namespace grpc_core {
29
30
 
@@ -40,25 +41,26 @@ Poll<absl::Status> Sleep::operator()() {
40
41
  // TODO(ctiller): the following can be safely removed when we remove ExecCtx.
41
42
  ExecCtx::Get()->InvalidateNow();
42
43
  // If the deadline is earlier than now we can just return.
43
- if (deadline_ <= ExecCtx::Get()->Now()) return absl::OkStatus();
44
+ if (deadline_ <= Timestamp::Now()) return absl::OkStatus();
44
45
  if (closure_ == nullptr) {
45
46
  // TODO(ctiller): it's likely we'll want a pool of closures - probably per
46
47
  // cpu? - to avoid allocating/deallocating on fast paths.
47
48
  closure_ = new ActiveClosure(deadline_);
48
49
  }
50
+ if (closure_->HasRun()) return absl::OkStatus();
49
51
  return Pending{};
50
52
  }
51
53
 
52
54
  Sleep::ActiveClosure::ActiveClosure(Timestamp deadline)
53
55
  : waker_(Activity::current()->MakeOwningWaker()),
54
56
  timer_handle_(GetDefaultEventEngine()->RunAfter(
55
- deadline - ExecCtx::Get()->Now(), this)) {}
57
+ deadline - Timestamp::Now(), this)) {}
56
58
 
57
59
  void Sleep::ActiveClosure::Run() {
58
60
  ApplicationCallbackExecCtx callback_exec_ctx;
59
61
  ExecCtx exec_ctx;
60
62
  auto waker = std::move(waker_);
61
- if (refs_.Unref()) {
63
+ if (Unref()) {
62
64
  delete this;
63
65
  } else {
64
66
  waker.Wakeup();
@@ -69,9 +71,19 @@ void Sleep::ActiveClosure::Cancel() {
69
71
  // If we cancel correctly then we must own both refs still and can simply
70
72
  // delete without unreffing twice, otherwise try unreffing since this may be
71
73
  // the last owned ref.
72
- if (GetDefaultEventEngine()->Cancel(timer_handle_) || refs_.Unref()) {
74
+ if (GetDefaultEventEngine()->Cancel(timer_handle_) || Unref()) {
73
75
  delete this;
74
76
  }
75
77
  }
76
78
 
79
+ bool Sleep::ActiveClosure::Unref() {
80
+ return (refs_.fetch_sub(1, std::memory_order_acq_rel) == 1);
81
+ }
82
+
83
+ bool Sleep::ActiveClosure::HasRun() const {
84
+ // If the closure has run (ie woken up the activity) then it will have
85
+ // decremented this ref count once.
86
+ return refs_.load(std::memory_order_acquire) == 1;
87
+ }
88
+
77
89
  } // namespace grpc_core
@@ -17,12 +17,13 @@
17
17
 
18
18
  #include <grpc/support/port_platform.h>
19
19
 
20
+ #include <atomic>
21
+
20
22
  #include "absl/status/status.h"
21
23
 
22
24
  #include <grpc/event_engine/event_engine.h>
23
25
  #include <grpc/support/log.h>
24
26
 
25
- #include "src/core/lib/gprpp/ref_counted.h"
26
27
  #include "src/core/lib/gprpp/time.h"
27
28
  #include "src/core/lib/promise/activity.h"
28
29
  #include "src/core/lib/promise/poll.h"
@@ -60,12 +61,17 @@ class Sleep final {
60
61
  explicit ActiveClosure(Timestamp deadline);
61
62
 
62
63
  void Run() override;
64
+ // After calling Cancel, it's no longer safe to access this object.
63
65
  void Cancel();
64
66
 
67
+ bool HasRun() const;
68
+
65
69
  private:
70
+ bool Unref();
71
+
66
72
  Waker waker_;
67
73
  // One ref dropped by Run(), the other by Cancel().
68
- RefCount refs_{2};
74
+ std::atomic<int> refs_{2};
69
75
  const grpc_event_engine::experimental::EventEngine::TaskHandle
70
76
  timer_handle_;
71
77
  };
@@ -19,8 +19,10 @@
19
19
 
20
20
  #include <grpc/support/port_platform.h>
21
21
 
22
+ #include <functional>
22
23
  #include <string>
23
24
 
25
+ #include "absl/status/status.h"
24
26
  #include "absl/status/statusor.h"
25
27
 
26
28
  #include "src/core/lib/channel/channel_args.h"
@@ -67,6 +69,17 @@ class Resolver : public InternallyRefCounted<Resolver> {
67
69
  // TODO(roth): Before making this a public API, figure out a way to
68
70
  // avoid exposing channel args this way.
69
71
  ChannelArgs args;
72
+ // If non-null, this callback will be invoked when the LB policy has
73
+ // processed the result. The status value passed to the callback
74
+ // indicates whether the LB policy accepted the update. For polling
75
+ // resolvers, if the reported status is non-OK, then the resolver
76
+ // should put itself into backoff to retry the resolution later.
77
+ // The resolver impl must not call ResultHandler::ReportResult()
78
+ // again until after this callback has been invoked.
79
+ // The callback will be invoked within the channel's WorkSerializer.
80
+ // It may or may not be invoked before ResultHandler::ReportResult()
81
+ // returns, which is why it's a separate callback.
82
+ std::function<void(absl::Status)> result_health_callback;
70
83
  };
71
84
 
72
85
  /// A proxy object used by the resolver to return results to the
@@ -76,9 +89,6 @@ class Resolver : public InternallyRefCounted<Resolver> {
76
89
  virtual ~ResultHandler() {}
77
90
 
78
91
  /// Reports a result to the channel.
79
- // TODO(roth): Add a mechanism for the resolver to get back a signal
80
- // indicating if the result was accepted by the LB policy, so that it
81
- // knows whether to go into backoff to retry to resolution.
82
92
  virtual void ReportResult(Result result) = 0; // NOLINT
83
93
  };
84
94
 
@@ -44,6 +44,15 @@ ResourceQuotaRefPtr ResourceQuotaFromChannelArgs(
44
44
  ->Ref();
45
45
  }
46
46
 
47
+ ResourceQuotaRefPtr ResourceQuotaFromEndpointConfig(
48
+ const grpc_event_engine::experimental::EndpointConfig& config) {
49
+ void* value = config.GetVoidPointer(GRPC_ARG_RESOURCE_QUOTA);
50
+ if (value != nullptr) {
51
+ return reinterpret_cast<ResourceQuota*>(value)->Ref();
52
+ }
53
+ return nullptr;
54
+ }
55
+
47
56
  ChannelArgs EnsureResourceQuotaInChannelArgs(const ChannelArgs& args) {
48
57
  if (args.GetObject<ResourceQuota>() != nullptr) return args;
49
58
  // If there's no existing quota, add it to the default one - shared between
@@ -19,6 +19,7 @@
19
19
 
20
20
  #include <stddef.h>
21
21
 
22
+ #include <grpc/event_engine/endpoint_config.h>
22
23
  #include <grpc/impl/codegen/grpc_types.h>
23
24
 
24
25
  #include "src/core/lib/config/core_configuration.h"
@@ -36,6 +37,11 @@ constexpr size_t kResourceQuotaChannelSize = 34 * 1024;
36
37
  // UB if not set.
37
38
  ResourceQuotaRefPtr ResourceQuotaFromChannelArgs(const grpc_channel_args* args);
38
39
 
40
+ // Retrieve the resource quota from the EndpointConfig.
41
+ // Returns nullptr if not set.
42
+ ResourceQuotaRefPtr ResourceQuotaFromEndpointConfig(
43
+ const grpc_event_engine::experimental::EndpointConfig& config);
44
+
39
45
  void RegisterResourceQuota(CoreConfiguration::Builder* builder);
40
46
 
41
47
  } // namespace grpc_core
@@ -23,8 +23,6 @@
23
23
  #include <atomic>
24
24
  #include <new>
25
25
 
26
- #include "absl/utility/utility.h"
27
-
28
26
  #include <grpc/support/alloc.h>
29
27
 
30
28
  #include "src/core/lib/gpr/alloc.h"
@@ -81,7 +79,7 @@ size_t Arena::Destroy() {
81
79
  nullptr) {
82
80
  // Inner loop: destruct a batch of objects.
83
81
  while (p != nullptr) {
84
- Destruct(absl::exchange(p, p->next));
82
+ Destruct(std::exchange(p, p->next));
85
83
  }
86
84
  }
87
85
  size_t size = total_used_.load(std::memory_order_relaxed);
@@ -24,11 +24,9 @@
24
24
 
25
25
  #include "absl/status/status.h"
26
26
  #include "absl/strings/str_cat.h"
27
- #include "absl/utility/utility.h"
28
27
 
29
28
  #include "src/core/lib/debug/trace.h"
30
29
  #include "src/core/lib/gpr/useful.h"
31
- #include "src/core/lib/gprpp/global_config_env.h"
32
30
  #include "src/core/lib/gprpp/mpscq.h"
33
31
  #include "src/core/lib/promise/exec_ctx_wakeup_scheduler.h"
34
32
  #include "src/core/lib/promise/loop.h"
@@ -37,18 +35,6 @@
37
35
  #include "src/core/lib/promise/seq.h"
38
36
  #include "src/core/lib/resource_quota/trace.h"
39
37
 
40
- GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_experimental_smooth_memory_presure, false,
41
- "smooth the value of memory pressure over time");
42
- GPR_GLOBAL_CONFIG_DEFINE_BOOL(
43
- grpc_experimental_enable_periodic_resource_quota_reclamation, false,
44
- "Enable experimental feature to reclaim resource quota periodically");
45
- GPR_GLOBAL_CONFIG_DEFINE_INT32(
46
- grpc_experimental_max_quota_buffer_size, 1024 * 1024,
47
- "Maximum size for one memory allocators buffer size against a quota");
48
- GPR_GLOBAL_CONFIG_DEFINE_INT32(
49
- grpc_experimental_resource_quota_set_point, 95,
50
- "Ask the resource quota to target this percentage of total quota usage.");
51
-
52
38
  namespace grpc_core {
53
39
 
54
40
  // Maximum number of bytes an allocator will request from a quota in one step.
@@ -191,7 +177,7 @@ void GrpcMemoryAllocatorImpl::Shutdown() {
191
177
  shutdown_ = true;
192
178
  memory_quota = memory_quota_;
193
179
  for (size_t i = 0; i < kNumReclamationPasses; i++) {
194
- reclamation_handles[i] = absl::exchange(reclamation_handles_[i], nullptr);
180
+ reclamation_handles[i] = std::exchange(reclamation_handles_[i], nullptr);
195
181
  }
196
182
  }
197
183
  }
@@ -262,10 +248,11 @@ void GrpcMemoryAllocatorImpl::MaybeDonateBack() {
262
248
  size_t free = free_bytes_.load(std::memory_order_relaxed);
263
249
  while (free > 0) {
264
250
  size_t ret = 0;
265
- if (max_quota_buffer_size() > 0 && free > max_quota_buffer_size() / 2) {
266
- ret = std::max(ret, free - max_quota_buffer_size() / 2);
251
+ if (!IsUnconstrainedMaxQuotaBufferSizeEnabled() &&
252
+ free > kMaxQuotaBufferSize / 2) {
253
+ ret = std::max(ret, free - kMaxQuotaBufferSize / 2);
267
254
  }
268
- if (periodic_donate_back()) {
255
+ if (IsPeriodicResourceQuotaReclamationEnabled()) {
269
256
  ret = std::max(ret, free > 8192 ? free / 2 : free);
270
257
  }
271
258
  const size_t new_free = free - ret;
@@ -463,8 +450,6 @@ void BasicMemoryQuota::Return(size_t amount) {
463
450
  }
464
451
 
465
452
  BasicMemoryQuota::PressureInfo BasicMemoryQuota::GetPressureInfo() {
466
- static const bool kSmoothMemoryPressure =
467
- GPR_GLOBAL_CONFIG_GET(grpc_experimental_smooth_memory_presure);
468
453
  double free = free_bytes_.load();
469
454
  if (free < 0) free = 0;
470
455
  size_t quota_size = quota_size_.load();
@@ -472,7 +457,7 @@ BasicMemoryQuota::PressureInfo BasicMemoryQuota::GetPressureInfo() {
472
457
  if (size < 1) return PressureInfo{1, 1, 1};
473
458
  PressureInfo pressure_info;
474
459
  pressure_info.instantaneous_pressure = std::max(0.0, (size - free) / size);
475
- if (kSmoothMemoryPressure) {
460
+ if (IsMemoryPressureControllerEnabled()) {
476
461
  pressure_info.pressure_control_value =
477
462
  pressure_tracker_.AddSampleAndGetControlValue(
478
463
  pressure_info.instantaneous_pressure);
@@ -492,7 +477,7 @@ namespace memory_quota_detail {
492
477
 
493
478
  double PressureController::Update(double error) {
494
479
  bool is_low = error < 0;
495
- bool was_low = absl::exchange(last_was_low_, is_low);
480
+ bool was_low = std::exchange(last_was_low_, is_low);
496
481
  double new_control; // leave unset to compiler can note bad branches
497
482
  if (is_low && was_low) {
498
483
  // Memory pressure is too low this round, and was last round too.
@@ -563,8 +548,7 @@ std::string PressureController::DebugString() const {
563
548
  }
564
549
 
565
550
  double PressureTracker::AddSampleAndGetControlValue(double sample) {
566
- static const double kSetPoint =
567
- GPR_GLOBAL_CONFIG_GET(grpc_experimental_resource_quota_set_point) / 100.0;
551
+ static const double kSetPoint = 95.0;
568
552
 
569
553
  double max_so_far = max_this_round_.load(std::memory_order_relaxed);
570
554
  if (sample > max_so_far) {
@@ -34,7 +34,7 @@
34
34
  #include <grpc/event_engine/memory_request.h>
35
35
  #include <grpc/support/log.h>
36
36
 
37
- #include "src/core/lib/gprpp/global_config_generic.h"
37
+ #include "src/core/lib/experiments/experiments.h"
38
38
  #include "src/core/lib/gprpp/orphanable.h"
39
39
  #include "src/core/lib/gprpp/ref_counted_ptr.h"
40
40
  #include "src/core/lib/gprpp/sync.h"
@@ -43,11 +43,6 @@
43
43
  #include "src/core/lib/promise/poll.h"
44
44
  #include "src/core/lib/resource_quota/periodic_update.h"
45
45
 
46
- GPR_GLOBAL_CONFIG_DECLARE_BOOL(grpc_experimental_smooth_memory_presure);
47
- GPR_GLOBAL_CONFIG_DECLARE_BOOL(
48
- grpc_experimental_enable_periodic_resource_quota_reclamation);
49
- GPR_GLOBAL_CONFIG_DECLARE_INT32(grpc_experimental_max_quota_buffer_size);
50
-
51
46
  namespace grpc_core {
52
47
 
53
48
  class BasicMemoryQuota;
@@ -370,9 +365,10 @@ class GrpcMemoryAllocatorImpl final : public EventEngineMemoryAllocatorImpl {
370
365
  // from 0 to non-zero, then we have more to do, otherwise, we're actually
371
366
  // done.
372
367
  size_t prev_free = free_bytes_.fetch_add(n, std::memory_order_release);
373
- if ((max_quota_buffer_size() > 0 &&
374
- prev_free + n > max_quota_buffer_size()) ||
375
- (periodic_donate_back() && donate_back_.Tick([](Duration) {}))) {
368
+ if ((!IsUnconstrainedMaxQuotaBufferSizeEnabled() &&
369
+ prev_free + n > kMaxQuotaBufferSize) ||
370
+ (IsPeriodicResourceQuotaReclamationEnabled() &&
371
+ donate_back_.Tick([](Duration) {}))) {
376
372
  // Try to immediately return some free'ed memory back to the total quota.
377
373
  MaybeDonateBack();
378
374
  }
@@ -400,16 +396,7 @@ class GrpcMemoryAllocatorImpl final : public EventEngineMemoryAllocatorImpl {
400
396
  absl::string_view name() const { return name_; }
401
397
 
402
398
  private:
403
- static bool periodic_donate_back() {
404
- static const bool value = GPR_GLOBAL_CONFIG_GET(
405
- grpc_experimental_enable_periodic_resource_quota_reclamation);
406
- return value;
407
- }
408
- static size_t max_quota_buffer_size() {
409
- static const size_t value =
410
- GPR_GLOBAL_CONFIG_GET(grpc_experimental_max_quota_buffer_size);
411
- return value;
412
- }
399
+ static constexpr size_t kMaxQuotaBufferSize = 1024 * 1024;
413
400
  // Primitive reservation function.
414
401
  absl::optional<size_t> TryReserve(MemoryRequest request) GRPC_MUST_USE_RESULT;
415
402
  // This function may be invoked during a memory release operation.
@@ -19,13 +19,12 @@
19
19
  #include <atomic>
20
20
 
21
21
  #include "src/core/lib/gpr/useful.h"
22
- #include "src/core/lib/iomgr/exec_ctx.h"
23
22
 
24
23
  namespace grpc_core {
25
24
 
26
25
  bool PeriodicUpdate::MaybeEndPeriod(absl::FunctionRef<void(Duration)> f) {
27
26
  if (period_start_ == Timestamp::ProcessEpoch()) {
28
- period_start_ = ExecCtx::Get()->Now();
27
+ period_start_ = Timestamp::Now();
29
28
  updates_remaining_.store(1, std::memory_order_release);
30
29
  return false;
31
30
  }
@@ -34,7 +33,7 @@ bool PeriodicUpdate::MaybeEndPeriod(absl::FunctionRef<void(Duration)> f) {
34
33
  // We can now safely mutate any non-atomic mutable variables (we've got a
35
34
  // guarantee that no other thread will), and by the time this function returns
36
35
  // we must store a postive number into updates_remaining_.
37
- auto now = ExecCtx::Get()->Now();
36
+ auto now = Timestamp::Now();
38
37
  Duration time_so_far = now - period_start_;
39
38
  if (time_so_far < period_) {
40
39
  // At most double the number of updates remaining until the next period.
@@ -16,8 +16,8 @@
16
16
  //
17
17
  //
18
18
 
19
- #ifndef GRPC_CORE_EXT_XDS_CERTIFICATE_PROVIDER_FACTORY_H
20
- #define GRPC_CORE_EXT_XDS_CERTIFICATE_PROVIDER_FACTORY_H
19
+ #ifndef GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H
20
+ #define GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H
21
21
 
22
22
  #include <grpc/support/port_platform.h>
23
23
 
@@ -63,4 +63,4 @@ class CertificateProviderFactory {
63
63
 
64
64
  } // namespace grpc_core
65
65
 
66
- #endif // GRPC_CORE_EXT_XDS_CERTIFICATE_PROVIDER_FACTORY_H
66
+ #endif // GRPC_CORE_LIB_SECURITY_CERTIFICATE_PROVIDER_CERTIFICATE_PROVIDER_FACTORY_H