diff --git a/BUILD b/BUILD index 020c3e96812..eb8979ddce6 100644 --- a/BUILD +++ b/BUILD @@ -1779,7 +1779,7 @@ grpc_cc_library( "ref_counted_ptr", "stats", "//src/core:arena", - "//src/core:call_factory", + "//src/core:call_size_estimator", "//src/core:channel_args", "//src/core:channel_fwd", "//src/core:channel_init", @@ -1790,6 +1790,7 @@ grpc_cc_library( "//src/core:init_internally", "//src/core:iomgr_fwd", "//src/core:metrics", + "//src/core:resource_quota", "//src/core:slice", "//src/core:stats_data", "//src/core:time", diff --git a/CMakeLists.txt b/CMakeLists.txt index c3e4e6d7b2b..b05932c44e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2510,7 +2510,6 @@ add_library(grpc src/core/lib/surface/wait_for_cq_end_op.cc src/core/lib/transport/batch_builder.cc src/core/lib/transport/bdp_estimator.cc - src/core/lib/transport/call_factory.cc src/core/lib/transport/call_filters.cc src/core/lib/transport/call_final_info.cc src/core/lib/transport/call_size_estimator.cc @@ -3236,7 +3235,6 @@ add_library(grpc_unsecure src/core/lib/surface/wait_for_cq_end_op.cc src/core/lib/transport/batch_builder.cc src/core/lib/transport/bdp_estimator.cc - src/core/lib/transport/call_factory.cc src/core/lib/transport/call_filters.cc src/core/lib/transport/call_final_info.cc src/core/lib/transport/call_size_estimator.cc diff --git a/Makefile b/Makefile index 1bfa6df4892..c8bf7b67e2a 100644 --- a/Makefile +++ b/Makefile @@ -1407,7 +1407,6 @@ LIBGRPC_SRC = \ src/core/lib/surface/wait_for_cq_end_op.cc \ src/core/lib/transport/batch_builder.cc \ src/core/lib/transport/bdp_estimator.cc \ - src/core/lib/transport/call_factory.cc \ src/core/lib/transport/call_filters.cc \ src/core/lib/transport/call_final_info.cc \ src/core/lib/transport/call_size_estimator.cc \ diff --git a/Package.swift b/Package.swift index 8dd50319324..4f251baf0e1 100644 --- a/Package.swift +++ b/Package.swift @@ -1804,8 +1804,6 @@ let package = Package( "src/core/lib/transport/batch_builder.h", "src/core/lib/transport/bdp_estimator.cc", "src/core/lib/transport/bdp_estimator.h", - "src/core/lib/transport/call_factory.cc", - "src/core/lib/transport/call_factory.h", "src/core/lib/transport/call_filters.cc", "src/core/lib/transport/call_filters.h", "src/core/lib/transport/call_final_info.cc", diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index af371057f88..d0f659ecd6c 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -1138,7 +1138,6 @@ libs: - src/core/lib/surface/wait_for_cq_end_op.h - src/core/lib/transport/batch_builder.h - src/core/lib/transport/bdp_estimator.h - - src/core/lib/transport/call_factory.h - src/core/lib/transport/call_filters.h - src/core/lib/transport/call_final_info.h - src/core/lib/transport/call_size_estimator.h @@ -1940,7 +1939,6 @@ libs: - src/core/lib/surface/wait_for_cq_end_op.cc - src/core/lib/transport/batch_builder.cc - src/core/lib/transport/bdp_estimator.cc - - src/core/lib/transport/call_factory.cc - src/core/lib/transport/call_filters.cc - src/core/lib/transport/call_final_info.cc - src/core/lib/transport/call_size_estimator.cc @@ -2606,7 +2604,6 @@ libs: - src/core/lib/surface/wait_for_cq_end_op.h - src/core/lib/transport/batch_builder.h - src/core/lib/transport/bdp_estimator.h - - src/core/lib/transport/call_factory.h - src/core/lib/transport/call_filters.h - src/core/lib/transport/call_final_info.h - src/core/lib/transport/call_size_estimator.h @@ -3026,7 +3023,6 @@ libs: - src/core/lib/surface/wait_for_cq_end_op.cc - src/core/lib/transport/batch_builder.cc - src/core/lib/transport/bdp_estimator.cc - - src/core/lib/transport/call_factory.cc - src/core/lib/transport/call_filters.cc - src/core/lib/transport/call_final_info.cc - src/core/lib/transport/call_size_estimator.cc diff --git a/config.m4 b/config.m4 index a99a765637c..9f7c9a26459 100644 --- a/config.m4 +++ b/config.m4 @@ -782,7 +782,6 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/surface/wait_for_cq_end_op.cc \ src/core/lib/transport/batch_builder.cc \ src/core/lib/transport/bdp_estimator.cc \ - src/core/lib/transport/call_factory.cc \ src/core/lib/transport/call_filters.cc \ src/core/lib/transport/call_final_info.cc \ src/core/lib/transport/call_size_estimator.cc \ diff --git a/config.w32 b/config.w32 index f2df20bdf9f..58110b18c32 100644 --- a/config.w32 +++ b/config.w32 @@ -747,7 +747,6 @@ if (PHP_GRPC != "no") { "src\\core\\lib\\surface\\wait_for_cq_end_op.cc " + "src\\core\\lib\\transport\\batch_builder.cc " + "src\\core\\lib\\transport\\bdp_estimator.cc " + - "src\\core\\lib\\transport\\call_factory.cc " + "src\\core\\lib\\transport\\call_filters.cc " + "src\\core\\lib\\transport\\call_final_info.cc " + "src\\core\\lib\\transport\\call_size_estimator.cc " + diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index 4b51f0c3ffa..009931bf5c1 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -1242,7 +1242,6 @@ Pod::Spec.new do |s| 'src/core/lib/surface/wait_for_cq_end_op.h', 'src/core/lib/transport/batch_builder.h', 'src/core/lib/transport/bdp_estimator.h', - 'src/core/lib/transport/call_factory.h', 'src/core/lib/transport/call_filters.h', 'src/core/lib/transport/call_final_info.h', 'src/core/lib/transport/call_size_estimator.h', @@ -2512,7 +2511,6 @@ Pod::Spec.new do |s| 'src/core/lib/surface/wait_for_cq_end_op.h', 'src/core/lib/transport/batch_builder.h', 'src/core/lib/transport/bdp_estimator.h', - 'src/core/lib/transport/call_factory.h', 'src/core/lib/transport/call_filters.h', 'src/core/lib/transport/call_final_info.h', 'src/core/lib/transport/call_size_estimator.h', diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 280e998223c..e96e29bd7c3 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -1916,8 +1916,6 @@ Pod::Spec.new do |s| 'src/core/lib/transport/batch_builder.h', 'src/core/lib/transport/bdp_estimator.cc', 'src/core/lib/transport/bdp_estimator.h', - 'src/core/lib/transport/call_factory.cc', - 'src/core/lib/transport/call_factory.h', 'src/core/lib/transport/call_filters.cc', 'src/core/lib/transport/call_filters.h', 'src/core/lib/transport/call_final_info.cc', @@ -3293,7 +3291,6 @@ Pod::Spec.new do |s| 'src/core/lib/surface/wait_for_cq_end_op.h', 'src/core/lib/transport/batch_builder.h', 'src/core/lib/transport/bdp_estimator.h', - 'src/core/lib/transport/call_factory.h', 'src/core/lib/transport/call_filters.h', 'src/core/lib/transport/call_final_info.h', 'src/core/lib/transport/call_size_estimator.h', diff --git a/grpc.gemspec b/grpc.gemspec index 7f5a93afed5..8756fb54f4a 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -1806,8 +1806,6 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/transport/batch_builder.h ) s.files += %w( src/core/lib/transport/bdp_estimator.cc ) s.files += %w( src/core/lib/transport/bdp_estimator.h ) - s.files += %w( src/core/lib/transport/call_factory.cc ) - s.files += %w( src/core/lib/transport/call_factory.h ) s.files += %w( src/core/lib/transport/call_filters.cc ) s.files += %w( src/core/lib/transport/call_filters.h ) s.files += %w( src/core/lib/transport/call_final_info.cc ) diff --git a/package.xml b/package.xml index b3de924127a..5fcdf502782 100644 --- a/package.xml +++ b/package.xml @@ -1788,8 +1788,6 @@ - - diff --git a/src/core/BUILD b/src/core/BUILD index 1a2eaf03762..0cd912802da 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -7227,26 +7227,6 @@ grpc_cc_library( ], ) -grpc_cc_library( - name = "call_factory", - srcs = [ - "lib/transport/call_factory.cc", - ], - hdrs = [ - "lib/transport/call_factory.h", - ], - deps = [ - "arena", - "call_size_estimator", - "call_spine", - "channel_args", - "ref_counted", - "resource_quota", - "//:gpr_platform", - "//:stats", - ], -) - grpc_cc_library( name = "call_destination", hdrs = [ diff --git a/src/core/lib/surface/legacy_channel.cc b/src/core/lib/surface/legacy_channel.cc index c82a84edce6..3f922476094 100644 --- a/src/core/lib/surface/legacy_channel.cc +++ b/src/core/lib/surface/legacy_channel.cc @@ -48,6 +48,7 @@ #include "src/core/lib/iomgr/closure.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/surface/call.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_init.h" @@ -55,7 +56,6 @@ #include "src/core/lib/surface/completion_queue.h" #include "src/core/lib/surface/init_internally.h" #include "src/core/lib/surface/lame_client.h" -#include "src/core/lib/transport/call_factory.h" #include "src/core/lib/transport/transport.h" namespace grpc_core { @@ -106,18 +106,6 @@ absl::StatusOr> LegacyChannel::Create( builder.IsPromising(), std::move(target), args, std::move(*r)); } -namespace { - -class NotReallyACallFactory final : public CallFactory { - public: - using CallFactory::CallFactory; - CallInitiator CreateCall(ClientMetadataHandle, Arena*) override { - Crash("NotReallyACallFactory::CreateCall should never be called"); - } -}; - -} // namespace - LegacyChannel::LegacyChannel(bool is_client, bool is_promising, std::string target, const ChannelArgs& channel_args, @@ -126,7 +114,9 @@ LegacyChannel::LegacyChannel(bool is_client, bool is_promising, is_client_(is_client), is_promising_(is_promising), channel_stack_(std::move(channel_stack)), - call_factory_(MakeRefCounted(channel_args)) { + allocator_(channel_args.GetObject() + ->memory_quota() + ->CreateMemoryOwner()) { // We need to make sure that grpc_shutdown() does not shut things down // until after the channel is destroyed. However, the channel may not // actually be destroyed by the time grpc_channel_destroy() returns, diff --git a/src/core/lib/surface/legacy_channel.h b/src/core/lib/surface/legacy_channel.h index a6c68572866..1e4a4e93bf5 100644 --- a/src/core/lib/surface/legacy_channel.h +++ b/src/core/lib/surface/legacy_channel.h @@ -33,14 +33,14 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_fwd.h" #include "src/core/lib/channel/channel_stack.h" // IWYU pragma: keep +#include "src/core/lib/debug/stats.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" #include "src/core/lib/iomgr/iomgr_fwd.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/surface/channel.h" #include "src/core/lib/surface/channel_stack_type.h" -#include "src/core/lib/transport/call_factory.h" -#include "src/core/lib/transport/transport.h" +#include "src/core/lib/transport/call_size_estimator.h" namespace grpc_core { @@ -57,9 +57,14 @@ class LegacyChannel final : public Channel { void Orphan() override; - Arena* CreateArena() override { return call_factory_->CreateArena(); } + Arena* CreateArena() override { + const size_t initial_size = call_size_estimator_.CallSizeEstimate(); + global_stats().IncrementCallInitialSize(initial_size); + return Arena::Create(initial_size, &allocator_); + } void DestroyArena(Arena* arena) override { - return call_factory_->DestroyArena(arena); + call_size_estimator_.UpdateCallSizeEstimate(arena->TotalUsedBytes()); + arena->Destroy(); } bool IsLame() const override; @@ -110,7 +115,8 @@ class LegacyChannel final : public Channel { const bool is_client_; const bool is_promising_; RefCountedPtr channel_stack_; - const RefCountedPtr call_factory_; + CallSizeEstimator call_size_estimator_{1024}; + grpc_event_engine::experimental::MemoryAllocator allocator_; }; } // namespace grpc_core diff --git a/src/core/lib/transport/call_factory.cc b/src/core/lib/transport/call_factory.cc deleted file mode 100644 index bcc01cc87ff..00000000000 --- a/src/core/lib/transport/call_factory.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2024 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include "src/core/lib/transport/call_factory.h" - -#include "src/core/lib/debug/stats.h" -#include "src/core/lib/resource_quota/resource_quota.h" - -namespace grpc_core { - -CallFactory::CallFactory(const ChannelArgs& args) - : call_size_estimator_(1024), - allocator_(args.GetObject() - ->memory_quota() - ->CreateMemoryOwner()) {} - -Arena* CallFactory::CreateArena() { - const size_t initial_size = call_size_estimator_.CallSizeEstimate(); - global_stats().IncrementCallInitialSize(initial_size); - return Arena::Create(initial_size, &allocator_); -} - -void CallFactory::DestroyArena(Arena* arena) { - call_size_estimator_.UpdateCallSizeEstimate(arena->TotalUsedBytes()); - arena->Destroy(); -} - -} // namespace grpc_core diff --git a/src/core/lib/transport/call_factory.h b/src/core/lib/transport/call_factory.h deleted file mode 100644 index 99bb1768650..00000000000 --- a/src/core/lib/transport/call_factory.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2024 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FACTORY_H -#define GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FACTORY_H - -#include - -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/gprpp/ref_counted.h" -#include "src/core/lib/resource_quota/arena.h" -#include "src/core/lib/transport/call_size_estimator.h" -#include "src/core/lib/transport/call_spine.h" - -namespace grpc_core { - -// CallFactory creates calls. -class CallFactory : public RefCounted { - public: - explicit CallFactory(const ChannelArgs& args); - - // Create an arena for a call. - // We do this as a separate step so that servers can create arenas without - // creating the call into it - in the case that we have a HTTP/2 rapid reset - // like attack this saves a lot of cpu time. - Arena* CreateArena(); - // Destroy an arena created by CreateArena. - // Updates the call size estimator so that we always create arenas of about - // the right size. - void DestroyArena(Arena* arena); - - // Create a call. The call will be created in the given arena. - // It is the CallFactory's responsibility to ensure that the CallHandler - // associated with the call is eventually handled by something (typically a - // CallDestination, but this is not strictly required). - virtual CallInitiator CreateCall(ClientMetadataHandle md, Arena* arena) = 0; - - private: - CallSizeEstimator call_size_estimator_; - MemoryAllocator allocator_; -}; - -} // namespace grpc_core - -#endif // GRPC_SRC_CORE_LIB_TRANSPORT_CALL_FACTORY_H diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 540ba147a25..bf054c2fe54 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -756,7 +756,6 @@ CORE_SOURCE_FILES = [ 'src/core/lib/surface/wait_for_cq_end_op.cc', 'src/core/lib/transport/batch_builder.cc', 'src/core/lib/transport/bdp_estimator.cc', - 'src/core/lib/transport/call_factory.cc', 'src/core/lib/transport/call_filters.cc', 'src/core/lib/transport/call_final_info.cc', 'src/core/lib/transport/call_size_estimator.cc', diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 4a1963c79de..3414fcda1a8 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -2805,8 +2805,6 @@ src/core/lib/transport/batch_builder.cc \ src/core/lib/transport/batch_builder.h \ src/core/lib/transport/bdp_estimator.cc \ src/core/lib/transport/bdp_estimator.h \ -src/core/lib/transport/call_factory.cc \ -src/core/lib/transport/call_factory.h \ src/core/lib/transport/call_filters.cc \ src/core/lib/transport/call_filters.h \ src/core/lib/transport/call_final_info.cc \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 92158316837..0b344926cdf 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -2582,8 +2582,6 @@ src/core/lib/transport/batch_builder.cc \ src/core/lib/transport/batch_builder.h \ src/core/lib/transport/bdp_estimator.cc \ src/core/lib/transport/bdp_estimator.h \ -src/core/lib/transport/call_factory.cc \ -src/core/lib/transport/call_factory.h \ src/core/lib/transport/call_filters.cc \ src/core/lib/transport/call_filters.h \ src/core/lib/transport/call_final_info.cc \