From 2794078c487d50110765f072059d8ab17c28ed9a Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 10 Jan 2024 11:17:58 -0800 Subject: [PATCH] [transport] Split metadata_batch into its own target (#35496) (Required recursively splitting some other targets too) Gets us closer to eliminating `grpc_base`, and (more importantly) sets up some pieces of transport to be split out so I can rebuild them in coming months. Closes #35496 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35496 from ctiller:chipchip 5319fb925dc723ab0ed15021abc8a87a2b157c4d PiperOrigin-RevId: 597304996 --- BUILD | 34 ++--- fuzztest/core/transport/chttp2/BUILD | 1 + src/core/BUILD | 126 ++++++++++++++++++ .../lib/compression/compression_internal.cc | 3 - src/cpp/ext/csm/BUILD | 1 + src/cpp/ext/otel/BUILD | 1 + 6 files changed, 146 insertions(+), 20 deletions(-) diff --git a/BUILD b/BUILD index feb7d315176..8bd86c8c5db 100644 --- a/BUILD +++ b/BUILD @@ -1113,6 +1113,7 @@ grpc_cc_library( "//src/core:default_event_engine", "//src/core:iomgr_fwd", "//src/core:iomgr_port", + "//src/core:metadata_batch", "//src/core:notification", "//src/core:slice", "//src/core:slice_refcount", @@ -1294,7 +1295,6 @@ grpc_cc_library( "//src/core:lib/channel/server_call_tracer_filter.cc", "//src/core:lib/channel/status_util.cc", "//src/core:lib/compression/compression.cc", - "//src/core:lib/compression/compression_internal.cc", "//src/core:lib/compression/message_compress.cc", "//src/core:lib/iomgr/call_combiner.cc", "//src/core:lib/iomgr/cfstream_handle.cc", @@ -1376,10 +1376,7 @@ grpc_cc_library( "//src/core:lib/transport/batch_builder.cc", "//src/core:lib/transport/connectivity_state.cc", "//src/core:lib/transport/error_utils.cc", - "//src/core:lib/transport/metadata_batch.cc", - "//src/core:lib/transport/parsed_metadata.cc", "//src/core:lib/transport/status_conversion.cc", - "//src/core:lib/transport/timeout_encoding.cc", "//src/core:lib/transport/transport.cc", "//src/core:lib/transport/transport_op_string.cc", ] + @@ -1402,7 +1399,6 @@ grpc_cc_library( "//src/core:lib/channel/connected_channel.h", "//src/core:lib/channel/promise_based_filter.h", "//src/core:lib/channel/status_util.h", - "//src/core:lib/compression/compression_internal.h", "//src/core:lib/compression/message_compress.h", "//src/core:lib/iomgr/block_annotate.h", "//src/core:lib/iomgr/call_combiner.h", @@ -1466,13 +1462,8 @@ grpc_cc_library( "//src/core:lib/surface/wait_for_cq_end_op.h", "//src/core:lib/transport/batch_builder.h", "//src/core:lib/transport/connectivity_state.h", - "//src/core:lib/transport/custom_metadata.h", "//src/core:lib/transport/error_utils.h", - "//src/core:lib/transport/metadata_batch.h", - "//src/core:lib/transport/parsed_metadata.h", - "//src/core:lib/transport/simple_slice_based_metadata.h", "//src/core:lib/transport/status_conversion.h", - "//src/core:lib/transport/timeout_encoding.h", "//src/core:lib/transport/transport.h", ] + # TODO(vigneshbabu): remove these @@ -1553,8 +1544,8 @@ grpc_cc_library( "//src/core:channel_init", "//src/core:channel_stack_trace", "//src/core:channel_stack_type", - "//src/core:chunked_vector", "//src/core:closure", + "//src/core:compression_internal", "//src/core:construct_destruct", "//src/core:context", "//src/core:default_event_engine", @@ -1574,7 +1565,6 @@ grpc_cc_library( "//src/core:grpc_sockaddr", "//src/core:http2_errors", "//src/core:if", - "//src/core:if_list", "//src/core:init_internally", "//src/core:iomgr_fwd", "//src/core:iomgr_port", @@ -1584,9 +1574,8 @@ grpc_cc_library( "//src/core:loop", "//src/core:map", "//src/core:memory_quota", - "//src/core:metadata_compression_traits", + "//src/core:metadata_batch", "//src/core:no_destruct", - "//src/core:packed_table", "//src/core:per_cpu", "//src/core:pipe", "//src/core:poll", @@ -1596,7 +1585,6 @@ grpc_cc_library( "//src/core:race", "//src/core:random_early_detection", "//src/core:ref_counted", - "//src/core:ref_counted_string", "//src/core:resolved_address", "//src/core:resource_quota", "//src/core:resource_quota_trace", @@ -1615,7 +1603,6 @@ grpc_cc_library( "//src/core:transport_fwd", "//src/core:try_join", "//src/core:try_seq", - "//src/core:type_list", "//src/core:useful", "//src/core:windows_event_engine", "//src/core:windows_event_engine_listener", @@ -1825,6 +1812,7 @@ grpc_cc_library( "//src/core:handshaker_registry", "//src/core:iomgr_fwd", "//src/core:memory_quota", + "//src/core:metadata_batch", "//src/core:poll", "//src/core:ref_counted", "//src/core:resource_quota", @@ -2370,6 +2358,7 @@ grpc_cc_library( "//src/core:context", "//src/core:error", "//src/core:logging_filter", + "//src/core:metadata_batch", "//src/core:slice", "//src/core:slice_buffer", "//src/core:slice_refcount", @@ -3133,6 +3122,7 @@ grpc_cc_library( "//src/core:lb_policy_registry", "//src/core:map", "//src/core:memory_quota", + "//src/core:metadata_batch", "//src/core:pipe", "//src/core:poll", "//src/core:pollset_set", @@ -3383,6 +3373,7 @@ grpc_cc_library( "//src/core:json", "//src/core:json_reader", "//src/core:json_writer", + "//src/core:metadata_batch", "//src/core:slice", "//src/core:slice_refcount", "//src/core:time", @@ -3619,11 +3610,13 @@ grpc_cc_library( "//src/core:channel_args", "//src/core:channel_fwd", "//src/core:channel_stack_type", + "//src/core:compression_internal", "//src/core:context", "//src/core:experiments", "//src/core:grpc_message_size_filter", "//src/core:latch", "//src/core:map", + "//src/core:metadata_batch", "//src/core:percent_encoding", "//src/core:pipe", "//src/core:poll", @@ -3843,12 +3836,13 @@ grpc_cc_library( deps = [ "gpr", "gpr_platform", - "grpc_base", "grpc_trace", "hpack_parse_result", "http_trace", "//src/core:hpack_constants", + "//src/core:metadata_batch", "//src/core:no_destruct", + "//src/core:parsed_metadata", "//src/core:slice", ], ) @@ -3873,6 +3867,7 @@ grpc_cc_library( "ref_counted_ptr", "//src/core:error", "//src/core:hpack_constants", + "//src/core:metadata_batch", "//src/core:ref_counted", "//src/core:slice", "//src/core:status_helper", @@ -3910,6 +3905,8 @@ grpc_cc_library( "//src/core:error", "//src/core:hpack_constants", "//src/core:match", + "//src/core:metadata_batch", + "//src/core:parsed_metadata", "//src/core:random_early_detection", "//src/core:slice", "//src/core:slice_refcount", @@ -3938,10 +3935,12 @@ grpc_cc_library( "http_trace", "//src/core:hpack_constants", "//src/core:hpack_encoder_table", + "//src/core:metadata_batch", "//src/core:metadata_compression_traits", "//src/core:slice", "//src/core:slice_buffer", "//src/core:time", + "//src/core:timeout_encoding", ], ) @@ -4078,6 +4077,7 @@ grpc_cc_library( "//src/core:match", "//src/core:max_concurrent_streams_policy", "//src/core:memory_quota", + "//src/core:metadata_batch", "//src/core:ping_abuse_policy", "//src/core:ping_callbacks", "//src/core:ping_rate_policy", diff --git a/fuzztest/core/transport/chttp2/BUILD b/fuzztest/core/transport/chttp2/BUILD index 02142a7074e..26f224cd1f5 100644 --- a/fuzztest/core/transport/chttp2/BUILD +++ b/fuzztest/core/transport/chttp2/BUILD @@ -41,6 +41,7 @@ grpc_fuzz_test( "//:ref_counted_ptr", "//src/core:arena", "//src/core:memory_quota", + "//src/core:metadata_batch", "//src/core:resource_quota", "//src/core:slice_buffer", "//src/core:time", diff --git a/src/core/BUILD b/src/core/BUILD index 39949b8a25f..b315e12d9a7 100644 --- a/src/core/BUILD +++ b/src/core/BUILD @@ -3075,6 +3075,7 @@ grpc_cc_library( deps = [ "dual_ref_counted", "grpc_service_config", + "metadata_batch", "ref_counted", "service_config_parser", "useful", @@ -3107,6 +3108,7 @@ grpc_cc_library( "context", "grpc_server_config_selector", "grpc_service_config", + "metadata_batch", "status_helper", "//:gpr", "//:grpc_base", @@ -3226,6 +3228,7 @@ grpc_cc_library( "channel_args", "channel_fwd", "dual_ref_counted", + "metadata_batch", "ref_counted", "resolved_address", "slice", @@ -3299,6 +3302,7 @@ grpc_cc_library( "closure", "error", "iomgr_fwd", + "metadata_batch", "slice", "unique_type_name", "useful", @@ -3595,6 +3599,7 @@ grpc_cc_library( language = "c++", deps = [ "arena_promise", + "metadata_batch", "slice", "unique_type_name", "useful", @@ -3633,6 +3638,7 @@ grpc_cc_library( "httpcli_ssl_credentials", "json", "json_reader", + "metadata_batch", "poll", "pollset_set", "ref_counted", @@ -3954,6 +3960,7 @@ grpc_cc_library( "http2_errors", "idle_filter_state", "loop", + "metadata_batch", "no_destruct", "per_cpu", "poll", @@ -3996,6 +4003,7 @@ grpc_cc_library( "closure", "context", "error", + "metadata_batch", "status_helper", "time", "//:channel_arg_names", @@ -4029,6 +4037,7 @@ grpc_cc_library( "channel_args", "channel_fwd", "channel_stack_type", + "metadata_batch", "slice", "//:channel_arg_names", "//:config", @@ -4067,6 +4076,7 @@ grpc_cc_library( "json_args", "json_object_loader", "latch", + "metadata_batch", "race", "service_config_parser", "slice", @@ -4111,6 +4121,7 @@ grpc_cc_library( "json", "json_args", "json_object_loader", + "metadata_batch", "service_config_parser", "sleep", "time", @@ -4156,6 +4167,7 @@ grpc_cc_library( "json", "json_args", "json_object_loader", + "metadata_batch", "service_config_parser", "validation_errors", "//:config", @@ -4195,6 +4207,7 @@ grpc_cc_library( "json_args", "json_object_loader", "map", + "metadata_batch", "pipe", "ref_counted_string", "service_config_parser", @@ -4259,6 +4272,7 @@ grpc_cc_library( "lb_policy_factory", "lb_policy_registry", "map", + "metadata_batch", "pipe", "pollset_set", "ref_counted", @@ -4556,6 +4570,7 @@ grpc_cc_library( "json_writer", "lb_policy_registry", "match", + "metadata_batch", "pollset_set", "protobuf_any_upb", "protobuf_duration_upb", @@ -4653,6 +4668,7 @@ grpc_cc_library( "grpc_xds_client", "iomgr_fwd", "match", + "metadata_batch", "resolved_address", "slice_refcount", "unique_type_name", @@ -5452,6 +5468,7 @@ grpc_cc_library( "channel_stack_type", "context", "grpc_sockaddr", + "metadata_batch", "resolved_address", "seq", "slice", @@ -5495,6 +5512,7 @@ grpc_cc_library( "grpc_backend_metric_data", "grpc_backend_metric_provider", "map", + "metadata_batch", "slice", "//:channel_arg_names", "//:config", @@ -5806,6 +5824,7 @@ grpc_cc_library( "grpc_xds_client", "iomgr_fwd", "match", + "metadata_batch", "pollset_set", "ref_counted", "slice", @@ -6193,6 +6212,7 @@ grpc_cc_library( "error", "experiments", "iomgr_fwd", + "metadata_batch", "slice", "slice_buffer", "status_helper", @@ -6231,6 +6251,7 @@ grpc_cc_library( "chaotic_good_frame_header", "context", "match", + "metadata_batch", "no_destruct", "slice", "slice_buffer", @@ -6342,6 +6363,7 @@ grpc_cc_library( "context", "logging_sink", "map", + "metadata_batch", "pipe", "slice", "slice_buffer", @@ -6446,6 +6468,7 @@ grpc_cc_library( "map", "match", "memory_quota", + "metadata_batch", "mpsc", "pipe", "poll", @@ -6501,6 +6524,7 @@ grpc_cc_library( "inter_activity_pipe", "loop", "memory_quota", + "metadata_batch", "mpsc", "pipe", "poll", @@ -6521,6 +6545,108 @@ grpc_cc_library( ], ) +grpc_cc_library( + name = "parsed_metadata", + srcs = [ + "lib/transport/parsed_metadata.cc", + ], + hdrs = [ + "lib/transport/parsed_metadata.h", + ], + external_deps = [ + "absl/functional:function_ref", + "absl/meta:type_traits", + "absl/strings", + ], + deps = [ + "slice", + "time", + "//:gpr_platform", + ], +) + +grpc_cc_library( + name = "metadata_batch", + srcs = [ + "lib/transport/metadata_batch.cc", + ], + hdrs = [ + "lib/transport/custom_metadata.h", + "lib/transport/metadata_batch.h", + "lib/transport/simple_slice_based_metadata.h", + ], + external_deps = [ + "absl/container:inlined_vector", + "absl/functional:function_ref", + "absl/meta:type_traits", + "absl/strings", + "absl/strings:str_format", + "absl/types:optional", + ], + deps = [ + "arena", + "chunked_vector", + "compression_internal", + "experiments", + "if_list", + "metadata_compression_traits", + "packed_table", + "parsed_metadata", + "poll", + "slice", + "time", + "timeout_encoding", + "type_list", + "//:gpr", + "//:grpc_public_hdrs", + ], +) + +grpc_cc_library( + name = "timeout_encoding", + srcs = [ + "lib/transport/timeout_encoding.cc", + ], + hdrs = [ + "lib/transport/timeout_encoding.h", + ], + external_deps = [ + "absl/base:core_headers", + "absl/types:optional", + ], + deps = [ + "slice", + "time", + "//:gpr", + ], +) + +grpc_cc_library( + name = "compression_internal", + srcs = [ + "lib/compression/compression_internal.cc", + ], + hdrs = [ + "lib/compression/compression_internal.h", + ], + external_deps = [ + "absl/container:inlined_vector", + "absl/strings", + "absl/strings:str_format", + "absl/types:optional", + ], + deps = [ + "bitset", + "channel_args", + "ref_counted_string", + "slice", + "//:gpr", + "//:grpc_public_hdrs", + "//:grpc_trace", + "//:ref_counted_ptr", + ], +) + ### UPB Targets grpc_upb_proto_library( diff --git a/src/core/lib/compression/compression_internal.cc b/src/core/lib/compression/compression_internal.cc index 426909eb8d9..484b101b79e 100644 --- a/src/core/lib/compression/compression_internal.cc +++ b/src/core/lib/compression/compression_internal.cc @@ -36,7 +36,6 @@ #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/ref_counted_string.h" -#include "src/core/lib/surface/api_trace.h" namespace grpc_core { @@ -112,8 +111,6 @@ absl::optional ParseCompressionAlgorithm( grpc_compression_algorithm CompressionAlgorithmSet::CompressionAlgorithmForLevel( grpc_compression_level level) const { - GRPC_API_TRACE("grpc_message_compression_algorithm_for_level(level=%d)", 1, - ((int)level)); if (level > GRPC_COMPRESS_LEVEL_HIGH) { Crash(absl::StrFormat("Unknown message compression level %d.", static_cast(level))); diff --git a/src/cpp/ext/csm/BUILD b/src/cpp/ext/csm/BUILD index 30b83b8e456..63533a40518 100644 --- a/src/cpp/ext/csm/BUILD +++ b/src/cpp/ext/csm/BUILD @@ -66,6 +66,7 @@ grpc_cc_library( "//src/core:json_args", "//src/core:json_object_loader", "//src/core:json_reader", + "//src/core:metadata_batch", "//src/core:slice", "//src/core:xds_enabled_server", "//src/cpp/ext/otel:otel_plugin", diff --git a/src/cpp/ext/otel/BUILD b/src/cpp/ext/otel/BUILD index 315fc5b270c..b877af9ff15 100644 --- a/src/cpp/ext/otel/BUILD +++ b/src/cpp/ext/otel/BUILD @@ -75,6 +75,7 @@ grpc_cc_library( "//src/core:channel_stack_type", "//src/core:context", "//src/core:error", + "//src/core:metadata_batch", "//src/core:slice", "//src/core:slice_buffer", ],