From 91edf92ce013d6c1ec5cff6b214cfecc3b004f6d Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 6 Dec 2021 12:59:28 -0800 Subject: [PATCH] Revert "Move arena into resource quota (#28008)" (#28292) This reverts commit ad424a2ebfbb63229851a098c56bb92a31b91e2b. --- BUILD | 21 +- CMakeLists.txt | 166 ++++++--- Makefile | 3 +- build_autogenerated.yaml | 314 +++++++++++------- config.m4 | 2 +- config.w32 | 2 +- gRPC-C++.podspec | 4 +- gRPC-Core.podspec | 6 +- grpc.gemspec | 4 +- grpc.gyp | 3 +- package.xml | 4 +- .../filters/client_channel/backend_metric.h | 2 +- .../filters/client_channel/config_selector.h | 2 +- .../filters/client_channel/dynamic_filters.h | 2 +- .../health/health_check_client.cc | 8 +- .../health/health_check_client.h | 5 +- .../ext/filters/client_channel/subchannel.h | 2 +- .../binder/client/channel_create_impl.cc | 5 - .../chttp2/transport/chttp2_transport.cc | 4 + .../ext/transport/chttp2/transport/internal.h | 2 + src/core/lib/channel/channel_stack.h | 2 +- src/core/lib/channel/channel_stack_builder.cc | 4 +- src/core/lib/channel/channel_stack_builder.h | 2 +- .../lib/{resource_quota => gprpp}/arena.cc | 29 +- .../lib/{resource_quota => gprpp}/arena.h | 32 +- src/core/lib/gprpp/chunked_vector.h | 2 +- src/core/lib/promise/arena_promise.h | 2 +- src/core/lib/resource_quota/api.h | 1 + .../lib/security/context/security_context.cc | 2 +- .../lib/security/context/security_context.h | 2 +- src/core/lib/surface/call.cc | 5 +- src/core/lib/surface/call.h | 2 +- src/core/lib/surface/channel.cc | 20 +- src/core/lib/surface/channel.h | 3 +- src/core/lib/transport/transport.h | 2 +- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/end2end/fixtures/h2_sockpair.cc | 6 +- .../end2end/fixtures/h2_sockpair_1byte.cc | 6 +- test/core/end2end/fuzzers/api_fuzzer.cc | 3 +- test/core/end2end/fuzzers/client_fuzzer.cc | 9 +- test/core/end2end/fuzzers/server_fuzzer.cc | 4 +- test/core/gpr/arena_test.cc | 13 +- test/core/gprpp/BUILD | 2 - test/core/gprpp/chunked_vector_fuzzer.cc | 7 +- test/core/gprpp/chunked_vector_test.cc | 15 +- test/core/promise/BUILD | 1 - test/core/promise/arena_promise_test.cc | 9 +- .../transport/binder/binder_transport_test.cc | 20 +- .../binder/end2end/testing_channel_create.cc | 10 +- .../binder/end2end/testing_channel_create.h | 5 +- .../transport/chttp2/hpack_encoder_test.cc | 11 +- .../chttp2/hpack_parser_fuzzer_test.cc | 6 +- .../transport/chttp2/hpack_parser_test.cc | 7 +- test/core/transport/metadata_map_test.cc | 14 +- test/core/transport/metadata_test.cc | 13 +- test/core/util/evaluate_args_test_util.h | 5 +- test/cpp/microbenchmarks/bm_arena.cc | 15 +- test/cpp/microbenchmarks/bm_call_create.cc | 31 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 13 +- .../microbenchmarks/bm_chttp2_transport.cc | 14 +- tools/doxygen/Doxyfile.c++.internal | 4 +- tools/doxygen/Doxyfile.core.internal | 4 +- 62 files changed, 472 insertions(+), 448 deletions(-) rename src/core/lib/{resource_quota => gprpp}/arena.cc (74%) rename src/core/lib/{resource_quota => gprpp}/arena.h (80%) diff --git a/BUILD b/BUILD index b56b31470f9..53dbfd4c97c 100644 --- a/BUILD +++ b/BUILD @@ -609,7 +609,6 @@ grpc_cc_library( "include/grpcpp/security/binder_credentials.h", ], deps = [ - "config", "gpr", "gpr_base", "gpr_platform", @@ -806,6 +805,7 @@ grpc_cc_library( "src/core/lib/gpr/tmpfile_posix.cc", "src/core/lib/gpr/tmpfile_windows.cc", "src/core/lib/gpr/wrap_memcpy.cc", + "src/core/lib/gprpp/arena.cc", "src/core/lib/gprpp/examine_stack.cc", "src/core/lib/gprpp/fork.cc", "src/core/lib/gprpp/global_config_env.cc", @@ -829,6 +829,7 @@ grpc_cc_library( "src/core/lib/gpr/string_windows.h", "src/core/lib/gpr/time_precise.h", "src/core/lib/gpr/tmpfile.h", + "src/core/lib/gprpp/arena.h", "src/core/lib/gprpp/examine_stack.h", "src/core/lib/gprpp/fork.h", "src/core/lib/gprpp/global_config.h", @@ -886,7 +887,6 @@ grpc_cc_library( hdrs = ["src/core/lib/gprpp/chunked_vector.h"], external_deps = ["absl/utility"], deps = [ - "arena", # TODO(ctiller): weaken this to just arena when that splits into its own target "gpr_base", ], @@ -1099,7 +1099,6 @@ grpc_cc_library( "src/core/lib/promise/arena_promise.h", ], deps = [ - "arena", "gpr_base", "poll", ], @@ -1500,20 +1499,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "arena", - srcs = [ - "src/core/lib/resource_quota/arena.cc", - ], - hdrs = [ - "src/core/lib/resource_quota/arena.h", - ], - deps = [ - "gpr_base", - "memory_quota", - ], -) - grpc_cc_library( name = "thread_quota", srcs = [ @@ -2056,7 +2041,6 @@ grpc_cc_library( public_hdrs = GRPC_PUBLIC_HDRS + GRPC_PUBLIC_EVENT_ENGINE_HDRS, visibility = ["@grpc:alt_grpc_base_legacy"], deps = [ - "arena", "avl", "bitset", "channel_args", @@ -3407,7 +3391,6 @@ grpc_cc_library( visibility = ["@grpc:public"], deps = [ "alts_util", - "arena", "config", "error", "gpr_base", diff --git a/CMakeLists.txt b/CMakeLists.txt index 26ed8d317fc..05ad8b18235 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1399,6 +1399,7 @@ add_library(gpr src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc @@ -1995,7 +1996,6 @@ add_library(grpc src/core/lib/matchers/matchers.cc src/core/lib/promise/activity.cc src/core/lib/resource_quota/api.cc - src/core/lib/resource_quota/arena.cc src/core/lib/resource_quota/memory_quota.cc src/core/lib/resource_quota/resource_quota.cc src/core/lib/resource_quota/thread_quota.cc @@ -2642,7 +2642,6 @@ add_library(grpc_unsecure src/core/lib/json/json_writer.cc src/core/lib/promise/activity.cc src/core/lib/resource_quota/api.cc - src/core/lib/resource_quota/arena.cc src/core/lib/resource_quota/memory_quota.cc src/core/lib/resource_quota/resource_quota.cc src/core/lib/resource_quota/thread_quota.cc @@ -7581,6 +7580,7 @@ add_executable(activity_test src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc @@ -7901,23 +7901,53 @@ endif() if(gRPC_BUILD_TESTS) add_executable(arena_promise_test - src/core/lib/debug/trace.cc - src/core/lib/event_engine/memory_allocator.cc - src/core/lib/iomgr/combiner.cc - src/core/lib/iomgr/error.cc - src/core/lib/iomgr/exec_ctx.cc - src/core/lib/iomgr/executor.cc - src/core/lib/iomgr/iomgr_internal.cc - src/core/lib/promise/activity.cc - src/core/lib/resource_quota/arena.cc - src/core/lib/resource_quota/memory_quota.cc - src/core/lib/resource_quota/resource_quota.cc - src/core/lib/resource_quota/thread_quota.cc - src/core/lib/resource_quota/trace.cc - src/core/lib/slice/slice.cc - src/core/lib/slice/slice_refcount.cc - src/core/lib/slice/slice_string_helpers.cc - src/core/lib/slice/static_slice.cc + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c + src/core/lib/gpr/alloc.cc + src/core/lib/gpr/atm.cc + src/core/lib/gpr/cpu_iphone.cc + src/core/lib/gpr/cpu_linux.cc + src/core/lib/gpr/cpu_posix.cc + src/core/lib/gpr/cpu_windows.cc + src/core/lib/gpr/env_linux.cc + src/core/lib/gpr/env_posix.cc + src/core/lib/gpr/env_windows.cc + src/core/lib/gpr/log.cc + src/core/lib/gpr/log_android.cc + src/core/lib/gpr/log_linux.cc + src/core/lib/gpr/log_posix.cc + src/core/lib/gpr/log_windows.cc + src/core/lib/gpr/murmur_hash.cc + src/core/lib/gpr/string.cc + src/core/lib/gpr/string_posix.cc + src/core/lib/gpr/string_util_windows.cc + src/core/lib/gpr/string_windows.cc + src/core/lib/gpr/sync.cc + src/core/lib/gpr/sync_abseil.cc + src/core/lib/gpr/sync_posix.cc + src/core/lib/gpr/sync_windows.cc + src/core/lib/gpr/time.cc + src/core/lib/gpr/time_posix.cc + src/core/lib/gpr/time_precise.cc + src/core/lib/gpr/time_windows.cc + src/core/lib/gpr/tmpfile_msys.cc + src/core/lib/gpr/tmpfile_posix.cc + src/core/lib/gpr/tmpfile_windows.cc + src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc + src/core/lib/gprpp/examine_stack.cc + src/core/lib/gprpp/fork.cc + src/core/lib/gprpp/global_config_env.cc + src/core/lib/gprpp/host_port.cc + src/core/lib/gprpp/mpscq.cc + src/core/lib/gprpp/stat_posix.cc + src/core/lib/gprpp/stat_windows.cc + src/core/lib/gprpp/status_helper.cc + src/core/lib/gprpp/thd_posix.cc + src/core/lib/gprpp/thd_windows.cc + src/core/lib/gprpp/time_util.cc + src/core/lib/profiling/basic_timers.cc + src/core/lib/profiling/stap_timers.cc test/core/promise/arena_promise_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -7945,9 +7975,19 @@ target_include_directories(arena_promise_test target_link_libraries(arena_promise_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::statusor + absl::base + absl::core_headers + absl::memory + absl::random_random + absl::status + absl::cord + absl::str_format + absl::strings + absl::synchronization + absl::time + absl::optional absl::variant - gpr + upb ) @@ -9124,23 +9164,53 @@ endif() if(gRPC_BUILD_TESTS) add_executable(chunked_vector_test - src/core/lib/debug/trace.cc - src/core/lib/event_engine/memory_allocator.cc - src/core/lib/iomgr/combiner.cc - src/core/lib/iomgr/error.cc - src/core/lib/iomgr/exec_ctx.cc - src/core/lib/iomgr/executor.cc - src/core/lib/iomgr/iomgr_internal.cc - src/core/lib/promise/activity.cc - src/core/lib/resource_quota/arena.cc - src/core/lib/resource_quota/memory_quota.cc - src/core/lib/resource_quota/resource_quota.cc - src/core/lib/resource_quota/thread_quota.cc - src/core/lib/resource_quota/trace.cc - src/core/lib/slice/slice.cc - src/core/lib/slice/slice_refcount.cc - src/core/lib/slice/slice_string_helpers.cc - src/core/lib/slice/static_slice.cc + src/core/ext/upb-generated/google/protobuf/any.upb.c + src/core/ext/upb-generated/google/rpc/status.upb.c + src/core/lib/gpr/alloc.cc + src/core/lib/gpr/atm.cc + src/core/lib/gpr/cpu_iphone.cc + src/core/lib/gpr/cpu_linux.cc + src/core/lib/gpr/cpu_posix.cc + src/core/lib/gpr/cpu_windows.cc + src/core/lib/gpr/env_linux.cc + src/core/lib/gpr/env_posix.cc + src/core/lib/gpr/env_windows.cc + src/core/lib/gpr/log.cc + src/core/lib/gpr/log_android.cc + src/core/lib/gpr/log_linux.cc + src/core/lib/gpr/log_posix.cc + src/core/lib/gpr/log_windows.cc + src/core/lib/gpr/murmur_hash.cc + src/core/lib/gpr/string.cc + src/core/lib/gpr/string_posix.cc + src/core/lib/gpr/string_util_windows.cc + src/core/lib/gpr/string_windows.cc + src/core/lib/gpr/sync.cc + src/core/lib/gpr/sync_abseil.cc + src/core/lib/gpr/sync_posix.cc + src/core/lib/gpr/sync_windows.cc + src/core/lib/gpr/time.cc + src/core/lib/gpr/time_posix.cc + src/core/lib/gpr/time_precise.cc + src/core/lib/gpr/time_windows.cc + src/core/lib/gpr/tmpfile_msys.cc + src/core/lib/gpr/tmpfile_posix.cc + src/core/lib/gpr/tmpfile_windows.cc + src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc + src/core/lib/gprpp/examine_stack.cc + src/core/lib/gprpp/fork.cc + src/core/lib/gprpp/global_config_env.cc + src/core/lib/gprpp/host_port.cc + src/core/lib/gprpp/mpscq.cc + src/core/lib/gprpp/stat_posix.cc + src/core/lib/gprpp/stat_windows.cc + src/core/lib/gprpp/status_helper.cc + src/core/lib/gprpp/thd_posix.cc + src/core/lib/gprpp/thd_windows.cc + src/core/lib/gprpp/time_util.cc + src/core/lib/profiling/basic_timers.cc + src/core/lib/profiling/stap_timers.cc test/core/gprpp/chunked_vector_test.cc third_party/googletest/googletest/src/gtest-all.cc third_party/googletest/googlemock/src/gmock-all.cc @@ -9168,10 +9238,19 @@ target_include_directories(chunked_vector_test target_link_libraries(chunked_vector_test ${_gRPC_PROTOBUF_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES} - absl::statusor - absl::variant + absl::base + absl::core_headers + absl::memory + absl::random_random + absl::status + absl::cord + absl::str_format + absl::strings + absl::synchronization + absl::time + absl::optional absl::utility - gpr + upb ) @@ -9785,6 +9864,7 @@ add_executable(core_configuration_test src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc @@ -10841,6 +10921,7 @@ add_executable(for_each_test src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc @@ -12584,6 +12665,7 @@ add_executable(latch_test src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc @@ -13246,6 +13328,7 @@ add_executable(observable_test src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc @@ -13518,6 +13601,7 @@ add_executable(pipe_test src/core/lib/gpr/tmpfile_posix.cc src/core/lib/gpr/tmpfile_windows.cc src/core/lib/gpr/wrap_memcpy.cc + src/core/lib/gprpp/arena.cc src/core/lib/gprpp/examine_stack.cc src/core/lib/gprpp/fork.cc src/core/lib/gprpp/global_config_env.cc diff --git a/Makefile b/Makefile index 391f66cab98..a92c2cf595b 100644 --- a/Makefile +++ b/Makefile @@ -925,6 +925,7 @@ LIBGPR_SRC = \ src/core/lib/gpr/tmpfile_posix.cc \ src/core/lib/gpr/tmpfile_windows.cc \ src/core/lib/gpr/wrap_memcpy.cc \ + src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/examine_stack.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ @@ -1491,7 +1492,6 @@ LIBGRPC_SRC = \ src/core/lib/matchers/matchers.cc \ src/core/lib/promise/activity.cc \ src/core/lib/resource_quota/api.cc \ - src/core/lib/resource_quota/arena.cc \ src/core/lib/resource_quota/memory_quota.cc \ src/core/lib/resource_quota/resource_quota.cc \ src/core/lib/resource_quota/thread_quota.cc \ @@ -1986,7 +1986,6 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/json/json_writer.cc \ src/core/lib/promise/activity.cc \ src/core/lib/resource_quota/api.cc \ - src/core/lib/resource_quota/arena.cc \ src/core/lib/resource_quota/memory_quota.cc \ src/core/lib/resource_quota/resource_quota.cc \ src/core/lib/resource_quota/thread_quota.cc \ diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 4661739ec5e..ca401100267 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -312,6 +312,7 @@ libs: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/construct_destruct.h - src/core/lib/gprpp/debug_location.h - src/core/lib/gprpp/examine_stack.h @@ -364,6 +365,7 @@ libs: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc @@ -866,7 +868,6 @@ libs: - src/core/lib/promise/race.h - src/core/lib/promise/seq.h - src/core/lib/resource_quota/api.h - - src/core/lib/resource_quota/arena.h - src/core/lib/resource_quota/memory_quota.h - src/core/lib/resource_quota/resource_quota.h - src/core/lib/resource_quota/thread_quota.h @@ -1456,7 +1457,6 @@ libs: - src/core/lib/matchers/matchers.cc - src/core/lib/promise/activity.cc - src/core/lib/resource_quota/api.cc - - src/core/lib/resource_quota/arena.cc - src/core/lib/resource_quota/memory_quota.cc - src/core/lib/resource_quota/resource_quota.cc - src/core/lib/resource_quota/thread_quota.cc @@ -1971,7 +1971,6 @@ libs: - src/core/lib/promise/race.h - src/core/lib/promise/seq.h - src/core/lib/resource_quota/api.h - - src/core/lib/resource_quota/arena.h - src/core/lib/resource_quota/memory_quota.h - src/core/lib/resource_quota/resource_quota.h - src/core/lib/resource_quota/thread_quota.h @@ -2257,7 +2256,6 @@ libs: - src/core/lib/json/json_writer.cc - src/core/lib/promise/activity.cc - src/core/lib/resource_quota/api.cc - - src/core/lib/resource_quota/arena.cc - src/core/lib/resource_quota/memory_quota.cc - src/core/lib/resource_quota/resource_quota.cc - src/core/lib/resource_quota/thread_quota.cc @@ -4356,6 +4354,7 @@ targets: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/construct_destruct.h @@ -4424,6 +4423,7 @@ targets: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc @@ -4557,69 +4557,102 @@ targets: build: test language: c++ headers: - - src/core/lib/debug/trace.h - - src/core/lib/gprpp/atomic_utils.h - - src/core/lib/gprpp/cpp_impl_of.h - - src/core/lib/gprpp/dual_ref_counted.h - - src/core/lib/gprpp/orphanable.h - - src/core/lib/gprpp/ref_counted.h - - src/core/lib/gprpp/ref_counted_ptr.h - - src/core/lib/iomgr/closure.h - - src/core/lib/iomgr/combiner.h - - src/core/lib/iomgr/error.h - - src/core/lib/iomgr/error_internal.h - - src/core/lib/iomgr/exec_ctx.h - - src/core/lib/iomgr/executor.h - - src/core/lib/iomgr/iomgr_internal.h - - src/core/lib/promise/activity.h + - src/core/ext/upb-generated/google/protobuf/any.upb.h + - src/core/ext/upb-generated/google/rpc/status.upb.h + - src/core/lib/gpr/alloc.h + - src/core/lib/gpr/env.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h + - src/core/lib/gpr/string.h + - src/core/lib/gpr/string_windows.h + - src/core/lib/gpr/time_precise.h + - src/core/lib/gpr/tls.h + - src/core/lib/gpr/tmpfile.h + - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h + - src/core/lib/gprpp/construct_destruct.h + - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/examine_stack.h + - src/core/lib/gprpp/fork.h + - src/core/lib/gprpp/global_config.h + - src/core/lib/gprpp/global_config_custom.h + - src/core/lib/gprpp/global_config_env.h + - src/core/lib/gprpp/global_config_generic.h + - src/core/lib/gprpp/host_port.h + - src/core/lib/gprpp/manual_constructor.h + - src/core/lib/gprpp/memory.h + - src/core/lib/gprpp/mpscq.h + - src/core/lib/gprpp/stat.h + - src/core/lib/gprpp/status_helper.h + - src/core/lib/gprpp/sync.h + - src/core/lib/gprpp/thd.h + - src/core/lib/gprpp/time_util.h + - src/core/lib/profiling/timers.h - src/core/lib/promise/arena_promise.h - - src/core/lib/promise/context.h - - src/core/lib/promise/detail/basic_seq.h - - src/core/lib/promise/detail/promise_factory.h - - src/core/lib/promise/detail/promise_like.h - - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - - src/core/lib/promise/loop.h - - src/core/lib/promise/map.h - src/core/lib/promise/poll.h - - src/core/lib/promise/race.h - - src/core/lib/promise/seq.h - - src/core/lib/resource_quota/arena.h - - src/core/lib/resource_quota/memory_quota.h - - src/core/lib/resource_quota/resource_quota.h - - src/core/lib/resource_quota/thread_quota.h - - src/core/lib/resource_quota/trace.h - - src/core/lib/slice/slice.h - - src/core/lib/slice/slice_internal.h - - src/core/lib/slice/slice_refcount.h - - src/core/lib/slice/slice_refcount_base.h - - src/core/lib/slice/slice_string_helpers.h - - src/core/lib/slice/slice_utils.h - - src/core/lib/slice/static_slice.h src: - - src/core/lib/debug/trace.cc - - src/core/lib/event_engine/memory_allocator.cc - - src/core/lib/iomgr/combiner.cc - - src/core/lib/iomgr/error.cc - - src/core/lib/iomgr/exec_ctx.cc - - src/core/lib/iomgr/executor.cc - - src/core/lib/iomgr/iomgr_internal.cc - - src/core/lib/promise/activity.cc - - src/core/lib/resource_quota/arena.cc - - src/core/lib/resource_quota/memory_quota.cc - - src/core/lib/resource_quota/resource_quota.cc - - src/core/lib/resource_quota/thread_quota.cc - - src/core/lib/resource_quota/trace.cc - - src/core/lib/slice/slice.cc - - src/core/lib/slice/slice_refcount.cc - - src/core/lib/slice/slice_string_helpers.cc - - src/core/lib/slice/static_slice.cc + - src/core/ext/upb-generated/google/protobuf/any.upb.c + - src/core/ext/upb-generated/google/rpc/status.upb.c + - src/core/lib/gpr/alloc.cc + - src/core/lib/gpr/atm.cc + - src/core/lib/gpr/cpu_iphone.cc + - src/core/lib/gpr/cpu_linux.cc + - src/core/lib/gpr/cpu_posix.cc + - src/core/lib/gpr/cpu_windows.cc + - src/core/lib/gpr/env_linux.cc + - src/core/lib/gpr/env_posix.cc + - src/core/lib/gpr/env_windows.cc + - src/core/lib/gpr/log.cc + - src/core/lib/gpr/log_android.cc + - src/core/lib/gpr/log_linux.cc + - src/core/lib/gpr/log_posix.cc + - src/core/lib/gpr/log_windows.cc + - src/core/lib/gpr/murmur_hash.cc + - src/core/lib/gpr/string.cc + - src/core/lib/gpr/string_posix.cc + - src/core/lib/gpr/string_util_windows.cc + - src/core/lib/gpr/string_windows.cc + - src/core/lib/gpr/sync.cc + - src/core/lib/gpr/sync_abseil.cc + - src/core/lib/gpr/sync_posix.cc + - src/core/lib/gpr/sync_windows.cc + - src/core/lib/gpr/time.cc + - src/core/lib/gpr/time_posix.cc + - src/core/lib/gpr/time_precise.cc + - src/core/lib/gpr/time_windows.cc + - src/core/lib/gpr/tmpfile_msys.cc + - src/core/lib/gpr/tmpfile_posix.cc + - src/core/lib/gpr/tmpfile_windows.cc + - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc + - src/core/lib/gprpp/examine_stack.cc + - src/core/lib/gprpp/fork.cc + - src/core/lib/gprpp/global_config_env.cc + - src/core/lib/gprpp/host_port.cc + - src/core/lib/gprpp/mpscq.cc + - src/core/lib/gprpp/stat_posix.cc + - src/core/lib/gprpp/stat_windows.cc + - src/core/lib/gprpp/status_helper.cc + - src/core/lib/gprpp/thd_posix.cc + - src/core/lib/gprpp/thd_windows.cc + - src/core/lib/gprpp/time_util.cc + - src/core/lib/profiling/basic_timers.cc + - src/core/lib/profiling/stap_timers.cc - test/core/promise/arena_promise_test.cc deps: - - absl/status:statusor + - absl/base:base + - absl/base:core_headers + - absl/memory:memory + - absl/random:random + - absl/status:status + - absl/strings:cord + - absl/strings:str_format + - absl/strings:strings + - absl/synchronization:synchronization + - absl/time:time + - absl/types:optional - absl/types:variant - - gpr + - upb uses_polling: false - name: async_end2end_test gtest: true @@ -5070,70 +5103,101 @@ targets: build: test language: c++ headers: - - src/core/lib/debug/trace.h - - src/core/lib/gprpp/atomic_utils.h + - src/core/ext/upb-generated/google/protobuf/any.upb.h + - src/core/ext/upb-generated/google/rpc/status.upb.h + - src/core/lib/gpr/alloc.h + - src/core/lib/gpr/env.h + - src/core/lib/gpr/murmur_hash.h + - src/core/lib/gpr/spinlock.h + - src/core/lib/gpr/string.h + - src/core/lib/gpr/string_windows.h + - src/core/lib/gpr/time_precise.h + - src/core/lib/gpr/tls.h + - src/core/lib/gpr/tmpfile.h + - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/chunked_vector.h - - src/core/lib/gprpp/cpp_impl_of.h - - src/core/lib/gprpp/dual_ref_counted.h - - src/core/lib/gprpp/orphanable.h - - src/core/lib/gprpp/ref_counted.h - - src/core/lib/gprpp/ref_counted_ptr.h - - src/core/lib/iomgr/closure.h - - src/core/lib/iomgr/combiner.h - - src/core/lib/iomgr/error.h - - src/core/lib/iomgr/error_internal.h - - src/core/lib/iomgr/exec_ctx.h - - src/core/lib/iomgr/executor.h - - src/core/lib/iomgr/iomgr_internal.h - - src/core/lib/promise/activity.h - - src/core/lib/promise/context.h - - src/core/lib/promise/detail/basic_seq.h - - src/core/lib/promise/detail/promise_factory.h - - src/core/lib/promise/detail/promise_like.h - - src/core/lib/promise/detail/status.h - - src/core/lib/promise/detail/switch.h - - src/core/lib/promise/exec_ctx_wakeup_scheduler.h - - src/core/lib/promise/loop.h - - src/core/lib/promise/map.h - - src/core/lib/promise/poll.h - - src/core/lib/promise/race.h - - src/core/lib/promise/seq.h - - src/core/lib/resource_quota/arena.h - - src/core/lib/resource_quota/memory_quota.h - - src/core/lib/resource_quota/resource_quota.h - - src/core/lib/resource_quota/thread_quota.h - - src/core/lib/resource_quota/trace.h - - src/core/lib/slice/slice.h - - src/core/lib/slice/slice_internal.h - - src/core/lib/slice/slice_refcount.h - - src/core/lib/slice/slice_refcount_base.h - - src/core/lib/slice/slice_string_helpers.h - - src/core/lib/slice/slice_utils.h - - src/core/lib/slice/static_slice.h + - src/core/lib/gprpp/construct_destruct.h + - src/core/lib/gprpp/debug_location.h + - src/core/lib/gprpp/examine_stack.h + - src/core/lib/gprpp/fork.h + - src/core/lib/gprpp/global_config.h + - src/core/lib/gprpp/global_config_custom.h + - src/core/lib/gprpp/global_config_env.h + - src/core/lib/gprpp/global_config_generic.h + - src/core/lib/gprpp/host_port.h + - src/core/lib/gprpp/manual_constructor.h + - src/core/lib/gprpp/memory.h + - src/core/lib/gprpp/mpscq.h + - src/core/lib/gprpp/stat.h + - src/core/lib/gprpp/status_helper.h + - src/core/lib/gprpp/sync.h + - src/core/lib/gprpp/thd.h + - src/core/lib/gprpp/time_util.h + - src/core/lib/profiling/timers.h src: - - src/core/lib/debug/trace.cc - - src/core/lib/event_engine/memory_allocator.cc - - src/core/lib/iomgr/combiner.cc - - src/core/lib/iomgr/error.cc - - src/core/lib/iomgr/exec_ctx.cc - - src/core/lib/iomgr/executor.cc - - src/core/lib/iomgr/iomgr_internal.cc - - src/core/lib/promise/activity.cc - - src/core/lib/resource_quota/arena.cc - - src/core/lib/resource_quota/memory_quota.cc - - src/core/lib/resource_quota/resource_quota.cc - - src/core/lib/resource_quota/thread_quota.cc - - src/core/lib/resource_quota/trace.cc - - src/core/lib/slice/slice.cc - - src/core/lib/slice/slice_refcount.cc - - src/core/lib/slice/slice_string_helpers.cc - - src/core/lib/slice/static_slice.cc + - src/core/ext/upb-generated/google/protobuf/any.upb.c + - src/core/ext/upb-generated/google/rpc/status.upb.c + - src/core/lib/gpr/alloc.cc + - src/core/lib/gpr/atm.cc + - src/core/lib/gpr/cpu_iphone.cc + - src/core/lib/gpr/cpu_linux.cc + - src/core/lib/gpr/cpu_posix.cc + - src/core/lib/gpr/cpu_windows.cc + - src/core/lib/gpr/env_linux.cc + - src/core/lib/gpr/env_posix.cc + - src/core/lib/gpr/env_windows.cc + - src/core/lib/gpr/log.cc + - src/core/lib/gpr/log_android.cc + - src/core/lib/gpr/log_linux.cc + - src/core/lib/gpr/log_posix.cc + - src/core/lib/gpr/log_windows.cc + - src/core/lib/gpr/murmur_hash.cc + - src/core/lib/gpr/string.cc + - src/core/lib/gpr/string_posix.cc + - src/core/lib/gpr/string_util_windows.cc + - src/core/lib/gpr/string_windows.cc + - src/core/lib/gpr/sync.cc + - src/core/lib/gpr/sync_abseil.cc + - src/core/lib/gpr/sync_posix.cc + - src/core/lib/gpr/sync_windows.cc + - src/core/lib/gpr/time.cc + - src/core/lib/gpr/time_posix.cc + - src/core/lib/gpr/time_precise.cc + - src/core/lib/gpr/time_windows.cc + - src/core/lib/gpr/tmpfile_msys.cc + - src/core/lib/gpr/tmpfile_posix.cc + - src/core/lib/gpr/tmpfile_windows.cc + - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc + - src/core/lib/gprpp/examine_stack.cc + - src/core/lib/gprpp/fork.cc + - src/core/lib/gprpp/global_config_env.cc + - src/core/lib/gprpp/host_port.cc + - src/core/lib/gprpp/mpscq.cc + - src/core/lib/gprpp/stat_posix.cc + - src/core/lib/gprpp/stat_windows.cc + - src/core/lib/gprpp/status_helper.cc + - src/core/lib/gprpp/thd_posix.cc + - src/core/lib/gprpp/thd_windows.cc + - src/core/lib/gprpp/time_util.cc + - src/core/lib/profiling/basic_timers.cc + - src/core/lib/profiling/stap_timers.cc - test/core/gprpp/chunked_vector_test.cc deps: - - absl/status:statusor - - absl/types:variant + - absl/base:base + - absl/base:core_headers + - absl/memory:memory + - absl/random:random + - absl/status:status + - absl/strings:cord + - absl/strings:str_format + - absl/strings:strings + - absl/synchronization:synchronization + - absl/time:time + - absl/types:optional - absl/utility:utility - - gpr + - upb uses_polling: false - name: cli_call_test gtest: true @@ -5348,6 +5412,7 @@ targets: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/construct_destruct.h - src/core/lib/gprpp/debug_location.h - src/core/lib/gprpp/examine_stack.h @@ -5406,6 +5471,7 @@ targets: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc @@ -5907,6 +5973,7 @@ targets: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/construct_destruct.h @@ -5979,6 +6046,7 @@ targets: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc @@ -6549,6 +6617,7 @@ targets: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/construct_destruct.h @@ -6617,6 +6686,7 @@ targets: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc @@ -6884,6 +6954,7 @@ targets: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/construct_destruct.h - src/core/lib/gprpp/debug_location.h @@ -6950,6 +7021,7 @@ targets: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc @@ -7049,6 +7121,7 @@ targets: - src/core/lib/gpr/tls.h - src/core/lib/gpr/tmpfile.h - src/core/lib/gpr/useful.h + - src/core/lib/gprpp/arena.h - src/core/lib/gprpp/atomic_utils.h - src/core/lib/gprpp/bitset.h - src/core/lib/gprpp/construct_destruct.h @@ -7118,6 +7191,7 @@ targets: - src/core/lib/gpr/tmpfile_posix.cc - src/core/lib/gpr/tmpfile_windows.cc - src/core/lib/gpr/wrap_memcpy.cc + - src/core/lib/gprpp/arena.cc - src/core/lib/gprpp/examine_stack.cc - src/core/lib/gprpp/fork.cc - src/core/lib/gprpp/global_config_env.cc diff --git a/config.m4 b/config.m4 index 927915abb61..e0b617ca5b5 100644 --- a/config.m4 +++ b/config.m4 @@ -436,6 +436,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/gpr/tmpfile_posix.cc \ src/core/lib/gpr/tmpfile_windows.cc \ src/core/lib/gpr/wrap_memcpy.cc \ + src/core/lib/gprpp/arena.cc \ src/core/lib/gprpp/examine_stack.cc \ src/core/lib/gprpp/fork.cc \ src/core/lib/gprpp/global_config_env.cc \ @@ -553,7 +554,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/profiling/stap_timers.cc \ src/core/lib/promise/activity.cc \ src/core/lib/resource_quota/api.cc \ - src/core/lib/resource_quota/arena.cc \ src/core/lib/resource_quota/memory_quota.cc \ src/core/lib/resource_quota/resource_quota.cc \ src/core/lib/resource_quota/thread_quota.cc \ diff --git a/config.w32 b/config.w32 index 5ad01e4785d..d9df2d9bf18 100644 --- a/config.w32 +++ b/config.w32 @@ -402,6 +402,7 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\gpr\\tmpfile_posix.cc " + "src\\core\\lib\\gpr\\tmpfile_windows.cc " + "src\\core\\lib\\gpr\\wrap_memcpy.cc " + + "src\\core\\lib\\gprpp\\arena.cc " + "src\\core\\lib\\gprpp\\examine_stack.cc " + "src\\core\\lib\\gprpp\\fork.cc " + "src\\core\\lib\\gprpp\\global_config_env.cc " + @@ -519,7 +520,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\profiling\\stap_timers.cc " + "src\\core\\lib\\promise\\activity.cc " + "src\\core\\lib\\resource_quota\\api.cc " + - "src\\core\\lib\\resource_quota\\arena.cc " + "src\\core\\lib\\resource_quota\\memory_quota.cc " + "src\\core\\lib\\resource_quota\\resource_quota.cc " + "src\\core\\lib\\resource_quota\\thread_quota.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 8a42c509ef1..a2a07be1307 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -609,6 +609,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tls.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gpr/useful.h', + 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic_utils.h', 'src/core/lib/gprpp/bitset.h', 'src/core/lib/gprpp/chunked_vector.h', @@ -731,7 +732,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/race.h', 'src/core/lib/promise/seq.h', 'src/core/lib/resource_quota/api.h', - 'src/core/lib/resource_quota/arena.h', 'src/core/lib/resource_quota/memory_quota.h', 'src/core/lib/resource_quota/resource_quota.h', 'src/core/lib/resource_quota/thread_quota.h', @@ -1332,6 +1332,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tls.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gpr/useful.h', + 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic_utils.h', 'src/core/lib/gprpp/bitset.h', 'src/core/lib/gprpp/chunked_vector.h', @@ -1454,7 +1455,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/race.h', 'src/core/lib/promise/seq.h', 'src/core/lib/resource_quota/api.h', - 'src/core/lib/resource_quota/arena.h', 'src/core/lib/resource_quota/memory_quota.h', 'src/core/lib/resource_quota/resource_quota.h', 'src/core/lib/resource_quota/thread_quota.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 2f4761ae343..04b8dc3fff1 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -944,6 +944,8 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tmpfile_windows.cc', 'src/core/lib/gpr/useful.h', 'src/core/lib/gpr/wrap_memcpy.cc', + 'src/core/lib/gprpp/arena.cc', + 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic_utils.h', 'src/core/lib/gprpp/bitset.h', 'src/core/lib/gprpp/chunked_vector.h', @@ -1183,8 +1185,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/seq.h', 'src/core/lib/resource_quota/api.cc', 'src/core/lib/resource_quota/api.h', - 'src/core/lib/resource_quota/arena.cc', - 'src/core/lib/resource_quota/arena.h', 'src/core/lib/resource_quota/memory_quota.cc', 'src/core/lib/resource_quota/memory_quota.h', 'src/core/lib/resource_quota/resource_quota.cc', @@ -1869,6 +1869,7 @@ Pod::Spec.new do |s| 'src/core/lib/gpr/tls.h', 'src/core/lib/gpr/tmpfile.h', 'src/core/lib/gpr/useful.h', + 'src/core/lib/gprpp/arena.h', 'src/core/lib/gprpp/atomic_utils.h', 'src/core/lib/gprpp/bitset.h', 'src/core/lib/gprpp/chunked_vector.h', @@ -1991,7 +1992,6 @@ Pod::Spec.new do |s| 'src/core/lib/promise/race.h', 'src/core/lib/promise/seq.h', 'src/core/lib/resource_quota/api.h', - 'src/core/lib/resource_quota/arena.h', 'src/core/lib/resource_quota/memory_quota.h', 'src/core/lib/resource_quota/resource_quota.h', 'src/core/lib/resource_quota/thread_quota.h', diff --git a/grpc.gemspec b/grpc.gemspec index 008a4fbb627..cf8cf19a38f 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -863,6 +863,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/gpr/tmpfile_windows.cc ) s.files += %w( src/core/lib/gpr/useful.h ) s.files += %w( src/core/lib/gpr/wrap_memcpy.cc ) + s.files += %w( src/core/lib/gprpp/arena.cc ) + s.files += %w( src/core/lib/gprpp/arena.h ) s.files += %w( src/core/lib/gprpp/atomic_utils.h ) s.files += %w( src/core/lib/gprpp/bitset.h ) s.files += %w( src/core/lib/gprpp/chunked_vector.h ) @@ -1102,8 +1104,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/promise/seq.h ) s.files += %w( src/core/lib/resource_quota/api.cc ) s.files += %w( src/core/lib/resource_quota/api.h ) - s.files += %w( src/core/lib/resource_quota/arena.cc ) - s.files += %w( src/core/lib/resource_quota/arena.h ) s.files += %w( src/core/lib/resource_quota/memory_quota.cc ) s.files += %w( src/core/lib/resource_quota/memory_quota.h ) s.files += %w( src/core/lib/resource_quota/resource_quota.cc ) diff --git a/grpc.gyp b/grpc.gyp index 5b91b16d56f..976f43bb802 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -447,6 +447,7 @@ 'src/core/lib/gpr/tmpfile_posix.cc', 'src/core/lib/gpr/tmpfile_windows.cc', 'src/core/lib/gpr/wrap_memcpy.cc', + 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/examine_stack.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', @@ -946,7 +947,6 @@ 'src/core/lib/matchers/matchers.cc', 'src/core/lib/promise/activity.cc', 'src/core/lib/resource_quota/api.cc', - 'src/core/lib/resource_quota/arena.cc', 'src/core/lib/resource_quota/memory_quota.cc', 'src/core/lib/resource_quota/resource_quota.cc', 'src/core/lib/resource_quota/thread_quota.cc', @@ -1413,7 +1413,6 @@ 'src/core/lib/json/json_writer.cc', 'src/core/lib/promise/activity.cc', 'src/core/lib/resource_quota/api.cc', - 'src/core/lib/resource_quota/arena.cc', 'src/core/lib/resource_quota/memory_quota.cc', 'src/core/lib/resource_quota/resource_quota.cc', 'src/core/lib/resource_quota/thread_quota.cc', diff --git a/package.xml b/package.xml index 0d3df25549c..2077c664735 100644 --- a/package.xml +++ b/package.xml @@ -843,6 +843,8 @@ + + @@ -1082,8 +1084,6 @@ - - diff --git a/src/core/ext/filters/client_channel/backend_metric.h b/src/core/ext/filters/client_channel/backend_metric.h index 70efe6b7f94..64f8ef61570 100644 --- a/src/core/ext/filters/client_channel/backend_metric.h +++ b/src/core/ext/filters/client_channel/backend_metric.h @@ -22,7 +22,7 @@ #include #include "src/core/ext/filters/client_channel/lb_policy.h" -#include "src/core/lib/resource_quota/arena.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/slice/slice.h" namespace grpc_core { diff --git a/src/core/ext/filters/client_channel/config_selector.h b/src/core/ext/filters/client_channel/config_selector.h index 655afa03a2d..5feb3313c42 100644 --- a/src/core/ext/filters/client_channel/config_selector.h +++ b/src/core/ext/filters/client_channel/config_selector.h @@ -31,9 +31,9 @@ #include "src/core/ext/service_config/service_config_call_data.h" #include "src/core/ext/service_config/service_config_parser.h" #include "src/core/lib/channel/channel_stack.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/transport/metadata_batch.h" // Channel arg key for ConfigSelector. diff --git a/src/core/ext/filters/client_channel/dynamic_filters.h b/src/core/ext/filters/client_channel/dynamic_filters.h index 03211ec1085..08a7f4985eb 100644 --- a/src/core/ext/filters/client_channel/dynamic_filters.h +++ b/src/core/ext/filters/client_channel/dynamic_filters.h @@ -23,10 +23,10 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/gpr/time_precise.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/polling_entity.h" -#include "src/core/lib/resource_quota/arena.h" namespace grpc_core { diff --git a/src/core/ext/filters/client_channel/health/health_check_client.cc b/src/core/ext/filters/client_channel/health/health_check_client.cc index a5c8ed61a9a..5da3fe387ae 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.cc +++ b/src/core/ext/filters/client_channel/health/health_check_client.cc @@ -29,7 +29,6 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gprpp/sync.h" -#include "src/core/lib/resource_quota/api.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/error_utils.h" #include "src/proto/grpc/health/v1/health.upb.h" @@ -61,10 +60,6 @@ HealthCheckClient::HealthCheckClient( connected_subchannel_(std::move(connected_subchannel)), interested_parties_(interested_parties), channelz_node_(std::move(channelz_node)), - call_allocator_( - ResourceQuotaFromChannelArgs(connected_subchannel_->args()) - ->memory_quota() - ->CreateMemoryAllocator(service_name_)), watcher_(std::move(watcher)), retry_backoff_( BackOff::Options() @@ -259,8 +254,7 @@ HealthCheckClient::CallState::CallState( : health_check_client_(std::move(health_check_client)), pollent_(grpc_polling_entity_create_from_pollset_set(interested_parties)), arena_(Arena::Create(health_check_client_->connected_subchannel_ - ->GetInitialCallSizeEstimate(), - &health_check_client_->call_allocator_)), + ->GetInitialCallSizeEstimate())), payload_(context_), send_initial_metadata_(arena_), send_trailing_metadata_(arena_), diff --git a/src/core/ext/filters/client_channel/health/health_check_client.h b/src/core/ext/filters/client_channel/health/health_check_client.h index c22ea1986d7..86e2fd2eaba 100644 --- a/src/core/ext/filters/client_channel/health/health_check_client.h +++ b/src/core/ext/filters/client_channel/health/health_check_client.h @@ -29,6 +29,7 @@ #include "src/core/ext/filters/client_channel/client_channel_channelz.h" #include "src/core/ext/filters/client_channel/subchannel.h" #include "src/core/lib/backoff/backoff.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" @@ -36,7 +37,6 @@ #include "src/core/lib/iomgr/closure.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/transport.h" @@ -60,7 +60,7 @@ class HealthCheckClient : public InternallyRefCounted { class CallState : public Orphanable { public: CallState(RefCountedPtr health_check_client, - grpc_pollset_set* interested_parties); + grpc_pollset_set* interested_parties_); ~CallState() override; void Orphan() override; @@ -155,7 +155,6 @@ class HealthCheckClient : public InternallyRefCounted { RefCountedPtr connected_subchannel_; grpc_pollset_set* interested_parties_; // Do not own. RefCountedPtr channelz_node_; - MemoryAllocator call_allocator_; Mutex mu_; RefCountedPtr watcher_ diff --git a/src/core/ext/filters/client_channel/subchannel.h b/src/core/ext/filters/client_channel/subchannel.h index 6a38d2870dd..d956d3e60c4 100644 --- a/src/core/ext/filters/client_channel/subchannel.h +++ b/src/core/ext/filters/client_channel/subchannel.h @@ -27,13 +27,13 @@ #include "src/core/lib/backoff/backoff.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/gpr/time_precise.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/dual_ref_counted.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/sync.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/timer.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/metadata.h" diff --git a/src/core/ext/transport/binder/client/channel_create_impl.cc b/src/core/ext/transport/binder/client/channel_create_impl.cc index e8ffc9aa784..63449dbcb54 100644 --- a/src/core/ext/transport/binder/client/channel_create_impl.cc +++ b/src/core/ext/transport/binder/client/channel_create_impl.cc @@ -25,7 +25,6 @@ #include "src/core/ext/transport/binder/transport/binder_transport.h" #include "src/core/ext/transport/binder/wire_format/binder.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/channel.h" @@ -54,9 +53,6 @@ grpc_channel* CreateDirectBinderChannelImplForTesting( grpc_arg default_authority_arg = grpc_channel_arg_string_create( const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("binder.authority")); - args = grpc_core::CoreConfiguration::Get() - .channel_args_preconditioning() - .PreconditionChannelArgs(args); grpc_channel_args* final_args = grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); grpc_error_handle error = GRPC_ERROR_NONE; @@ -65,7 +61,6 @@ grpc_channel* CreateDirectBinderChannelImplForTesting( GRPC_CLIENT_DIRECT_CHANNEL, transport, &error); // TODO(mingcl): Handle error properly GPR_ASSERT(error == GRPC_ERROR_NONE); - grpc_channel_args_destroy(args); grpc_channel_args_destroy(final_args); return channel; } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index c819c1a7fec..acdb5a9fd38 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -650,6 +650,10 @@ grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, : t(t), refcount(refcount), reffer(this), + stream_reservation(t->memory_owner.MakeReservation( + grpc_core::kResourceQuotaCallSize)), // TODO(ctiller): sizeof(*this), + // or better, move allocation to + // memory quota. initial_metadata_buffer(arena), trailing_metadata_buffer(arena) { if (server_data) { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index bbb8932221e..e9e6ef143a7 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -523,6 +523,8 @@ struct grpc_chttp2_stream { explicit Reffer(grpc_chttp2_stream* s); } reffer; + grpc_core::MemoryAllocator::Reservation stream_reservation; + grpc_closure destroy_stream; grpc_closure* destroy_stream_arg; diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index 0f3504f85b7..5e6b3594db8 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -54,9 +54,9 @@ #include "src/core/lib/debug/trace.h" #include "src/core/lib/gpr/time_precise.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/iomgr/polling_entity.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/transport/transport.h" typedef struct grpc_channel_element grpc_channel_element; diff --git a/src/core/lib/channel/channel_stack_builder.cc b/src/core/lib/channel/channel_stack_builder.cc index 05bbae71d37..b9c0e4c7f91 100644 --- a/src/core/lib/channel/channel_stack_builder.cc +++ b/src/core/lib/channel/channel_stack_builder.cc @@ -69,9 +69,9 @@ void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder* b, b->target = gpr_strdup(target); } -std::string grpc_channel_stack_builder_get_target( +const char* grpc_channel_stack_builder_get_target( grpc_channel_stack_builder* b) { - return b->target == nullptr ? std::string() : std::string(b->target); + return b->target; } static grpc_channel_stack_builder_iterator* create_iterator_at_filter_node( diff --git a/src/core/lib/channel/channel_stack_builder.h b/src/core/lib/channel/channel_stack_builder.h index 5518329cd74..0071aa960f5 100644 --- a/src/core/lib/channel/channel_stack_builder.h +++ b/src/core/lib/channel/channel_stack_builder.h @@ -43,7 +43,7 @@ void grpc_channel_stack_builder_set_name(grpc_channel_stack_builder* builder, void grpc_channel_stack_builder_set_target(grpc_channel_stack_builder* b, const char* target); -std::string grpc_channel_stack_builder_get_target( +const char* grpc_channel_stack_builder_get_target( grpc_channel_stack_builder* b); /// Attach \a transport to the builder (does not take ownership) diff --git a/src/core/lib/resource_quota/arena.cc b/src/core/lib/gprpp/arena.cc similarity index 74% rename from src/core/lib/resource_quota/arena.cc rename to src/core/lib/gprpp/arena.cc index 7d7e1857b56..9e979de39ae 100644 --- a/src/core/lib/resource_quota/arena.cc +++ b/src/core/lib/gprpp/arena.cc @@ -18,7 +18,7 @@ #include -#include "src/core/lib/resource_quota/arena.h" +#include "src/core/lib/gprpp/arena.h" #include @@ -61,24 +61,22 @@ Arena::~Arena() { } } -Arena* Arena::Create(size_t initial_size, MemoryAllocator* memory_allocator) { - return new (ArenaStorage(initial_size)) - Arena(initial_size, 0, memory_allocator); +Arena* Arena::Create(size_t initial_size) { + return new (ArenaStorage(initial_size)) Arena(initial_size); } -std::pair Arena::CreateWithAlloc( - size_t initial_size, size_t alloc_size, MemoryAllocator* memory_allocator) { +std::pair Arena::CreateWithAlloc(size_t initial_size, + size_t alloc_size) { static constexpr size_t base_size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(Arena)); - auto* new_arena = new (ArenaStorage(initial_size)) - Arena(initial_size, alloc_size, memory_allocator); + auto* new_arena = + new (ArenaStorage(initial_size)) Arena(initial_size, alloc_size); void* first_alloc = reinterpret_cast(new_arena) + base_size; return std::make_pair(new_arena, first_alloc); } size_t Arena::Destroy() { size_t size = total_used_.load(std::memory_order_relaxed); - memory_allocator_->Release(total_allocated_.load(std::memory_order_relaxed)); this->~Arena(); gpr_free_aligned(this); return size; @@ -93,14 +91,13 @@ void* Arena::AllocZone(size_t size) { static constexpr size_t zone_base_size = GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(Zone)); size_t alloc_size = zone_base_size + size; - memory_allocator_->Reserve(alloc_size); - total_allocated_.fetch_add(alloc_size, std::memory_order_relaxed); Zone* z = new (gpr_malloc_aligned(alloc_size, GPR_MAX_ALIGNMENT)) Zone(); - auto* prev = last_zone_.load(std::memory_order_relaxed); - do { - z->prev = prev; - } while (!last_zone_.compare_exchange_weak(prev, z, std::memory_order_relaxed, - std::memory_order_relaxed)); + { + gpr_spinlock_lock(&arena_growth_spinlock_); + z->prev = last_zone_; + last_zone_ = z; + gpr_spinlock_unlock(&arena_growth_spinlock_); + } return reinterpret_cast(z) + zone_base_size; } diff --git a/src/core/lib/resource_quota/arena.h b/src/core/lib/gprpp/arena.h similarity index 80% rename from src/core/lib/resource_quota/arena.h rename to src/core/lib/gprpp/arena.h index f071d3431d3..3967f2f8e85 100644 --- a/src/core/lib/resource_quota/arena.h +++ b/src/core/lib/gprpp/arena.h @@ -22,8 +22,8 @@ // Tracks the total memory allocated against it, so that future arenas can // pre-allocate the right amount of memory -#ifndef GRPC_CORE_LIB_RESOURCE_QUOTA_ARENA_H -#define GRPC_CORE_LIB_RESOURCE_QUOTA_ARENA_H +#ifndef GRPC_CORE_LIB_GPRPP_ARENA_H +#define GRPC_CORE_LIB_GPRPP_ARENA_H #include @@ -38,21 +38,20 @@ #include #include "src/core/lib/gpr/alloc.h" -#include "src/core/lib/resource_quota/memory_quota.h" +#include "src/core/lib/gpr/spinlock.h" namespace grpc_core { class Arena { public: // Create an arena, with \a initial_size bytes in the first allocated buffer. - static Arena* Create(size_t initial_size, MemoryAllocator* memory_allocator); + static Arena* Create(size_t initial_size); // Create an arena, with \a initial_size bytes in the first allocated buffer, // and return both a void pointer to the returned arena and a void* with the // first allocation. - static std::pair CreateWithAlloc( - size_t initial_size, size_t alloc_size, - MemoryAllocator* memory_allocator); + static std::pair CreateWithAlloc(size_t initial_size, + size_t alloc_size); // Destroy an arena, returning the total number of bytes allocated. size_t Destroy(); @@ -97,11 +96,9 @@ class Arena { // quick optimization (avoiding an atomic fetch-add) for the common case // where we wish to create an arena and then perform an immediate // allocation. - explicit Arena(size_t initial_size, size_t initial_alloc, - MemoryAllocator* memory_allocator) + explicit Arena(size_t initial_size, size_t initial_alloc = 0) : total_used_(GPR_ROUND_UP_TO_ALIGNMENT_SIZE(initial_alloc)), - initial_zone_size_(initial_size), - memory_allocator_(memory_allocator) {} + initial_zone_size_(initial_size) {} ~Arena(); @@ -110,16 +107,14 @@ class Arena { // Keep track of the total used size. We use this in our call sizing // hysteresis. std::atomic total_used_{0}; - std::atomic total_allocated_{0}; const size_t initial_zone_size_; + gpr_spinlock arena_growth_spinlock_ = GPR_SPINLOCK_STATIC_INITIALIZER; // If the initial arena allocation wasn't enough, we allocate additional zones // in a reverse linked list. Each additional zone consists of (1) a pointer to // the zone added before this zone (null if this is the first additional zone) // and (2) the allocated memory. The arena itself maintains a pointer to the // last zone; the zone list is reverse-walked during arena destruction only. - std::atomic last_zone_{nullptr}; - // The backing memory quota - MemoryAllocator* const memory_allocator_; + Zone* last_zone_ = nullptr; }; // Smart pointer for arenas when the final size is not required. @@ -127,11 +122,10 @@ struct ScopedArenaDeleter { void operator()(Arena* arena) { arena->Destroy(); } }; using ScopedArenaPtr = std::unique_ptr; -inline ScopedArenaPtr MakeScopedArena(size_t initial_size, - MemoryAllocator* memory_allocator) { - return ScopedArenaPtr(Arena::Create(initial_size, memory_allocator)); +inline ScopedArenaPtr MakeScopedArena(size_t initial_size) { + return ScopedArenaPtr(Arena::Create(initial_size)); } } // namespace grpc_core -#endif /* GRPC_CORE_LIB_RESOURCE_QUOTA_ARENA_H */ +#endif /* GRPC_CORE_LIB_GPRPP_ARENA_H */ diff --git a/src/core/lib/gprpp/chunked_vector.h b/src/core/lib/gprpp/chunked_vector.h index feb982f96b5..256fa908b4e 100644 --- a/src/core/lib/gprpp/chunked_vector.h +++ b/src/core/lib/gprpp/chunked_vector.h @@ -17,8 +17,8 @@ #include +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/manual_constructor.h" -#include "src/core/lib/resource_quota/arena.h" namespace grpc_core { diff --git a/src/core/lib/promise/arena_promise.h b/src/core/lib/promise/arena_promise.h index a62a6c21269..35d914d3c2b 100644 --- a/src/core/lib/promise/arena_promise.h +++ b/src/core/lib/promise/arena_promise.h @@ -19,8 +19,8 @@ #include +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/promise/poll.h" -#include "src/core/lib/resource_quota/arena.h" namespace grpc_core { diff --git a/src/core/lib/resource_quota/api.h b/src/core/lib/resource_quota/api.h index 40d0a0525f4..c531813038f 100644 --- a/src/core/lib/resource_quota/api.h +++ b/src/core/lib/resource_quota/api.h @@ -27,6 +27,7 @@ namespace grpc_core { // TODO(ctiller): This is a hack. We need to do real accounting instead of // hard coding. +constexpr size_t kResourceQuotaCallSize = 15 * 1024; constexpr size_t kResourceQuotaChannelSize = 50 * 1024; // Retrieve the resource quota from the channel args. diff --git a/src/core/lib/security/context/security_context.cc b/src/core/lib/security/context/security_context.cc index 7e0aa2b8e2d..257f5c25cb0 100644 --- a/src/core/lib/security/context/security_context.cc +++ b/src/core/lib/security/context/security_context.cc @@ -29,9 +29,9 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/call.h" diff --git a/src/core/lib/security/context/security_context.h b/src/core/lib/security/context/security_context.h index 2c695931b56..6ff4856e6bd 100644 --- a/src/core/lib/security/context/security_context.h +++ b/src/core/lib/security/context/security_context.h @@ -21,10 +21,10 @@ #include +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/pollset.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/security/credentials/credentials.h" extern grpc_core::DebugOnlyTraceFlag grpc_trace_auth_context_refcount; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index b17b5bb2a5e..082ba66fd2c 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -45,11 +45,11 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/time_precise.h" #include "src/core/lib/gpr/useful.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/manual_constructor.h" #include "src/core/lib/gprpp/ref_counted.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice_split.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/slice/slice_utils.h" @@ -362,8 +362,7 @@ grpc_error_handle grpc_call_create(const grpc_call_create_args* args, call_and_stack_size + (args->parent ? sizeof(child_call) : 0); std::pair arena_with_call = - grpc_core::Arena::CreateWithAlloc(initial_size, call_alloc_size, - &*args->channel->allocator); + grpc_core::Arena::CreateWithAlloc(initial_size, call_alloc_size); arena = arena_with_call.first; call = new (arena_with_call.second) grpc_call(arena, *args); *out_call = call; diff --git a/src/core/lib/surface/call.h b/src/core/lib/surface/call.h index 8074395bd09..e16a6be520e 100644 --- a/src/core/lib/surface/call.h +++ b/src/core/lib/surface/call.h @@ -26,7 +26,7 @@ #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/context.h" -#include "src/core/lib/resource_quota/arena.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/surface/api_trace.h" #include "src/core/lib/surface/server.h" diff --git a/src/core/lib/surface/channel.cc b/src/core/lib/surface/channel.cc index 9df3dc9938d..d10cb074a49 100644 --- a/src/core/lib/surface/channel.cc +++ b/src/core/lib/surface/channel.cc @@ -41,7 +41,6 @@ #include "src/core/lib/gprpp/memory.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/iomgr.h" -#include "src/core/lib/resource_quota/api.h" #include "src/core/lib/resource_quota/memory_quota.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/surface/api_trace.h" @@ -60,7 +59,7 @@ static void destroy_channel(void* arg, grpc_error_handle error); grpc_channel* grpc_channel_create_with_builder( grpc_channel_stack_builder* builder, grpc_channel_stack_type channel_stack_type, grpc_error_handle* error) { - std::string target = grpc_channel_stack_builder_get_target(builder); + char* target = gpr_strdup(grpc_channel_stack_builder_get_target(builder)); grpc_channel_args* args = grpc_channel_args_copy( grpc_channel_stack_builder_get_channel_arguments(builder)); grpc_channel* channel; @@ -69,7 +68,6 @@ grpc_channel* grpc_channel_create_with_builder( } else { GRPC_STATS_INC_CLIENT_CHANNELS_CREATED(); } - std::string name = grpc_channel_stack_builder_get_target(builder); grpc_error_handle builder_error = grpc_channel_stack_builder_finish( builder, sizeof(grpc_channel), 1, destroy_channel, nullptr, reinterpret_cast(&channel)); @@ -82,15 +80,13 @@ grpc_channel* grpc_channel_create_with_builder( } else { GRPC_ERROR_UNREF(builder_error); } + gpr_free(target); grpc_channel_args_destroy(args); return nullptr; } - channel->target.Init(std::move(target)); + channel->target = target; channel->is_client = grpc_channel_stack_type_is_client(channel_stack_type); channel->registration_table.Init(); - channel->allocator.Init(grpc_core::ResourceQuotaFromChannelArgs(args) - ->memory_quota() - ->CreateMemoryOwner(name)); gpr_atm_no_barrier_store( &channel->call_size_estimate, @@ -201,10 +197,11 @@ void CreateChannelzNode(grpc_channel_stack_builder* builder) { const bool is_internal_channel = grpc_channel_args_find_bool( args, GRPC_ARG_CHANNELZ_IS_INTERNAL_CHANNEL, false); // Create the channelz node. - std::string target = grpc_channel_stack_builder_get_target(builder); + const char* target = grpc_channel_stack_builder_get_target(builder); grpc_core::RefCountedPtr channelz_node = grpc_core::MakeRefCounted( - target.c_str(), channel_tracer_max_memory, is_internal_channel); + target != nullptr ? target : "", channel_tracer_max_memory, + is_internal_channel); channelz_node->AddTraceEvent( grpc_core::channelz::ChannelTrace::Severity::Info, grpc_slice_from_static_string("Channel created")); @@ -316,7 +313,7 @@ void grpc_channel_update_call_size_estimate(grpc_channel* channel, char* grpc_channel_get_target(grpc_channel* channel) { GRPC_API_TRACE("grpc_channel_get_target(channel=%p)", 1, (channel)); - return gpr_strdup(channel->target->c_str()); + return gpr_strdup(channel->target); } void grpc_channel_get_info(grpc_channel* channel, @@ -489,8 +486,7 @@ static void destroy_channel(void* arg, grpc_error_handle /*error*/) { } grpc_channel_stack_destroy(CHANNEL_STACK_FROM_CHANNEL(channel)); channel->registration_table.Destroy(); - channel->allocator.Destroy(); - channel->target.Destroy(); + gpr_free(channel->target); gpr_free(channel); // See comment in grpc_channel_create() for why we do this. grpc_shutdown(); diff --git a/src/core/lib/surface/channel.h b/src/core/lib/surface/channel.h index 3641398449b..9037d2e1a7a 100644 --- a/src/core/lib/surface/channel.h +++ b/src/core/lib/surface/channel.h @@ -110,9 +110,8 @@ struct grpc_channel { grpc_core::ManualConstructor registration_table; grpc_core::RefCountedPtr channelz_node; - grpc_core::ManualConstructor allocator; - grpc_core::ManualConstructor target; + char* target; }; #define CHANNEL_STACK_FROM_CHANNEL(c) ((grpc_channel_stack*)((c) + 1)) diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 577e439dc4d..72440cda5ca 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -24,13 +24,13 @@ #include #include "src/core/lib/channel/context.h" +#include "src/core/lib/gprpp/arena.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/iomgr/endpoint.h" #include "src/core/lib/iomgr/polling_entity.h" #include "src/core/lib/iomgr/pollset.h" #include "src/core/lib/iomgr/pollset_set.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/byte_stream.h" #include "src/core/lib/transport/connectivity_state.h" diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 91a14dde9ce..e4d6f61b9f5 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -411,6 +411,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/gpr/tmpfile_posix.cc', 'src/core/lib/gpr/tmpfile_windows.cc', 'src/core/lib/gpr/wrap_memcpy.cc', + 'src/core/lib/gprpp/arena.cc', 'src/core/lib/gprpp/examine_stack.cc', 'src/core/lib/gprpp/fork.cc', 'src/core/lib/gprpp/global_config_env.cc', @@ -528,7 +529,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/profiling/stap_timers.cc', 'src/core/lib/promise/activity.cc', 'src/core/lib/resource_quota/api.cc', - 'src/core/lib/resource_quota/arena.cc', 'src/core/lib/resource_quota/memory_quota.cc', 'src/core/lib/resource_quota/resource_quota.cc', 'src/core/lib/resource_quota/thread_quota.cc', diff --git a/test/core/end2end/fixtures/h2_sockpair.cc b/test/core/end2end/fixtures/h2_sockpair.cc index d9b02fa80f7..794becf5760 100644 --- a/test/core/end2end/fixtures/h2_sockpair.cc +++ b/test/core/end2end/fixtures/h2_sockpair.cc @@ -114,15 +114,15 @@ static void chttp2_init_client_socketpair( auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; sp_client_setup cs; + cs.client_args = client_args; + cs.f = f; client_args = grpc_core::CoreConfiguration::Get() .channel_args_preconditioning() .PreconditionChannelArgs(client_args); - cs.client_args = client_args; - cs.f = f; transport = grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true); - client_setup_transport(&cs, transport); grpc_channel_args_destroy(client_args); + client_setup_transport(&cs, transport); GPR_ASSERT(f->client); } diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.cc b/test/core/end2end/fixtures/h2_sockpair_1byte.cc index 95f51af46e4..b9616d0199a 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.cc +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.cc @@ -125,15 +125,15 @@ static void chttp2_init_client_socketpair( auto* fixture_data = static_cast(f->fixture_data); grpc_transport* transport; sp_client_setup cs; + cs.client_args = client_args; + cs.f = f; client_args = grpc_core::CoreConfiguration::Get() .channel_args_preconditioning() .PreconditionChannelArgs(client_args); - cs.client_args = client_args; - cs.f = f; transport = grpc_create_chttp2_transport(client_args, fixture_data->ep.client, true); - client_setup_transport(&cs, transport); grpc_channel_args_destroy(client_args); + client_setup_transport(&cs, transport); GPR_ASSERT(f->client); } diff --git a/test/core/end2end/fuzzers/api_fuzzer.cc b/test/core/end2end/fuzzers/api_fuzzer.cc index cf2769707b3..a3e1068b77b 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.cc +++ b/test/core/end2end/fuzzers/api_fuzzer.cc @@ -189,8 +189,7 @@ static void do_connect(void* arg, grpc_error_handle error) { core_server->channel_args(), server, false); GPR_ASSERT(GRPC_LOG_IF_ERROR( "SetupTransport", - core_server->SetupTransport(transport, nullptr, - core_server->channel_args(), nullptr))); + core_server->SetupTransport(transport, nullptr, nullptr, nullptr))); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr); grpc_core::ExecCtx::Run(DEBUG_LOCATION, fc->closure, GRPC_ERROR_NONE); diff --git a/test/core/end2end/fuzzers/client_fuzzer.cc b/test/core/end2end/fuzzers/client_fuzzer.cc index 6db3b3b19e4..39fbf24fc6c 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.cc +++ b/test/core/end2end/fuzzers/client_fuzzer.cc @@ -62,14 +62,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("test-authority")); args = grpc_channel_args_copy_and_add(nullptr, &authority_arg, 1); - const grpc_channel_args* channel_args = grpc_core::CoreConfiguration::Get() - .channel_args_preconditioning() - .PreconditionChannelArgs(args); - grpc_channel* channel = - grpc_channel_create("test-target", channel_args, - GRPC_CLIENT_DIRECT_CHANNEL, transport, nullptr); + grpc_channel* channel = grpc_channel_create( + "test-target", args, GRPC_CLIENT_DIRECT_CHANNEL, transport, nullptr); grpc_channel_args_destroy(args); - grpc_channel_args_destroy(channel_args); grpc_slice host = grpc_slice_from_static_string("localhost"); grpc_call* call = grpc_channel_create_call( channel, nullptr, 0, cq, grpc_slice_from_static_string("/foo"), &host, diff --git a/test/core/end2end/fuzzers/server_fuzzer.cc b/test/core/end2end/fuzzers/server_fuzzer.cc index 30fc573820e..7e70f2b5b4e 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.cc +++ b/test/core/end2end/fuzzers/server_fuzzer.cc @@ -58,11 +58,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { .PreconditionChannelArgs(nullptr); grpc_transport* transport = grpc_create_chttp2_transport(channel_args, mock_endpoint, false); + grpc_channel_args_destroy(channel_args); grpc_resource_quota_unref(resource_quota); GPR_ASSERT(GRPC_LOG_IF_ERROR( "SetupTransport", grpc_core::Server::FromC(server)->SetupTransport( - transport, nullptr, channel_args, nullptr))); - grpc_channel_args_destroy(channel_args); + transport, nullptr, nullptr, nullptr))); grpc_chttp2_transport_start_reading(transport, nullptr, nullptr, nullptr); grpc_call* call1 = nullptr; diff --git a/test/core/gpr/arena_test.cc b/test/core/gpr/arena_test.cc index 6fc2a6314d9..64bd0589897 100644 --- a/test/core/gpr/arena_test.cc +++ b/test/core/gpr/arena_test.cc @@ -16,7 +16,7 @@ * */ -#include "src/core/lib/resource_quota/arena.h" +#include "src/core/lib/gprpp/arena.h" #include #include @@ -32,16 +32,11 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/gpr/useful.h" #include "src/core/lib/gprpp/thd.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "test/core/util/test_config.h" using grpc_core::Arena; -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - -static void test_noop(void) { Arena::Create(1, g_memory_allocator)->Destroy(); } +static void test_noop(void) { Arena::Create(1)->Destroy(); } static void test(const char* name, size_t init_size, const size_t* allocs, size_t nallocs) { @@ -55,7 +50,7 @@ static void test(const char* name, size_t init_size, const size_t* allocs, std::string s = absl::StrJoin(parts, ""); gpr_log(GPR_INFO, "%s", s.c_str()); - Arena* a = Arena::Create(init_size, g_memory_allocator); + Arena* a = Arena::Create(init_size); void** ps = static_cast(gpr_zalloc(sizeof(*ps) * nallocs)); for (size_t i = 0; i < nallocs; i++) { ps[i] = a->Alloc(allocs[i]); @@ -101,7 +96,7 @@ static void concurrent_test(void) { concurrent_test_args args; gpr_event_init(&args.ev_start); - args.arena = Arena::Create(1024, g_memory_allocator); + args.arena = Arena::Create(1024); grpc_core::Thread thds[CONCURRENT_TEST_THREADS]; diff --git a/test/core/gprpp/BUILD b/test/core/gprpp/BUILD index 99dcbec8110..9bb380d45fd 100644 --- a/test/core/gprpp/BUILD +++ b/test/core/gprpp/BUILD @@ -306,7 +306,6 @@ grpc_cc_test( deps = [ "//:chunked_vector", "//:gpr_base", - "//:resource_quota", "//test/core/util:grpc_suppressions", ], ) @@ -321,7 +320,6 @@ grpc_proto_fuzzer( uses_polling = False, deps = [ "//:chunked_vector", - "//:resource_quota", "//test/core/util:grpc_test_util", ], ) diff --git a/test/core/gprpp/chunked_vector_fuzzer.cc b/test/core/gprpp/chunked_vector_fuzzer.cc index 52b55773e5d..1704e3e789c 100644 --- a/test/core/gprpp/chunked_vector_fuzzer.cc +++ b/test/core/gprpp/chunked_vector_fuzzer.cc @@ -15,17 +15,12 @@ #include #include "src/core/lib/gprpp/chunked_vector.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/libfuzzer/libfuzzer_macro.h" #include "test/core/gprpp/chunked_vector_fuzzer.pb.h" bool squelch = true; bool leak_check = true; -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - static constexpr size_t kChunkSize = 17; using IntHdl = std::shared_ptr; @@ -144,7 +139,7 @@ class Fuzzer { return &vectors_.emplace(index, Comparison(arena_.get())).first->second; } - ScopedArenaPtr arena_ = MakeScopedArena(128, g_memory_allocator); + ScopedArenaPtr arena_ = MakeScopedArena(128); std::map vectors_; }; } // namespace grpc_core diff --git a/test/core/gprpp/chunked_vector_test.cc b/test/core/gprpp/chunked_vector_test.cc index fbd8c557909..274bc0f3b15 100644 --- a/test/core/gprpp/chunked_vector_test.cc +++ b/test/core/gprpp/chunked_vector_test.cc @@ -16,25 +16,20 @@ #include -#include "src/core/lib/resource_quota/resource_quota.h" - namespace grpc_core { namespace testing { -static auto* g_memory_allocator = new MemoryAllocator( - ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test")); - static constexpr size_t kInitialArenaSize = 1024; static constexpr size_t kChunkSize = 3; TEST(ChunkedVector, Noop) { - auto arena = MakeScopedArena(kInitialArenaSize, g_memory_allocator); + auto arena = MakeScopedArena(kInitialArenaSize); ChunkedVector v(arena.get()); EXPECT_EQ(0, v.size()); } TEST(ChunkedVector, Stack) { - auto arena = MakeScopedArena(kInitialArenaSize, g_memory_allocator); + auto arena = MakeScopedArena(kInitialArenaSize); ChunkedVector v(arena.get()); // Populate 2 chunks of memory, and 2/3 of a final chunk. @@ -76,7 +71,7 @@ TEST(ChunkedVector, Stack) { } TEST(ChunkedVector, Iterate) { - auto arena = MakeScopedArena(kInitialArenaSize, g_memory_allocator); + auto arena = MakeScopedArena(kInitialArenaSize); ChunkedVector v(arena.get()); v.EmplaceBack(1); v.EmplaceBack(2); @@ -108,7 +103,7 @@ TEST(ChunkedVector, Iterate) { } TEST(ChunkedVector, ConstIterate) { - auto arena = MakeScopedArena(kInitialArenaSize, g_memory_allocator); + auto arena = MakeScopedArena(kInitialArenaSize); ChunkedVector v(arena.get()); v.EmplaceBack(1); v.EmplaceBack(2); @@ -140,7 +135,7 @@ TEST(ChunkedVector, ConstIterate) { } TEST(ChunkedVector, Clear) { - auto arena = MakeScopedArena(kInitialArenaSize, g_memory_allocator); + auto arena = MakeScopedArena(kInitialArenaSize); ChunkedVector v(arena.get()); v.EmplaceBack(1); EXPECT_EQ(v.size(), 1); diff --git a/test/core/promise/BUILD b/test/core/promise/BUILD index 41061142e3e..66dd1d9ab5e 100644 --- a/test/core/promise/BUILD +++ b/test/core/promise/BUILD @@ -75,7 +75,6 @@ grpc_cc_test( uses_polling = False, deps = [ "//:arena_promise", - "//:resource_quota", "//test/core/util:grpc_suppressions", ], ) diff --git a/test/core/promise/arena_promise_test.cc b/test/core/promise/arena_promise_test.cc index ff065b1a4c2..561373202c7 100644 --- a/test/core/promise/arena_promise_test.cc +++ b/test/core/promise/arena_promise_test.cc @@ -18,15 +18,10 @@ #include -#include "src/core/lib/resource_quota/resource_quota.h" - namespace grpc_core { -static auto* g_memory_allocator = new MemoryAllocator( - ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test")); - TEST(ArenaPromiseTest, AllocatedWorks) { - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); int x = 42; ArenaPromise p(arena.get(), [x] { return Poll(x); }); EXPECT_EQ(p(), Poll(42)); @@ -35,7 +30,7 @@ TEST(ArenaPromiseTest, AllocatedWorks) { } TEST(ArenaPromiseTest, DestructionWorks) { - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); auto x = std::make_shared(42); auto p = ArenaPromise(arena.get(), [x] { return Poll(*x); }); ArenaPromise q(std::move(p)); diff --git a/test/core/transport/binder/binder_transport_test.cc b/test/core/transport/binder/binder_transport_test.cc index 09b7c44ce78..c323608ad13 100644 --- a/test/core/transport/binder/binder_transport_test.cc +++ b/test/core/transport/binder/binder_transport_test.cc @@ -32,14 +32,9 @@ #include #include "src/core/ext/transport/binder/transport/binder_stream.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "test/core/transport/binder/mock_objects.h" #include "test/core/util/test_config.h" -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - namespace grpc_binder { namespace { @@ -50,8 +45,7 @@ using ::testing::Return; class BinderTransportTest : public ::testing::Test { public: BinderTransportTest() - : arena_(grpc_core::Arena::Create(/* initial_size = */ 1, - g_memory_allocator)), + : arena_(grpc_core::Arena::Create(/* initial_size = */ 1)), transport_(grpc_create_binder_transport_client( absl::make_unique>(), std::make_shared< @@ -217,8 +211,7 @@ struct MakeSendInitialMetadata { std::vector storage; grpc_linked_mdelem method_ref_storage; - grpc_core::ScopedArenaPtr arena = - grpc_core::MakeScopedArena(1024, g_memory_allocator); + grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch grpc_initial_metadata{arena.get()}; }; @@ -250,8 +243,7 @@ struct MakeSendTrailingMetadata { &grpc_trailing_metadata; } - grpc_core::ScopedArenaPtr arena = - grpc_core::MakeScopedArena(1024, g_memory_allocator); + grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch grpc_trailing_metadata{arena.get()}; }; @@ -274,8 +266,7 @@ struct MakeRecvInitialMetadata { ~MakeRecvInitialMetadata() {} MockGrpcClosure ready; - grpc_core::ScopedArenaPtr arena = - grpc_core::MakeScopedArena(1024, g_memory_allocator); + grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch grpc_initial_metadata{arena.get()}; absl::Notification notification; }; @@ -318,8 +309,7 @@ struct MakeRecvTrailingMetadata { ~MakeRecvTrailingMetadata() {} MockGrpcClosure ready; - grpc_core::ScopedArenaPtr arena = - grpc_core::MakeScopedArena(1024, g_memory_allocator); + grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch grpc_trailing_metadata{arena.get()}; absl::Notification notification; }; diff --git a/test/core/transport/binder/end2end/testing_channel_create.cc b/test/core/transport/binder/end2end/testing_channel_create.cc index 485a1d0e706..75dd531d3f4 100644 --- a/test/core/transport/binder/end2end/testing_channel_create.cc +++ b/test/core/transport/binder/end2end/testing_channel_create.cc @@ -21,7 +21,6 @@ #include "src/core/ext/transport/binder/transport/binder_transport.h" #include "src/core/ext/transport/binder/wire_format/wire_reader_impl.h" #include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/error_utils.h" @@ -108,16 +107,14 @@ std::shared_ptr BinderChannelForTesting( } // namespace end2end_testing } // namespace grpc_binder -grpc_channel* grpc_binder_channel_create_for_testing( - grpc_server* server, const grpc_channel_args* args, void* /*reserved*/) { +grpc_channel* grpc_binder_channel_create_for_testing(grpc_server* server, + grpc_channel_args* args, + void* /*reserved*/) { grpc_core::ExecCtx exec_ctx; grpc_arg default_authority_arg = grpc_channel_arg_string_create( const_cast(GRPC_ARG_DEFAULT_AUTHORITY), const_cast("test.authority")); - args = grpc_core::CoreConfiguration::Get() - .channel_args_preconditioning() - .PreconditionChannelArgs(args); grpc_channel_args* client_args = grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); @@ -131,7 +128,6 @@ grpc_channel* grpc_binder_channel_create_for_testing( grpc_channel_create("binder", client_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport, &error); GPR_ASSERT(error == GRPC_ERROR_NONE); - grpc_channel_args_destroy(args); grpc_channel_args_destroy(client_args); return channel; } diff --git a/test/core/transport/binder/end2end/testing_channel_create.h b/test/core/transport/binder/end2end/testing_channel_create.h index d0bf06ea54a..97058c330d0 100644 --- a/test/core/transport/binder/end2end/testing_channel_create.h +++ b/test/core/transport/binder/end2end/testing_channel_create.h @@ -35,7 +35,8 @@ std::shared_ptr BinderChannelForTesting( } // namespace end2end_testing } // namespace grpc_binder -grpc_channel* grpc_binder_channel_create_for_testing( - grpc_server* server, const grpc_channel_args* args, void* /*reserved*/); +grpc_channel* grpc_binder_channel_create_for_testing(grpc_server* server, + grpc_channel_args* args, + void* /*reserved*/); #endif // GRPC_TEST_CORE_TRANSPORT_BINDER_END2END_TESTING_CHANNEL_CREATE_H diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc index edb7ae48222..d59248cf8fd 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.cc +++ b/test/core/transport/chttp2/hpack_encoder_test.cc @@ -32,7 +32,6 @@ #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/ext/transport/chttp2/transport/hpack_utils.h" #include "src/core/lib/gpr/string.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/transport/metadata.h" @@ -42,10 +41,6 @@ #define TEST(x) run_test(x, #x) -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - grpc_core::HPackCompressor* g_compressor; int g_failure = 0; @@ -166,7 +161,7 @@ static void verify(const verify_params params, const char* expected, va_list l; grpc_linked_mdelem* e = static_cast(gpr_malloc(sizeof(*e) * nheaders)); - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch b(arena.get()); va_start(l, nheaders); @@ -249,7 +244,7 @@ static void test_basic_headers() { static void verify_continuation_headers(const char* key, const char* value, bool is_eof) { - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_slice_buffer output; grpc_mdelem elem = grpc_mdelem_from_slices( grpc_slice_intern(grpc_slice_from_static_string(key)), @@ -332,7 +327,7 @@ static void test_decode_table_overflow() { static void verify_table_size_change_match_elem_size(const char* key, const char* value, bool use_true_binary) { - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_slice_buffer output; grpc_mdelem elem = grpc_mdelem_from_slices( grpc_slice_intern(grpc_slice_from_static_string(key)), diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index 63aab2fbab6..99e0eeacab0 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -25,7 +25,6 @@ #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice_internal.h" #include "src/libfuzzer/libfuzzer_macro.h" #include "test/core/transport/chttp2/hpack_parser_fuzzer.pb.h" @@ -39,13 +38,10 @@ DEFINE_PROTO_FUZZER(const hpack_parser_fuzzer::Msg& msg) { grpc_test_only_set_slice_hash_seed(0); if (squelch) gpr_set_log_function(dont_log); grpc_init(); - auto memory_allocator = grpc_core::ResourceQuota::Default() - ->memory_quota() - ->CreateMemoryAllocator("test-allocator"); { std::unique_ptr parser(new grpc_core::HPackParser); for (int i = 0; i < msg.frames_size(); i++) { - auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_core::ExecCtx exec_ctx; grpc_metadata_batch b(arena.get()); diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 1280684a604..30b89df24ef 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -26,15 +26,10 @@ #include #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "test/core/util/parse_hexstring.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - struct TestInput { const char* input; const char* expected_parse; @@ -72,7 +67,7 @@ class ParseTest : public ::testing::TestWithParam { void TestVector(grpc_slice_split_mode mode, const char* hexstring, std::string expect) { - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_core::ExecCtx exec_ctx; grpc_slice input = parse_hexstring(hexstring); grpc_slice* slices; diff --git a/test/core/transport/metadata_map_test.cc b/test/core/transport/metadata_map_test.cc index 99e29398df3..91e58c6bb32 100644 --- a/test/core/transport/metadata_map_test.cc +++ b/test/core/transport/metadata_map_test.cc @@ -16,7 +16,6 @@ #include -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata_batch.h" #include "test/core/util/test_config.h" @@ -24,21 +23,18 @@ namespace grpc_core { namespace testing { -static auto* g_memory_allocator = new MemoryAllocator( - ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test")); - TEST(MetadataMapTest, Noop) { - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); MetadataMap<>(arena.get()); } TEST(MetadataMapTest, NoopWithDeadline) { - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); MetadataMap(arena.get()); } TEST(MetadataMapTest, SimpleOps) { - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); MetadataMap map(arena.get()); EXPECT_EQ(map.get_pointer(GrpcTimeoutMetadata()), nullptr); EXPECT_EQ(map.get(GrpcTimeoutMetadata()), absl::nullopt); @@ -74,7 +70,7 @@ class FakeEncoder { TEST(MetadataMapTest, EmptyEncodeTest) { FakeEncoder encoder; - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); MetadataMap map(arena.get()); map.Encode(&encoder); EXPECT_EQ(encoder.output(), ""); @@ -82,7 +78,7 @@ TEST(MetadataMapTest, EmptyEncodeTest) { TEST(MetadataMapTest, TimeoutEncodeTest) { FakeEncoder encoder; - auto arena = MakeScopedArena(1024, g_memory_allocator); + auto arena = MakeScopedArena(1024); MetadataMap map(arena.get()); map.Set(GrpcTimeoutMetadata(), 1234); map.Encode(&encoder); diff --git a/test/core/transport/metadata_test.cc b/test/core/transport/metadata_test.cc index 5579ac54d7d..81569297017 100644 --- a/test/core/transport/metadata_test.cc +++ b/test/core/transport/metadata_test.cc @@ -35,7 +35,6 @@ #include "src/core/lib/gpr/string.h" #include "src/core/lib/iomgr/error.h" #include "src/core/lib/iomgr/exec_ctx.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/transport/metadata_batch.h" #include "src/core/lib/transport/static_metadata.h" @@ -44,10 +43,6 @@ /* a large number */ #define MANY 10000 -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - static grpc_slice maybe_intern(grpc_slice in, bool intern) { grpc_slice out = intern ? grpc_slice_intern(in) : grpc_slice_ref(in); grpc_slice_unref(in); @@ -313,7 +308,7 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) { } static void test_grpc_metadata_batch_get_value_with_absent_key(void) { - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch metadata(arena.get()); std::string concatenated_value; absl::optional value = @@ -324,7 +319,7 @@ static void test_grpc_metadata_batch_get_value_with_absent_key(void) { static void test_grpc_metadata_batch_get_value_returns_one_value(void) { const char* kKey = "some_key"; const char* kValue = "some_value"; - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_linked_mdelem storage; grpc_metadata_batch metadata(arena.get()); storage.md = grpc_mdelem_from_slices( @@ -342,7 +337,7 @@ static void test_grpc_metadata_batch_get_value_returns_multiple_values(void) { const char* kKey = "some_key"; const char* kValue1 = "value1"; const char* kValue2 = "value2"; - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_linked_mdelem storage1; grpc_linked_mdelem storage2; grpc_metadata_batch metadata(arena.get()); @@ -362,7 +357,7 @@ static void test_grpc_metadata_batch_get_value_returns_multiple_values(void) { } static void test_grpc_chttp2_incoming_metadata_replace_or_add_works(void) { - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch buffer(arena.get()); GRPC_LOG_IF_ERROR("incoming_buffer_add", buffer.Append(grpc_mdelem_from_slices( diff --git a/test/core/util/evaluate_args_test_util.h b/test/core/util/evaluate_args_test_util.h index 1d5bf4c53a8..ab12dc5d043 100644 --- a/test/core/util/evaluate_args_test_util.h +++ b/test/core/util/evaluate_args_test_util.h @@ -56,10 +56,7 @@ class EvaluateArgsTestUtil { } private: - MemoryAllocator allocator_ = - ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "EvaluateArgsTestUtil"); - ScopedArenaPtr arena_ = MakeScopedArena(1024, &allocator_); + ScopedArenaPtr arena_ = MakeScopedArena(1024); grpc_metadata_batch metadata_{arena_.get()}; MockAuthorizationEndpoint endpoint_{/*local_uri=*/"", /*peer_uri=*/""}; grpc_auth_context auth_context_{nullptr}; diff --git a/test/cpp/microbenchmarks/bm_arena.cc b/test/cpp/microbenchmarks/bm_arena.cc index 6b1a9fc058c..aba5ceb68be 100644 --- a/test/cpp/microbenchmarks/bm_arena.cc +++ b/test/cpp/microbenchmarks/bm_arena.cc @@ -20,27 +20,22 @@ #include -#include "src/core/lib/resource_quota/arena.h" -#include "src/core/lib/resource_quota/resource_quota.h" +#include "src/core/lib/gprpp/arena.h" #include "test/core/util/test_config.h" #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" using grpc_core::Arena; -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - static void BM_Arena_NoOp(benchmark::State& state) { for (auto _ : state) { - Arena::Create(state.range(0), g_memory_allocator)->Destroy(); + Arena::Create(state.range(0))->Destroy(); } } BENCHMARK(BM_Arena_NoOp)->Range(1, 1024 * 1024); static void BM_Arena_ManyAlloc(benchmark::State& state) { - Arena* a = Arena::Create(state.range(0), g_memory_allocator); + Arena* a = Arena::Create(state.range(0)); const size_t realloc_after = 1024 * 1024 * 1024 / ((state.range(1) + 15) & 0xffffff0u); while (state.KeepRunning()) { @@ -48,7 +43,7 @@ static void BM_Arena_ManyAlloc(benchmark::State& state) { // periodically recreate arena to avoid OOM if (state.iterations() % realloc_after == 0) { a->Destroy(); - a = Arena::Create(state.range(0), g_memory_allocator); + a = Arena::Create(state.range(0)); } } a->Destroy(); @@ -57,7 +52,7 @@ BENCHMARK(BM_Arena_ManyAlloc)->Ranges({{1, 1024 * 1024}, {1, 32 * 1024}}); static void BM_Arena_Batch(benchmark::State& state) { for (auto _ : state) { - Arena* a = Arena::Create(state.range(0), g_memory_allocator); + Arena* a = Arena::Create(state.range(0)); for (int i = 0; i < state.range(1); i++) { a->Alloc(state.range(2)); } diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 9882fe0f70e..02e8952a61f 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -39,10 +39,8 @@ #include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/connected_channel.h" -#include "src/core/lib/config/core_configuration.h" #include "src/core/lib/iomgr/call_combiner.h" #include "src/core/lib/profiling/timers.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/transport/transport_impl.h" #include "src/cpp/client/create_channel_internal.h" @@ -51,10 +49,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - void BM_Zalloc(benchmark::State& state) { // speed of light for call creation is zalloc, so benchmark a few interesting // sizes @@ -541,15 +535,14 @@ static void BM_IsolatedFilter(benchmark::State& state) { TestOp test_op_data; const int kArenaSize = 4096; grpc_call_context_element context[GRPC_CONTEXT_COUNT] = {}; - grpc_call_element_args call_args{ - call_stack, - nullptr, - context, - method, - start_time, - deadline, - grpc_core::Arena::Create(kArenaSize, g_memory_allocator), - nullptr}; + grpc_call_element_args call_args{call_stack, + nullptr, + context, + method, + start_time, + deadline, + grpc_core::Arena::Create(kArenaSize), + nullptr}; while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); GRPC_ERROR_UNREF( @@ -561,8 +554,7 @@ static void BM_IsolatedFilter(benchmark::State& state) { // recreate arena every 64k iterations to avoid oom if (0 == (state.iterations() & 0xffff)) { call_args.arena->Destroy(); - call_args.arena = - grpc_core::Arena::Create(kArenaSize, g_memory_allocator); + call_args.arena = grpc_core::Arena::Create(kArenaSize); } } call_args.arena->Destroy(); @@ -704,13 +696,9 @@ class IsolatedCallFixture : public TrackCounters { // the grpc_shutdown() run by grpc_channel_destroy(). So we need to // call grpc_init() manually here to balance things out. grpc_init(); - const grpc_channel_args* args = grpc_core::CoreConfiguration::Get() - .channel_args_preconditioning() - .PreconditionChannelArgs(nullptr); grpc_channel_stack_builder* builder = grpc_channel_stack_builder_create(); grpc_channel_stack_builder_set_name(builder, "phony"); grpc_channel_stack_builder_set_target(builder, "phony_target"); - grpc_channel_stack_builder_set_channel_arguments(builder, args); GPR_ASSERT(grpc_channel_stack_builder_append_filter( builder, &isolated_call_filter::isolated_call_filter, nullptr, nullptr)); @@ -720,7 +708,6 @@ class IsolatedCallFixture : public TrackCounters { nullptr); } cq_ = grpc_completion_queue_create_for_next(nullptr); - grpc_channel_args_destroy(args); } void Finish(benchmark::State& state) override { diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index e8491274d5a..f12cdbffe26 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -30,7 +30,6 @@ #include "src/core/ext/transport/chttp2/transport/hpack_encoder.h" #include "src/core/ext/transport/chttp2/transport/hpack_parser.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/slice/slice_string_helpers.h" #include "src/core/lib/transport/metadata_batch.h" @@ -40,10 +39,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - static grpc_slice MakeSlice(std::vector bytes) { grpc_slice s = grpc_slice_malloc(bytes.size()); uint8_t* p = GRPC_SLICE_START_PTR(s); @@ -74,7 +69,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; grpc_millis saved_now = grpc_core::ExecCtx::Get()->Now(); - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch b(arena.get()); b.Set(grpc_core::GrpcTimeoutMetadata(), saved_now + 30 * 1000); @@ -116,7 +111,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { grpc_core::ExecCtx exec_ctx; static bool logged_representative_output = false; - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch b(arena.get()); Fixture::Prepare(&b); @@ -473,7 +468,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { std::vector benchmark_slices = Fixture::GetBenchmarkSlices(); grpc_core::HPackParser p; const int kArenaSize = 4096 * 4096; - auto* arena = grpc_core::Arena::Create(kArenaSize, g_memory_allocator); + auto* arena = grpc_core::Arena::Create(kArenaSize); grpc_core::ManualConstructor b; b.Init(arena); p.BeginFrame(&*b, std::numeric_limits::max(), @@ -494,7 +489,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { if (0 == (state.iterations() & 0xfff)) { b.Destroy(); arena->Destroy(); - arena = grpc_core::Arena::Create(kArenaSize, g_memory_allocator); + arena = grpc_core::Arena::Create(kArenaSize); b.Init(arena); p.BeginFrame(&*b, std::numeric_limits::max(), grpc_core::HPackParser::Boundary::None, diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 8765440d53f..29ae1696b96 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -41,10 +41,6 @@ #include "test/cpp/microbenchmarks/helpers.h" #include "test/cpp/util/test_config.h" -static auto* g_memory_allocator = new grpc_core::MemoryAllocator( - grpc_core::ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( - "test")); - //////////////////////////////////////////////////////////////////////////////// // Helper classes // @@ -200,7 +196,7 @@ class Stream { explicit Stream(Fixture* f) : f_(f) { stream_size_ = grpc_transport_stream_size(f->transport()); stream_ = gpr_malloc(stream_size_); - arena_ = grpc_core::Arena::Create(4096, g_memory_allocator); + arena_ = grpc_core::Arena::Create(4096); } ~Stream() { @@ -216,7 +212,7 @@ class Stream { memset(stream_, 0, stream_size_); if ((state.iterations() & 0xffff) == 0) { arena_->Destroy(); - arena_ = grpc_core::Arena::Create(4096, g_memory_allocator); + arena_ = grpc_core::Arena::Create(4096); } grpc_transport_init_stream(f_->transport(), static_cast(stream_), &refcount_, @@ -337,7 +333,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { op.payload = &op_payload; }; - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch b(arena.get()); Metadata::Prepare(&b); @@ -434,7 +430,7 @@ static void BM_TransportStreamSend(benchmark::State& state) { grpc_slice send_slice = grpc_slice_malloc_large(state.range(0)); memset(GRPC_SLICE_START_PTR(send_slice), 0, GRPC_SLICE_LENGTH(send_slice)); grpc_core::ManualConstructor send_stream; - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch b(arena.get()); RepresentativeClientInitialMetadata::Prepare(&b); @@ -568,7 +564,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { op.payload = &op_payload; }; - auto arena = grpc_core::MakeScopedArena(1024, g_memory_allocator); + auto arena = grpc_core::MakeScopedArena(1024); grpc_metadata_batch b(arena.get()); RepresentativeClientInitialMetadata::Prepare(&b); diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 65164414dd1..51661f403d9 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1842,6 +1842,8 @@ src/core/lib/gpr/tmpfile_posix.cc \ src/core/lib/gpr/tmpfile_windows.cc \ src/core/lib/gpr/useful.h \ src/core/lib/gpr/wrap_memcpy.cc \ +src/core/lib/gprpp/arena.cc \ +src/core/lib/gprpp/arena.h \ src/core/lib/gprpp/atomic_utils.h \ src/core/lib/gprpp/bitset.h \ src/core/lib/gprpp/chunked_vector.h \ @@ -2081,8 +2083,6 @@ src/core/lib/promise/race.h \ src/core/lib/promise/seq.h \ src/core/lib/resource_quota/api.cc \ src/core/lib/resource_quota/api.h \ -src/core/lib/resource_quota/arena.cc \ -src/core/lib/resource_quota/arena.h \ src/core/lib/resource_quota/memory_quota.cc \ src/core/lib/resource_quota/memory_quota.h \ src/core/lib/resource_quota/resource_quota.cc \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index a205835de3a..5a407a2a20e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -1640,6 +1640,8 @@ src/core/lib/gpr/tmpfile_windows.cc \ src/core/lib/gpr/useful.h \ src/core/lib/gpr/wrap_memcpy.cc \ src/core/lib/gprpp/README.md \ +src/core/lib/gprpp/arena.cc \ +src/core/lib/gprpp/arena.h \ src/core/lib/gprpp/atomic_utils.h \ src/core/lib/gprpp/bitset.h \ src/core/lib/gprpp/chunked_vector.h \ @@ -1880,8 +1882,6 @@ src/core/lib/promise/race.h \ src/core/lib/promise/seq.h \ src/core/lib/resource_quota/api.cc \ src/core/lib/resource_quota/api.h \ -src/core/lib/resource_quota/arena.cc \ -src/core/lib/resource_quota/arena.h \ src/core/lib/resource_quota/memory_quota.cc \ src/core/lib/resource_quota/memory_quota.h \ src/core/lib/resource_quota/resource_quota.cc \