From 8b8f43aecf839f5bcca43252b0440449274a9ff3 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 1 Apr 2024 11:21:09 -0700 Subject: [PATCH] [metadata] Remove arena from `grpc_metadata_batch` constructor (#36118) Internally, use `std::vector` instead of `ChunkedVector` to hold extra metadatum. I'm not totally convinced this is the right move, so it's going to be a try it and monitor for a month or so thing... I might roll back if performance is actually affected (but I think we'll see some wins and losses and overall about a wash). Closes #36118 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36118 from ctiller:YUPYUPYUP 68e0acd0a28c357ee039778f1870f08dfca79787 PiperOrigin-RevId: 620902195 --- .../chttp2/hpack_encoder_timeout_test.cc | 14 ++-- .../client_channel/client_channel_filter.cc | 2 +- .../retry_filter_legacy_call_data.h | 12 ++-- .../subchannel_stream_client.cc | 6 +- .../filters/http/server/http_server_filter.cc | 2 +- .../message_size/message_size_filter.cc | 2 +- .../client/chaotic_good_connector.cc | 4 +- src/core/ext/transport/chaotic_good/frame.cc | 2 +- .../server/chaotic_good_server.cc | 4 +- .../chaotic_good/settings_metadata.cc | 5 +- .../chaotic_good/settings_metadata.h | 2 +- .../chttp2/transport/chttp2_transport.cc | 9 +-- .../ext/transport/chttp2/transport/internal.h | 2 +- .../cronet/transport/cronet_transport.cc | 8 +-- .../inproc/legacy_inproc_transport.cc | 14 ++-- src/core/lib/channel/connected_channel.cc | 13 ++-- src/core/lib/surface/call.cc | 21 +++--- src/core/lib/transport/batch_builder.h | 6 +- src/core/lib/transport/metadata.cc | 2 +- src/core/lib/transport/metadata_batch.cc | 11 ++-- src/core/lib/transport/metadata_batch.h | 19 ++---- test/core/filters/filter_test.cc | 4 +- test/core/promise/try_seq_metadata_test.cc | 15 ++--- test/core/security/credentials_test.cc | 2 +- test/core/security/oauth2_utils.cc | 2 +- .../transport/binder/binder_transport_test.cc | 8 +-- test/core/transport/call_filters_test.cc | 65 +++++++++---------- .../client_transport_error_test.cc | 3 +- .../chaotic_good/client_transport_test.cc | 3 +- .../chaotic_good/server_transport_test.cc | 6 +- .../transport/chttp2/hpack_encoder_test.cc | 8 +-- .../chttp2/hpack_parser_fuzzer_test.cc | 2 +- .../chttp2/hpack_parser_input_size_fuzzer.cc | 2 +- .../transport/chttp2/hpack_parser_test.cc | 2 +- .../transport/chttp2/hpack_sync_fuzzer.cc | 2 +- test/core/transport/metadata_map_test.cc | 12 ++-- .../core/transport/test_suite/call_content.cc | 6 +- test/core/transport/test_suite/call_shapes.cc | 48 +++++++------- test/core/transport/test_suite/stress.cc | 6 +- test/core/util/evaluate_args_test_util.h | 3 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 10 +-- .../microbenchmarks/bm_chttp2_transport.cc | 2 +- 42 files changed, 160 insertions(+), 211 deletions(-) diff --git a/fuzztest/core/transport/chttp2/hpack_encoder_timeout_test.cc b/fuzztest/core/transport/chttp2/hpack_encoder_timeout_test.cc index 37a686c8b7b..6ab0dfadb10 100644 --- a/fuzztest/core/transport/chttp2/hpack_encoder_timeout_test.cc +++ b/fuzztest/core/transport/chttp2/hpack_encoder_timeout_test.cc @@ -14,23 +14,20 @@ // Test to verify Fuzztest integration -#include #include #include -#include + #include #include +#include #include "absl/random/random.h" #include "fuzztest/fuzztest.h" #include "gtest/gtest.h" + #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/memory_quota.h" -#include "src/core/lib/resource_quota/resource_quota.h" -#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/gprpp/time.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice_buffer.h" #include "src/core/lib/transport/metadata_batch.h" @@ -43,9 +40,6 @@ void EncodeTimeouts(std::vector timeouts) { hpack_encoder_detail::TimeoutCompressorImpl timeout_compressor; HPackCompressor compressor; HPackParser parser; - MemoryAllocator memory_allocator = MemoryAllocator( - ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test")); - auto arena = MakeScopedArena(1024, &memory_allocator); for (size_t i = 0; i < timeouts.size(); i++) { SliceBuffer encoded; hpack_encoder_detail::Encoder encoder(&compressor, false, encoded); @@ -53,7 +47,7 @@ void EncodeTimeouts(std::vector timeouts) { "grpc-timeout", Timestamp::ProcessEpoch() + Duration::Milliseconds(timeouts[i]), &encoder); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; const uint32_t kMetadataSizeLimit = 3u * 1024 * 1024 * 1024; parser.BeginFrame( &b, kMetadataSizeLimit, kMetadataSizeLimit, HPackParser::Boundary::None, diff --git a/src/core/client_channel/client_channel_filter.cc b/src/core/client_channel/client_channel_filter.cc index eb1ec52a343..1c6432e94a6 100644 --- a/src/core/client_channel/client_channel_filter.cc +++ b/src/core/client_channel/client_channel_filter.cc @@ -3535,7 +3535,7 @@ ClientChannelFilter::PromiseBasedLoadBalancedCall::MakeCallPromise( [this]() { // TODO(roth): Change CallTracer API to not pass metadata // batch to this method, since the batch is always empty. - grpc_metadata_batch metadata(GetContext()); + grpc_metadata_batch metadata; call_attempt_tracer()->RecordSendTrailingMetadata(&metadata); }); } diff --git a/src/core/client_channel/retry_filter_legacy_call_data.h b/src/core/client_channel/retry_filter_legacy_call_data.h index 8d45393f48b..1ce4dc11b29 100644 --- a/src/core/client_channel/retry_filter_legacy_call_data.h +++ b/src/core/client_channel/retry_filter_legacy_call_data.h @@ -266,11 +266,11 @@ class RetryFilter::LegacyCallData { // BatchData.batch.payload points to this. grpc_transport_stream_op_batch_payload batch_payload_; // For send_initial_metadata. - grpc_metadata_batch send_initial_metadata_{calld_->arena_}; + grpc_metadata_batch send_initial_metadata_; // For send_trailing_metadata. - grpc_metadata_batch send_trailing_metadata_{calld_->arena_}; + grpc_metadata_batch send_trailing_metadata_; // For intercepting recv_initial_metadata. - grpc_metadata_batch recv_initial_metadata_{calld_->arena_}; + grpc_metadata_batch recv_initial_metadata_; grpc_closure recv_initial_metadata_ready_; bool trailing_metadata_available_ = false; // For intercepting recv_message. @@ -278,7 +278,7 @@ class RetryFilter::LegacyCallData { absl::optional recv_message_; uint32_t recv_message_flags_; // For intercepting recv_trailing_metadata. - grpc_metadata_batch recv_trailing_metadata_{calld_->arena_}; + grpc_metadata_batch recv_trailing_metadata_; grpc_transport_stream_stats collect_stats_; grpc_closure recv_trailing_metadata_ready_; // These fields indicate which ops have been started and completed on @@ -420,7 +420,7 @@ class RetryFilter::LegacyCallData { // Cached data for retrying send ops. // send_initial_metadata bool seen_send_initial_metadata_ = false; - grpc_metadata_batch send_initial_metadata_{arena_}; + grpc_metadata_batch send_initial_metadata_; // send_message // When we get a send_message op, we replace the original byte stream // with a CachingByteStream that caches the slices to a local buffer for @@ -435,7 +435,7 @@ class RetryFilter::LegacyCallData { absl::InlinedVector send_messages_; // send_trailing_metadata bool seen_send_trailing_metadata_ = false; - grpc_metadata_batch send_trailing_metadata_{arena_}; + grpc_metadata_batch send_trailing_metadata_; }; } // namespace grpc_core diff --git a/src/core/client_channel/subchannel_stream_client.cc b/src/core/client_channel/subchannel_stream_client.cc index 57b9cbbc483..34c5d2c6bb9 100644 --- a/src/core/client_channel/subchannel_stream_client.cc +++ b/src/core/client_channel/subchannel_stream_client.cc @@ -172,11 +172,7 @@ SubchannelStreamClient::CallState::CallState( arena_(Arena::Create(subchannel_stream_client_->connected_subchannel_ ->GetInitialCallSizeEstimate(), &subchannel_stream_client_->call_allocator_)), - payload_(context_), - send_initial_metadata_(arena_.get()), - send_trailing_metadata_(arena_.get()), - recv_initial_metadata_(arena_.get()), - recv_trailing_metadata_(arena_.get()) {} + payload_(context_) {} SubchannelStreamClient::CallState::~CallState() { if (GPR_UNLIKELY(subchannel_stream_client_->tracer_ != nullptr)) { diff --git a/src/core/ext/filters/http/server/http_server_filter.cc b/src/core/ext/filters/http/server/http_server_filter.cc index 9769e6de89c..775eebcb1d3 100644 --- a/src/core/ext/filters/http/server/http_server_filter.cc +++ b/src/core/ext/filters/http/server/http_server_filter.cc @@ -67,7 +67,7 @@ void FilterOutgoingMetadata(ServerMetadata* md) { ServerMetadataHandle MalformedRequest(absl::string_view explanation) { auto* arena = GetContext(); - auto hdl = arena->MakePooled(arena); + auto hdl = arena->MakePooled(); hdl->Set(GrpcStatusMetadata(), GRPC_STATUS_UNKNOWN); hdl->Set(GrpcMessageMetadata(), Slice::FromStaticString(explanation)); hdl->Set(GrpcTarPit(), Empty()); diff --git a/src/core/ext/filters/message_size/message_size_filter.cc b/src/core/ext/filters/message_size/message_size_filter.cc index df1b4b53306..252bb1a46cb 100644 --- a/src/core/ext/filters/message_size/message_size_filter.cc +++ b/src/core/ext/filters/message_size/message_size_filter.cc @@ -168,7 +168,7 @@ ServerMetadataHandle CheckPayload(const Message& msg, is_send ? "send" : "recv", msg.payload()->Length(), *max_length); } if (msg.payload()->Length() <= *max_length) return nullptr; - auto r = GetContext()->MakePooled(GetContext()); + auto r = GetContext()->MakePooled(); r->Set(GrpcStatusMetadata(), GRPC_STATUS_RESOURCE_EXHAUSTED); r->Set(GrpcMessageMetadata(), Slice::FromCopiedString(absl::StrFormat( diff --git a/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc b/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc index 7f3d85e4530..0eb354e5e6c 100644 --- a/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc +++ b/src/core/ext/transport/chaotic_good/client/chaotic_good_connector.cc @@ -113,7 +113,7 @@ auto ChaoticGoodConnector::DataEndpointWriteSettingsFrame( // frame.header set connectiion_type: control frame.headers = SettingsMetadata{SettingsMetadata::ConnectionType::kData, self->connection_id_, kDataAlignmentBytes} - .ToMetadataBatch(GetContext()); + .ToMetadataBatch(); auto write_buffer = frame.Serialize(&self->hpack_compressor_); return self->data_endpoint_.Write(std::move(write_buffer.control)); } @@ -214,7 +214,7 @@ auto ChaoticGoodConnector::ControlEndpointWriteSettingsFrame( // frame.header set connectiion_type: control frame.headers = SettingsMetadata{SettingsMetadata::ConnectionType::kControl, absl::nullopt, absl::nullopt} - .ToMetadataBatch(GetContext()); + .ToMetadataBatch(); auto write_buffer = frame.Serialize(&self->hpack_compressor_); return self->control_endpoint_.Write(std::move(write_buffer.control)); } diff --git a/src/core/ext/transport/chaotic_good/frame.cc b/src/core/ext/transport/chaotic_good/frame.cc index fc7479e69bf..eca4a02a419 100644 --- a/src/core/ext/transport/chaotic_good/frame.cc +++ b/src/core/ext/transport/chaotic_good/frame.cc @@ -154,7 +154,7 @@ absl::StatusOr> ReadMetadata( if (!maybe_slices.ok()) return maybe_slices.status(); auto& slices = *maybe_slices; GPR_ASSERT(arena != nullptr); - Arena::PoolPtr metadata = Arena::MakePooled(arena); + Arena::PoolPtr metadata = Arena::MakePooled(); parser->BeginFrame( metadata.get(), std::numeric_limits::max(), std::numeric_limits::max(), diff --git a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc index 65912c07b82..8c172bd87ef 100644 --- a/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc +++ b/src/core/ext/transport/chaotic_good/server/chaotic_good_server.cc @@ -339,7 +339,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState:: frame.headers = SettingsMetadata{absl::nullopt, self->connection_->connection_id_, absl::nullopt} - .ToMetadataBatch(GetContext()); + .ToMetadataBatch(); auto write_buffer = frame.Serialize(&self->connection_->hpack_compressor_); return TrySeq( self->connection_->endpoint_.Write(std::move(write_buffer.control)), @@ -353,7 +353,7 @@ auto ChaoticGoodServerListener::ActiveConnection::HandshakingState:: frame.headers = SettingsMetadata{absl::nullopt, self->connection_->connection_id_, self->connection_->data_alignment_} - .ToMetadataBatch(GetContext()); + .ToMetadataBatch(); auto write_buffer = frame.Serialize(&self->connection_->hpack_compressor_); return TrySeq( self->connection_->endpoint_.Write(std::move(write_buffer.control)), diff --git a/src/core/ext/transport/chaotic_good/settings_metadata.cc b/src/core/ext/transport/chaotic_good/settings_metadata.cc index 6ce80294a96..af2e648c7fb 100644 --- a/src/core/ext/transport/chaotic_good/settings_metadata.cc +++ b/src/core/ext/transport/chaotic_good/settings_metadata.cc @@ -23,9 +23,8 @@ namespace grpc_core { namespace chaotic_good { -Arena::PoolPtr SettingsMetadata::ToMetadataBatch( - Arena* arena) { - auto md = Arena::MakePooled(arena); +Arena::PoolPtr SettingsMetadata::ToMetadataBatch() { + auto md = Arena::MakePooled(); auto add = [&md](absl::string_view key, std::string value) { md->Append(key, Slice::FromCopiedString(value), [key, value](absl::string_view error, const Slice&) { diff --git a/src/core/ext/transport/chaotic_good/settings_metadata.h b/src/core/ext/transport/chaotic_good/settings_metadata.h index c038cbd93f2..f092e6c265d 100644 --- a/src/core/ext/transport/chaotic_good/settings_metadata.h +++ b/src/core/ext/transport/chaotic_good/settings_metadata.h @@ -35,7 +35,7 @@ struct SettingsMetadata { absl::optional connection_id; absl::optional alignment; - Arena::PoolPtr ToMetadataBatch(Arena* arena); + Arena::PoolPtr ToMetadataBatch(); static absl::StatusOr FromMetadataBatch( const grpc_metadata_batch& batch); }; diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc index 8eb8501378c..a1e490e44b6 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.cc @@ -790,8 +790,7 @@ void grpc_chttp2_stream_unref(grpc_chttp2_stream* s) { grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_stream_refcount* refcount, - const void* server_data, - grpc_core::Arena* arena) + const void* server_data) : t(t->Ref()), refcount([refcount]() { // We reserve one 'active stream' that's dropped when the stream is @@ -805,8 +804,6 @@ grpc_chttp2_stream::grpc_chttp2_stream(grpc_chttp2_transport* t, #endif return refcount; }()), - initial_metadata_buffer(arena), - trailing_metadata_buffer(arena), flow_control(&t->flow_control) { t->streams_allocated.fetch_add(1, std::memory_order_relaxed); if (server_data) { @@ -864,8 +861,8 @@ grpc_chttp2_stream::~grpc_chttp2_stream() { void grpc_chttp2_transport::InitStream(grpc_stream* gs, grpc_stream_refcount* refcount, const void* server_data, - grpc_core::Arena* arena) { - new (gs) grpc_chttp2_stream(this, refcount, server_data, arena); + grpc_core::Arena*) { + new (gs) grpc_chttp2_stream(this, refcount, server_data); } static void destroy_stream_locked(void* sp, grpc_error_handle /*error*/) { diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 94976850645..250de698f4c 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -546,7 +546,7 @@ typedef enum { struct grpc_chttp2_stream { grpc_chttp2_stream(grpc_chttp2_transport* t, grpc_stream_refcount* refcount, - const void* server_data, grpc_core::Arena* arena); + const void* server_data); ~grpc_chttp2_stream(); void* context = nullptr; diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.cc b/src/core/ext/transport/cronet/transport/cronet_transport.cc index aaf9cacef30..6a2678bcc2c 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.cc +++ b/src/core/ext/transport/cronet/transport/cronet_transport.cc @@ -154,9 +154,6 @@ typedef struct grpc_cronet_transport grpc_cronet_transport; // TODO (makdharma): reorder structure for memory efficiency per // http://www.catb.org/esr/structure-packing/#_structure_reordering: struct read_state { - explicit read_state(grpc_core::Arena* arena) - : trailing_metadata(arena), initial_metadata(arena) {} - // vars to store data coming from server char* read_buffer = nullptr; bool length_field_received = false; @@ -185,8 +182,6 @@ struct write_state { // track state of one stream op struct op_state { - explicit op_state(grpc_core::Arena* arena) : rs(arena) {} - bool state_op_done[OP_NUM_OPS] = {}; bool state_callback_received[OP_NUM_OPS] = {}; // A non-zero gRPC status code has been seen @@ -352,7 +347,7 @@ static grpc_error_handle make_error_with_desc(int error_code, inline op_and_state::op_and_state(stream_obj* s, const grpc_transport_stream_op_batch& op) - : op(op), state(s->arena), s(s) {} + : op(op), s(s) {} // // Add a new stream op to op storage. @@ -1412,7 +1407,6 @@ inline stream_obj::stream_obj(grpc_core::Transport* gt, grpc_stream* gs, : arena(arena), curr_ct(reinterpret_cast(gt)), curr_gs(gs), - state(arena), refcount(refcount) { GRPC_CRONET_STREAM_REF(this, "cronet transport"); gpr_mu_init(&mu); diff --git a/src/core/ext/transport/inproc/legacy_inproc_transport.cc b/src/core/ext/transport/inproc/legacy_inproc_transport.cc index b560146daf6..6373d77b35c 100644 --- a/src/core/ext/transport/inproc/legacy_inproc_transport.cc +++ b/src/core/ext/transport/inproc/legacy_inproc_transport.cc @@ -268,18 +268,18 @@ struct inproc_stream { grpc_stream_refcount* refs; grpc_core::Arena* arena; - grpc_metadata_batch to_read_initial_md{arena}; + grpc_metadata_batch to_read_initial_md; bool to_read_initial_md_filled = false; - grpc_metadata_batch to_read_trailing_md{arena}; + grpc_metadata_batch to_read_trailing_md; bool to_read_trailing_md_filled = false; bool ops_needed = false; // Write buffer used only during gap at init time when client-side // stream is set up but server side stream is not yet set up - grpc_metadata_batch write_buffer_initial_md{arena}; + grpc_metadata_batch write_buffer_initial_md; bool write_buffer_initial_md_filled = false; grpc_core::Timestamp write_buffer_deadline = grpc_core::Timestamp::InfFuture(); - grpc_metadata_batch write_buffer_trailing_md{arena}; + grpc_metadata_batch write_buffer_trailing_md; bool write_buffer_trailing_md_filled = false; grpc_error_handle write_buffer_cancel_error; @@ -457,7 +457,7 @@ void fail_helper_locked(inproc_stream* s, grpc_error_handle error) { // Send trailing md to the other side indicating cancellation s->trailing_md_sent = true; - grpc_metadata_batch fake_md(s->arena); + grpc_metadata_batch fake_md; inproc_stream* other = s->other_side; grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md @@ -480,7 +480,7 @@ void fail_helper_locked(inproc_stream* s, grpc_error_handle error) { if (!s->t->is_client) { // If this is a server, provide initial metadata with a path and // authority since it expects that as well as no error yet - grpc_metadata_batch fake_md(s->arena); + grpc_metadata_batch fake_md; fake_md.Set(grpc_core::HttpPathMetadata(), grpc_core::Slice::FromStaticString("/")); fake_md.Set(grpc_core::HttpAuthorityMetadata(), @@ -903,7 +903,7 @@ bool cancel_stream_locked(inproc_stream* s, grpc_error_handle error) { // already have s->trailing_md_sent = true; - grpc_metadata_batch cancel_md(s->arena); + grpc_metadata_batch cancel_md; grpc_metadata_batch* dest = (other == nullptr) ? &s->write_buffer_trailing_md diff --git a/src/core/lib/channel/connected_channel.cc b/src/core/lib/channel/connected_channel.cc index 2e0689bd54f..4955d8eeef3 100644 --- a/src/core/lib/channel/connected_channel.cc +++ b/src/core/lib/channel/connected_channel.cc @@ -465,7 +465,7 @@ ArenaPromise MakeClientCallPromise(Transport* transport, // Start a promise to receive server initial metadata and then forward it up // through the receiving pipe. auto server_initial_metadata = - GetContext()->MakePooled(GetContext()); + GetContext()->MakePooled(); party->Spawn( "recv_initial_metadata", TrySeq(GetContext()->ReceiveServerInitialMetadata( @@ -503,15 +503,14 @@ ArenaPromise MakeClientCallPromise(Transport* transport, // If this fails, we massage the error into metadata that we can report // upwards. auto server_trailing_metadata = - GetContext()->MakePooled(GetContext()); + GetContext()->MakePooled(); auto recv_trailing_metadata = Map(GetContext()->ReceiveServerTrailingMetadata( stream->batch_target()), [](absl::StatusOr status) mutable { if (!status.ok()) { auto server_trailing_metadata = - GetContext()->MakePooled( - GetContext()); + GetContext()->MakePooled(); grpc_status_code status_code = GRPC_STATUS_UNKNOWN; std::string message; grpc_error_get_status(status.status(), Timestamp::InfFuture(), @@ -787,8 +786,7 @@ ArenaPromise MakeServerCallPromise( trailing_metadata = std::move(*status); } else { trailing_metadata = - GetContext()->MakePooled( - GetContext()); + GetContext()->MakePooled(); grpc_status_code status_code = GRPC_STATUS_UNKNOWN; std::string message; grpc_error_get_status(status.status(), Timestamp::InfFuture(), @@ -898,8 +896,7 @@ ArenaPromise MakeClientTransportCallPromise( md->Set(GrpcStatusFromWire(), true); return md; } - auto m = GetContext()->MakePooled( - GetContext()); + auto m = GetContext()->MakePooled(); m->Set(GrpcStatusMetadata(), GRPC_STATUS_CANCELLED); m->Set(GrpcCallWasCancelled(), true); return m; diff --git a/src/core/lib/surface/call.cc b/src/core/lib/surface/call.cc index e0dfe8e38b9..5ef037e2dcb 100644 --- a/src/core/lib/surface/call.cc +++ b/src/core/lib/surface/call.cc @@ -722,10 +722,10 @@ class FilterStackCall final : public Call { grpc_transport_stream_op_batch_payload stream_op_payload_; // first idx: is_receiving, second idx: is_trailing - grpc_metadata_batch send_initial_metadata_{arena()}; - grpc_metadata_batch send_trailing_metadata_{arena()}; - grpc_metadata_batch recv_initial_metadata_{arena()}; - grpc_metadata_batch recv_trailing_metadata_{arena()}; + grpc_metadata_batch send_initial_metadata_; + grpc_metadata_batch send_trailing_metadata_; + grpc_metadata_batch recv_initial_metadata_; + grpc_metadata_batch recv_trailing_metadata_; // Buffered read metadata waiting to be returned to the application. // Element 0 is initial metadata, element 1 is trailing metadata. @@ -2740,8 +2740,7 @@ class ClientPromiseBasedCall final : public PromiseBasedCall { ScopedContext context(this); args->channel->channel_stack()->stats_plugin_group->AddClientCallTracers( *args->path, args->registered_method, this->context()); - send_initial_metadata_ = - GetContext()->MakePooled(GetContext()); + send_initial_metadata_ = GetContext()->MakePooled(); send_initial_metadata_->Set(HttpPathMetadata(), std::move(*args->path)); if (args->authority.has_value()) { send_initial_metadata_->Set(HttpAuthorityMetadata(), @@ -3147,7 +3146,7 @@ void ClientPromiseBasedCall::StartRecvInitialMetadata( is_trailers_only_ = metadata->get(GrpcTrailersOnly()).value_or(false); } else { is_trailers_only_ = true; - metadata = arena()->MakePooled(arena()); + metadata = arena()->MakePooled(); } ProcessIncomingInitialMetadata(*metadata); PublishMetadataArray(metadata.get(), array, true); @@ -3524,7 +3523,7 @@ void ServerPromiseBasedCall::CommitBatch(const grpc_op* ops, size_t nops, const grpc_op& op = ops[op_idx]; switch (op.op) { case GRPC_OP_SEND_INITIAL_METADATA: { - auto metadata = arena()->MakePooled(arena()); + auto metadata = arena()->MakePooled(); PrepareOutgoingInitialMetadata(op, *metadata); CToMetadata(op.data.send_initial_metadata.metadata, op.data.send_initial_metadata.count, metadata.get()); @@ -3564,7 +3563,7 @@ void ServerPromiseBasedCall::CommitBatch(const grpc_op* ops, size_t nops, client_to_server_messages_, true, spawner); break; case GRPC_OP_SEND_STATUS_FROM_SERVER: { - auto metadata = arena()->MakePooled(arena()); + auto metadata = arena()->MakePooled(); CToMetadata(op.data.send_status_from_server.trailing_metadata, op.data.send_status_from_server.trailing_metadata_count, metadata.get()); @@ -4037,7 +4036,7 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, if (!is_notify_tag_closure) grpc_cq_begin_op(cq(), notify_tag); auto send_initial_metadata = MaybeOp( ops, got_ops[GRPC_OP_SEND_INITIAL_METADATA], [this](const grpc_op& op) { - auto metadata = arena()->MakePooled(arena()); + auto metadata = arena()->MakePooled(); PrepareOutgoingInitialMetadata(op, *metadata); CToMetadata(op.data.send_initial_metadata.metadata, op.data.send_initial_metadata.count, metadata.get()); @@ -4067,7 +4066,7 @@ void ServerCallSpine::CommitBatch(const grpc_op* ops, size_t nops, }); auto send_trailing_metadata = MaybeOp( ops, got_ops[GRPC_OP_SEND_STATUS_FROM_SERVER], [this](const grpc_op& op) { - auto metadata = arena()->MakePooled(arena()); + auto metadata = arena()->MakePooled(); CToMetadata(op.data.send_status_from_server.trailing_metadata, op.data.send_status_from_server.trailing_metadata_count, metadata.get()); diff --git a/src/core/lib/transport/batch_builder.h b/src/core/lib/transport/batch_builder.h index 427de2305c1..c4bf8cae105 100644 --- a/src/core/lib/transport/batch_builder.h +++ b/src/core/lib/transport/batch_builder.h @@ -162,8 +162,7 @@ class BatchBuilder { using PendingCompletion::PendingCompletion; Arena::PoolPtr metadata = - GetContext()->MakePooled( - GetContext()); + GetContext()->MakePooled(); protected: ~PendingReceiveMetadata() = default; @@ -330,8 +329,7 @@ inline auto BatchBuilder::SendClientTrailingMetadata(Target target) { auto* pc = batch->GetInitializedCompletion(&Batch::pending_sends); batch->batch.on_complete = &pc->on_done_closure; batch->batch.send_trailing_metadata = true; - auto metadata = - GetContext()->MakePooled(GetContext()); + auto metadata = GetContext()->MakePooled(); payload_->send_trailing_metadata.send_trailing_metadata = metadata.get(); payload_->send_trailing_metadata.sent = nullptr; pc->send_trailing_metadata = std::move(metadata); diff --git a/src/core/lib/transport/metadata.cc b/src/core/lib/transport/metadata.cc index cffb522bd39..1a77cb81a89 100644 --- a/src/core/lib/transport/metadata.cc +++ b/src/core/lib/transport/metadata.cc @@ -22,7 +22,7 @@ namespace grpc_core { ServerMetadataHandle ServerMetadataFromStatus(const absl::Status& status, Arena* arena) { - auto hdl = arena->MakePooled(arena); + auto hdl = arena->MakePooled(); grpc_status_code code; std::string message; grpc_error_get_status(status, Timestamp::InfFuture(), &code, &message, diff --git a/src/core/lib/transport/metadata_batch.cc b/src/core/lib/transport/metadata_batch.cc index 0fdbe5171d7..3edc9dc7c42 100644 --- a/src/core/lib/transport/metadata_batch.cc +++ b/src/core/lib/transport/metadata_batch.cc @@ -96,14 +96,15 @@ bool DebugStringBuilder::IsAllowListed(const absl::string_view key) const { } void UnknownMap::Append(absl::string_view key, Slice value) { - unknown_.EmplaceBack(Slice::FromCopiedString(key), value.Ref()); + unknown_.emplace_back(Slice::FromCopiedString(key), value.Ref()); } void UnknownMap::Remove(absl::string_view key) { - unknown_.SetEnd(std::remove_if(unknown_.begin(), unknown_.end(), - [key](const std::pair& p) { - return p.first.as_string_view() == key; - })); + unknown_.erase(std::remove_if(unknown_.begin(), unknown_.end(), + [key](const std::pair& p) { + return p.first.as_string_view() == key; + }), + unknown_.end()); } absl::optional UnknownMap::GetStringValue( diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index a5634b3a66d..b05c8d188fe 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -47,7 +47,6 @@ #include "src/core/lib/gprpp/time.h" #include "src/core/lib/gprpp/type_list.h" #include "src/core/lib/promise/poll.h" -#include "src/core/lib/resource_quota/arena.h" #include "src/core/lib/slice/slice.h" #include "src/core/lib/transport/custom_metadata.h" #include "src/core/lib/transport/metadata_compression_traits.h" @@ -1051,22 +1050,19 @@ class TransportSizeEncoder { // Handle unknown (non-trait-based) fields in the metadata map. class UnknownMap { public: - explicit UnknownMap(Arena* arena) : unknown_(arena) {} - - using BackingType = ChunkedVector, 5>; + using BackingType = std::vector>; void Append(absl::string_view key, Slice value); void Remove(absl::string_view key); absl::optional GetStringValue(absl::string_view key, std::string* backing) const; - BackingType::ConstForwardIterator begin() const { return unknown_.cbegin(); } - BackingType::ConstForwardIterator end() const { return unknown_.cend(); } + BackingType::const_iterator begin() const { return unknown_.cbegin(); } + BackingType::const_iterator end() const { return unknown_.cend(); } bool empty() const { return unknown_.empty(); } size_t size() const { return unknown_.size(); } - void Clear() { unknown_.Clear(); } - Arena* arena() const { return unknown_.arena(); } + void Clear() { unknown_.clear(); } private: // Backing store for added metadata. @@ -1223,7 +1219,7 @@ MetadataValueAsSlice(typename Which::ValueType value) { template class MetadataMap { public: - explicit MetadataMap(Arena* arena); + MetadataMap() = default; ~MetadataMap(); // Given a compressor factory - template taking & m) { GRPC_STATUS_OK; } -template -MetadataMap::MetadataMap(Arena* arena) : unknown_(arena) {} - template MetadataMap::MetadataMap(MetadataMap&& other) noexcept : table_(std::move(other.table_)), unknown_(std::move(other.unknown_)) {} @@ -1482,7 +1475,7 @@ size_t MetadataMap::TransportSize() const { template Derived MetadataMap::Copy() const { - Derived out(unknown_.arena()); + Derived out; metadata_detail::CopySink sink(&out); ForEach(&sink); return out; diff --git a/test/core/filters/filter_test.cc b/test/core/filters/filter_test.cc index 9089933336c..d3178163c33 100644 --- a/test/core/filters/filter_test.cc +++ b/test/core/filters/filter_test.cc @@ -354,7 +354,7 @@ Arena* FilterTestBase::Call::arena() { return impl_->arena(); } ClientMetadataHandle FilterTestBase::Call::NewClientMetadata( std::initializer_list> init) { - auto md = impl_->arena()->MakePooled(impl_->arena()); + auto md = impl_->arena()->MakePooled(); for (auto& p : init) { auto parsed = ClientMetadata::Parse( p.first, Slice::FromCopiedString(p.second), false, @@ -371,7 +371,7 @@ ClientMetadataHandle FilterTestBase::Call::NewClientMetadata( ServerMetadataHandle FilterTestBase::Call::NewServerMetadata( std::initializer_list> init) { - auto md = impl_->arena()->MakePooled(impl_->arena()); + auto md = impl_->arena()->MakePooled(); for (auto& p : init) { auto parsed = ServerMetadata::Parse( p.first, Slice::FromCopiedString(p.second), false, diff --git a/test/core/promise/try_seq_metadata_test.cc b/test/core/promise/try_seq_metadata_test.cc index dc0fb8ca92e..34c74a83211 100644 --- a/test/core/promise/try_seq_metadata_test.cc +++ b/test/core/promise/try_seq_metadata_test.cc @@ -19,12 +19,8 @@ #include #include -#include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/promise/poll.h" #include "src/core/lib/promise/try_seq.h" -#include "src/core/lib/resource_quota/arena.h" -#include "src/core/lib/resource_quota/memory_quota.h" -#include "src/core/lib/resource_quota/resource_quota.h" #include "src/core/lib/transport/metadata_batch.h" namespace grpc_core { @@ -34,17 +30,14 @@ struct TestMap : public MetadataMap { }; TEST(PromiseTest, SucceedAndThenFail) { - MemoryAllocator memory_allocator = MemoryAllocator( - ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test")); - auto arena = MakeScopedArena(1024, &memory_allocator); Poll r = TrySeq( - [&arena] { - TestMap m(arena.get()); + [] { + TestMap m; m.Set(GrpcStatusMetadata(), GRPC_STATUS_OK); return m; }, - [&arena]() { - TestMap m(arena.get()); + []() { + TestMap m; m.Set(GrpcStatusMetadata(), GRPC_STATUS_UNAVAILABLE); return m; })(); diff --git a/test/core/security/credentials_test.cc b/test/core/security/credentials_test.cc index a349c9a9778..c73336dbca4 100644 --- a/test/core/security/credentials_test.cc +++ b/test/core/security/credentials_test.cc @@ -519,7 +519,7 @@ class RequestMetadataState : public RefCounted { MemoryAllocator memory_allocator_ = MemoryAllocator( ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator("test")); ScopedArenaPtr arena_ = MakeScopedArena(1024, &memory_allocator_); - grpc_metadata_batch md_{arena_.get()}; + grpc_metadata_batch md_; grpc_call_credentials::GetRequestMetadataArgs get_request_metadata_args_; grpc_polling_entity pollent_; ActivityPtr activity_; diff --git a/test/core/security/oauth2_utils.cc b/test/core/security/oauth2_utils.cc index 35fce7a6147..956783d2ff3 100644 --- a/test/core/security/oauth2_utils.cc +++ b/test/core/security/oauth2_utils.cc @@ -54,7 +54,7 @@ char* grpc_test_fetch_oauth2_token_with_credentials( ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch initial_metadata{arena.get()}; + grpc_metadata_batch initial_metadata; char* token = nullptr; auto activity = grpc_core::MakeActivity( diff --git a/test/core/transport/binder/binder_transport_test.cc b/test/core/transport/binder/binder_transport_test.cc index 6533fd7659c..f4376b75d13 100644 --- a/test/core/transport/binder/binder_transport_test.cc +++ b/test/core/transport/binder/binder_transport_test.cc @@ -240,7 +240,7 @@ struct MakeSendInitialMetadata { ->CreateMemoryAllocator("test")); grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch grpc_initial_metadata{arena.get()}; + grpc_metadata_batch grpc_initial_metadata; }; struct MakeSendMessage { @@ -271,7 +271,7 @@ struct MakeSendTrailingMetadata { ->CreateMemoryAllocator("test")); grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch grpc_trailing_metadata{arena.get()}; + grpc_metadata_batch grpc_trailing_metadata; }; struct MakeRecvInitialMetadata { @@ -299,7 +299,7 @@ struct MakeRecvInitialMetadata { ->CreateMemoryAllocator("test")); grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch grpc_initial_metadata{arena.get()}; + grpc_metadata_batch grpc_initial_metadata; grpc_core::Notification notification; }; @@ -347,7 +347,7 @@ struct MakeRecvTrailingMetadata { ->CreateMemoryAllocator("test")); grpc_core::ScopedArenaPtr arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch grpc_trailing_metadata{arena.get()}; + grpc_metadata_batch grpc_trailing_metadata; grpc_core::Notification notification; }; diff --git a/test/core/transport/call_filters_test.cc b/test/core/transport/call_filters_test.cc index 08df49c0057..1db57026314 100644 --- a/test/core/transport/call_filters_test.cc +++ b/test/core/transport/call_filters_test.cc @@ -354,10 +354,7 @@ TEST(StackDataTest, InstantClientInitialMetadataReturningVoid) { EXPECT_EQ(d.client_initial_metadata.ops[0].poll, nullptr); EXPECT_EQ(d.client_initial_metadata.ops[0].early_destroy, nullptr); // Check promise init - auto memory_allocator = - MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); - auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); char call_data; auto r = d.client_initial_metadata.ops[0].promise_init( @@ -392,10 +389,7 @@ TEST(StackDataTest, InstantClientInitialMetadataReturningVoidTakingChannelPtr) { EXPECT_EQ(d.client_initial_metadata.ops[0].poll, nullptr); EXPECT_EQ(d.client_initial_metadata.ops[0].early_destroy, nullptr); // Check promise init - auto memory_allocator = - MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); - auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); char call_data; auto r = d.client_initial_metadata.ops[0].promise_init( @@ -442,7 +436,7 @@ TEST(StackDataTest, InstantClientInitialMetadataReturningAbslStatus) { auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); promise_detail::Context ctx(arena.get()); // A succeeding call EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); @@ -453,7 +447,7 @@ TEST(StackDataTest, InstantClientInitialMetadataReturningAbslStatus) { EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "hello"); // A failing call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( nullptr, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -502,7 +496,7 @@ TEST(StackDataTest, auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); promise_detail::Context ctx(arena.get()); // A succeeding call EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); @@ -513,7 +507,7 @@ TEST(StackDataTest, EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "hello"); // A failing call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( nullptr, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -561,7 +555,7 @@ TEST(StackDataTest, InstantClientInitialMetadataReturningServerMetadata) { auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); promise_detail::Context ctx(arena.get()); // A succeeding call EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); @@ -572,7 +566,7 @@ TEST(StackDataTest, InstantClientInitialMetadataReturningServerMetadata) { EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "hello"); // A failing call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( nullptr, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -623,7 +617,7 @@ TEST(StackDataTest, auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); promise_detail::Context ctx(arena.get()); // A succeeding call EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); @@ -634,7 +628,7 @@ TEST(StackDataTest, EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "hello"); // A failing call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( nullptr, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -683,7 +677,7 @@ TEST(StackDataTest, PromiseClientInitialMetadataReturningAbslStatus) { auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); promise_detail::Context ctx(arena.get()); // A succeeding call EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); @@ -701,7 +695,7 @@ TEST(StackDataTest, PromiseClientInitialMetadataReturningAbslStatus) { EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "hello"); // A failing call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( promise_data, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -714,7 +708,7 @@ TEST(StackDataTest, PromiseClientInitialMetadataReturningAbslStatus) { EXPECT_EQ(r.value().ok, nullptr); EXPECT_EQ(r.value().error->get(GrpcStatusMetadata()), GRPC_STATUS_CANCELLED); // A cancelled call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( promise_data, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -766,7 +760,7 @@ TEST(StackDataTest, auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); promise_detail::Context ctx(arena.get()); // A succeeding call EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); @@ -784,7 +778,7 @@ TEST(StackDataTest, EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "hello"); // A failing call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( promise_data, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -797,7 +791,7 @@ TEST(StackDataTest, EXPECT_EQ(r.value().ok, nullptr); EXPECT_EQ(r.value().error->get(GrpcStatusMetadata()), GRPC_STATUS_CANCELLED); // A cancelled call - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = d.client_initial_metadata.ops[0].promise_init( promise_data, call_data, d.client_initial_metadata.ops[0].channel_data, @@ -836,7 +830,7 @@ TEST(StackDataTest, InstantServerInitialMetadataReturningVoid) { auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); char call_data; auto r = d.server_initial_metadata.ops[0].promise_init( @@ -943,7 +937,7 @@ TEST(StackDataTest, InstantServerTrailingMetadataReturningVoid) { auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); char call_data; auto r = d.server_trailing_metadata.ops[0].promise_init( @@ -983,7 +977,7 @@ TEST(StackDataTest, auto memory_allocator = MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); char call_data; auto r = d.server_trailing_metadata.ops[0].promise_init( @@ -1075,7 +1069,7 @@ TEST(OperationExecutorTest, InstantTwo) { auto arena = MakeScopedArena(1024, &memory_allocator); promise_detail::Context ctx(arena.get()); // First call succeeds - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); auto r = transformer.Start(&d.client_initial_metadata, std::move(md), call_data1); @@ -1083,7 +1077,7 @@ TEST(OperationExecutorTest, InstantTwo) { EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "world"); // Second fails - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = transformer.Start(&d.client_initial_metadata, std::move(md), call_data1); EXPECT_TRUE(r.ready()); @@ -1140,7 +1134,7 @@ TEST(OperationExecutorTest, PromiseTwo) { auto arena = MakeScopedArena(1024, &memory_allocator); promise_detail::Context ctx(arena.get()); // First call succeeds after two sets of two step delays. - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); auto r = transformer.Start(&d.client_initial_metadata, std::move(md), call_data1); @@ -1156,7 +1150,7 @@ TEST(OperationExecutorTest, PromiseTwo) { EXPECT_EQ(r.value().ok->get_pointer(HttpPathMetadata())->as_string_view(), "world"); // Second fails after one set of two step delays. - md = Arena::MakePooled(arena.get()); + md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); r = transformer.Start(&d.client_initial_metadata, std::move(md), call_data1); EXPECT_FALSE(r.ready()); @@ -1211,7 +1205,7 @@ TEST(InfallibleOperationExecutor, InstantTwo) { MakeMemoryQuota("test-quota")->CreateMemoryAllocator("foo"); auto arena = MakeScopedArena(1024, &memory_allocator); promise_detail::Context ctx(arena.get()); - auto md = Arena::MakePooled(arena.get()); + auto md = Arena::MakePooled(); EXPECT_EQ(md->get_pointer(HttpPathMetadata()), nullptr); auto r = transformer.Start(&d.server_trailing_metadata, std::move(md), call_data); @@ -1416,8 +1410,8 @@ TEST(CallFiltersTest, UnaryCall) { StrictMock activity; activity.Activate(); // Push client initial metadata - auto push_client_initial_metadata = filters.PushClientInitialMetadata( - Arena::MakePooled(arena.get())); + auto push_client_initial_metadata = + filters.PushClientInitialMetadata(Arena::MakePooled()); EXPECT_THAT(push_client_initial_metadata(), IsPending()); auto pull_client_initial_metadata = filters.PullClientInitialMetadata(); // Pull client initial metadata, expect a wakeup @@ -1438,8 +1432,8 @@ TEST(CallFiltersTest, UnaryCall) { // Push should be done EXPECT_THAT(push_client_to_server_message(), IsReady(Success{})); // Push server initial metadata - auto push_server_initial_metadata = filters.PushServerInitialMetadata( - Arena::MakePooled(arena.get())); + auto push_server_initial_metadata = + filters.PushServerInitialMetadata(Arena::MakePooled()); EXPECT_THAT(push_server_initial_metadata(), IsPending()); auto pull_server_initial_metadata = filters.PullServerInitialMetadata(); // Pull server initial metadata, expect a wakeup @@ -1460,8 +1454,7 @@ TEST(CallFiltersTest, UnaryCall) { // Push should be done EXPECT_THAT(push_server_to_client_message(), IsReady(Success{})); // Push server trailing metadata - filters.PushServerTrailingMetadata( - Arena::MakePooled(arena.get())); + filters.PushServerTrailingMetadata(Arena::MakePooled()); // Pull server trailing metadata auto pull_server_trailing_metadata = filters.PullServerTrailingMetadata(); // Should be done diff --git a/test/core/transport/chaotic_good/client_transport_error_test.cc b/test/core/transport/chaotic_good/client_transport_error_test.cc index ac1555fb473..453e99a3663 100644 --- a/test/core/transport/chaotic_good/client_transport_error_test.cc +++ b/test/core/transport/chaotic_good/client_transport_error_test.cc @@ -120,8 +120,7 @@ auto SendClientToServerMessages(CallInitiator initiator, int num_messages) { } ClientMetadataHandle TestInitialMetadata() { - auto md = - GetContext()->MakePooled(GetContext()); + auto md = GetContext()->MakePooled(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/test")); return md; } diff --git a/test/core/transport/chaotic_good/client_transport_test.cc b/test/core/transport/chaotic_good/client_transport_test.cc index 358197031a3..387e483fc21 100644 --- a/test/core/transport/chaotic_good/client_transport_test.cc +++ b/test/core/transport/chaotic_good/client_transport_test.cc @@ -67,8 +67,7 @@ const uint8_t kGrpcStatus0[] = {0x10, 0x0b, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x01, 0x30}; ClientMetadataHandle TestInitialMetadata() { - auto md = - GetContext()->MakePooled(GetContext()); + auto md = GetContext()->MakePooled(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/demo.Service/Step")); return md; } diff --git a/test/core/transport/chaotic_good/server_transport_test.cc b/test/core/transport/chaotic_good/server_transport_test.cc index e67301cf6c9..7c21a07c72d 100644 --- a/test/core/transport/chaotic_good/server_transport_test.cc +++ b/test/core/transport/chaotic_good/server_transport_test.cc @@ -71,15 +71,13 @@ const uint8_t kGrpcStatus0[] = {0x40, 0x0b, 0x67, 0x72, 0x70, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x01, 0x30}; ServerMetadataHandle TestInitialMetadata() { - auto md = - GetContext()->MakePooled(GetContext()); + auto md = GetContext()->MakePooled(); md->Set(HttpPathMetadata(), Slice::FromStaticString("/demo.Service/Step")); return md; } ServerMetadataHandle TestTrailingMetadata() { - auto md = - GetContext()->MakePooled(GetContext()); + auto md = GetContext()->MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_OK); return md; } diff --git a/test/core/transport/chttp2/hpack_encoder_test.cc b/test/core/transport/chttp2/hpack_encoder_test.cc index e10e88bb3c1..534edacbeab 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.cc +++ b/test/core/transport/chttp2/hpack_encoder_test.cc @@ -159,7 +159,7 @@ grpc_slice EncodeHeaderIntoBytes( ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; for (const auto& field : header_fields) { b.Append(field.first, @@ -309,7 +309,7 @@ static void verify_continuation_headers(const char* key, const char* value, ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); grpc_slice_buffer output; - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; b.Append(key, grpc_core::Slice::FromStaticString(value), CrashOnAppendError); grpc_slice_buffer_init(&output); @@ -349,7 +349,7 @@ TEST(HpackEncoderTest, EncodeBinaryAsBase64) { ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; // Haiku by Bard b.Append("grpc-trace-bin", grpc_core::Slice::FromStaticString( @@ -379,7 +379,7 @@ TEST(HpackEncoderTest, EncodeBinaryAsTrueBinary) { ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; // Haiku by Bard b.Append("grpc-trace-bin", grpc_core::Slice::FromStaticString( diff --git a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc index c167cf9ce49..9b3d9699d3c 100644 --- a/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc +++ b/test/core/transport/chttp2/hpack_parser_fuzzer_test.cc @@ -70,7 +70,7 @@ DEFINE_PROTO_FUZZER(const hpack_parser_fuzzer::Msg& msg) { for (int i = 0; i < msg.frames_size(); i++) { auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); grpc_core::ExecCtx exec_ctx; - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; const auto& frame = msg.frames(i); if (frame.parse_size() == 0) continue; diff --git a/test/core/transport/chttp2/hpack_parser_input_size_fuzzer.cc b/test/core/transport/chttp2/hpack_parser_input_size_fuzzer.cc index 070fd7a9f16..f3160042abe 100644 --- a/test/core/transport/chttp2/hpack_parser_input_size_fuzzer.cc +++ b/test/core/transport/chttp2/hpack_parser_input_size_fuzzer.cc @@ -90,7 +90,7 @@ absl::StatusOr TestVector(grpc_slice_split_mode mode, size_t nslices; size_t i; - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; HPackParser parser; parser.BeginFrame( diff --git a/test/core/transport/chttp2/hpack_parser_test.cc b/test/core/transport/chttp2/hpack_parser_test.cc index 3772d909b9b..bdb3f02cad0 100644 --- a/test/core/transport/chttp2/hpack_parser_test.cc +++ b/test/core/transport/chttp2/hpack_parser_test.cc @@ -118,7 +118,7 @@ class ParseTest : public ::testing::TestWithParam { size_t i; absl::BitGen bitgen; - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; parser_->BeginFrame( &b, max_metadata_size.value_or(4096), max_metadata_size.value_or(4096), diff --git a/test/core/transport/chttp2/hpack_sync_fuzzer.cc b/test/core/transport/chttp2/hpack_sync_fuzzer.cc index 47e426547a7..58b0fa8628c 100644 --- a/test/core/transport/chttp2/hpack_sync_fuzzer.cc +++ b/test/core/transport/chttp2/hpack_sync_fuzzer.cc @@ -122,7 +122,7 @@ void FuzzOneInput(const hpack_sync_fuzzer::Msg& msg) { "test-allocator"); auto arena = MakeScopedArena(1024, &memory_allocator); ExecCtx exec_ctx; - grpc_metadata_batch read_metadata(arena.get()); + grpc_metadata_batch read_metadata; parser.BeginFrame( &read_metadata, 1024, 1024, HPackParser::Boundary::EndOfHeaders, HPackParser::Priority::None, diff --git a/test/core/transport/metadata_map_test.cc b/test/core/transport/metadata_map_test.cc index c15fbeb7f63..b691e99787d 100644 --- a/test/core/transport/metadata_map_test.cc +++ b/test/core/transport/metadata_map_test.cc @@ -64,17 +64,17 @@ class MetadataMapTest : public ::testing::Test { TEST_F(MetadataMapTest, Noop) { auto arena = MakeScopedArena(1024, &memory_allocator_); - EmptyMetadataMap(arena.get()); + EmptyMetadataMap(); } TEST_F(MetadataMapTest, NoopWithDeadline) { auto arena = MakeScopedArena(1024, &memory_allocator_); - TimeoutOnlyMetadataMap(arena.get()); + TimeoutOnlyMetadataMap(); } TEST_F(MetadataMapTest, SimpleOps) { auto arena = MakeScopedArena(1024, &memory_allocator_); - TimeoutOnlyMetadataMap map(arena.get()); + TimeoutOnlyMetadataMap map; EXPECT_EQ(map.get_pointer(GrpcTimeoutMetadata()), nullptr); EXPECT_EQ(map.get(GrpcTimeoutMetadata()), absl::nullopt); map.Set(GrpcTimeoutMetadata(), @@ -113,7 +113,7 @@ class FakeEncoder { TEST_F(MetadataMapTest, EmptyEncodeTest) { FakeEncoder encoder; auto arena = MakeScopedArena(1024, &memory_allocator_); - TimeoutOnlyMetadataMap map(arena.get()); + TimeoutOnlyMetadataMap map; map.Encode(&encoder); EXPECT_EQ(encoder.output(), ""); } @@ -121,7 +121,7 @@ TEST_F(MetadataMapTest, EmptyEncodeTest) { TEST_F(MetadataMapTest, TimeoutEncodeTest) { FakeEncoder encoder; auto arena = MakeScopedArena(1024, &memory_allocator_); - TimeoutOnlyMetadataMap map(arena.get()); + TimeoutOnlyMetadataMap map; map.Set(GrpcTimeoutMetadata(), Timestamp::FromMillisecondsAfterProcessEpoch(1234)); map.Encode(&encoder); @@ -135,7 +135,7 @@ TEST_F(MetadataMapTest, NonEncodableTrait) { } }; auto arena = MakeScopedArena(1024, &memory_allocator_); - StreamNetworkStateMetadataMap map(arena.get()); + StreamNetworkStateMetadataMap map; map.Set(GrpcStreamNetworkState(), GrpcStreamNetworkState::kNotSentOnWire); EXPECT_EQ(map.get(GrpcStreamNetworkState()), GrpcStreamNetworkState::kNotSentOnWire); diff --git a/test/core/transport/test_suite/call_content.cc b/test/core/transport/test_suite/call_content.cc index c565bb76696..cea4c5a0aa5 100644 --- a/test/core/transport/test_suite/call_content.cc +++ b/test/core/transport/test_suite/call_content.cc @@ -72,7 +72,7 @@ TRANSPORT_TEST(UnaryWithSomeContent) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); FillMetadata(client_initial_metadata, *md); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -126,7 +126,7 @@ TRANSPORT_TEST(UnaryWithSomeContent) { [&](NextResult msg) { EXPECT_FALSE(msg.has_value()); EXPECT_FALSE(msg.cancelled()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); FillMetadata(server_initial_metadata, *md); return handler.PushServerInitialMetadata(std::move(md)); }, @@ -137,7 +137,7 @@ TRANSPORT_TEST(UnaryWithSomeContent) { }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); FillMetadata(server_trailing_metadata, *md); return handler.PushServerTrailingMetadata(std::move(md)); }, diff --git a/test/core/transport/test_suite/call_shapes.cc b/test/core/transport/test_suite/call_shapes.cc index 4e24a35ea17..acfa0ffb741 100644 --- a/test/core/transport/test_suite/call_shapes.cc +++ b/test/core/transport/test_suite/call_shapes.cc @@ -22,7 +22,7 @@ TRANSPORT_TEST(MetadataOnlyRequest) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -55,13 +55,13 @@ TRANSPORT_TEST(MetadataOnlyRequest) { }, [&](NextResult msg) { EXPECT_FALSE(msg.has_value()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -83,7 +83,7 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsAfterInitialMetadata) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -115,13 +115,13 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsAfterInitialMetadata) { "/foo/bar"); // Don't wait for end of stream for client->server messages, just // publish initial then trailing metadata. - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -143,7 +143,7 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsImmediately) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -173,7 +173,7 @@ TRANSPORT_TEST(MetadataOnlyRequestServerAbortsImmediately) { "/foo/bar"); // Don't wait for end of stream for client->server messages, just // and don't send initial metadata - just trailing metadata. - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -190,7 +190,7 @@ TRANSPORT_TEST(CanCreateCallThenAbandonIt) { SpawnTestSeq( initiator, "start-call", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -212,7 +212,7 @@ TRANSPORT_TEST(UnaryRequest) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -267,7 +267,7 @@ TRANSPORT_TEST(UnaryRequest) { [&](NextResult msg) { EXPECT_FALSE(msg.has_value()); EXPECT_FALSE(msg.cancelled()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); }, @@ -278,7 +278,7 @@ TRANSPORT_TEST(UnaryRequest) { }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -295,7 +295,7 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -340,7 +340,7 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { [&](NextResult msg) { EXPECT_TRUE(msg.has_value()); EXPECT_EQ(msg.value()->payload()->JoinIntoString(), "hello world"); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); }, @@ -351,7 +351,7 @@ TRANSPORT_TEST(UnaryRequestOmitCheckEndOfStream) { }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -368,7 +368,7 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -413,7 +413,7 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { EXPECT_TRUE(md.ok()); EXPECT_EQ(md.value()->get_pointer(HttpPathMetadata())->as_string_view(), "/foo/bar"); - auto md_out = Arena::MakePooled(GetContext()); + auto md_out = Arena::MakePooled(); md_out->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md_out)); @@ -435,7 +435,7 @@ TRANSPORT_TEST(UnaryRequestWaitForServerInitialMetadataBeforeSendingPayload) { }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -452,7 +452,7 @@ TRANSPORT_TEST(ClientStreamingRequest) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -511,7 +511,7 @@ TRANSPORT_TEST(ClientStreamingRequest) { EXPECT_TRUE(md.ok()); EXPECT_EQ(md.value()->get_pointer(HttpPathMetadata())->as_string_view(), "/foo/bar"); - auto md_out = Arena::MakePooled(GetContext()); + auto md_out = Arena::MakePooled(); md_out->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md_out)); @@ -548,7 +548,7 @@ TRANSPORT_TEST(ClientStreamingRequest) { [&](NextResult msg) { EXPECT_FALSE(msg.has_value()); EXPECT_FALSE(msg.cancelled()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, @@ -565,7 +565,7 @@ TRANSPORT_TEST(ServerStreamingRequest) { SpawnTestSeq( initiator, "initiator", [&]() { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromExternalString("/foo/bar")); return initiator.PushClientInitialMetadata(std::move(md)); }, @@ -635,7 +635,7 @@ TRANSPORT_TEST(ServerStreamingRequest) { EXPECT_TRUE(md.ok()); EXPECT_EQ(md.value()->get_pointer(HttpPathMetadata())->as_string_view(), "/foo/bar"); - auto md_out = Arena::MakePooled(GetContext()); + auto md_out = Arena::MakePooled(); md_out->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md_out)); @@ -677,7 +677,7 @@ TRANSPORT_TEST(ServerStreamingRequest) { }, [&](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, diff --git a/test/core/transport/test_suite/stress.cc b/test/core/transport/test_suite/stress.cc index 2adaeec45bf..54e34ba98d5 100644 --- a/test/core/transport/test_suite/stress.cc +++ b/test/core/transport/test_suite/stress.cc @@ -36,7 +36,7 @@ TRANSPORT_TEST(ManyUnaryRequests) { SpawnTestSeq( initiator, make_call_name(i, "initiator"), [initiator, i]() mutable { - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(HttpPathMetadata(), Slice::FromCopiedString(std::to_string(i))); return initiator.PushClientInitialMetadata(std::move(md)); @@ -102,7 +102,7 @@ TRANSPORT_TEST(ManyUnaryRequests) { [handler](NextResult msg) mutable { EXPECT_FALSE(msg.has_value()); EXPECT_FALSE(msg.cancelled()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(ContentTypeMetadata(), ContentTypeMetadata::kApplicationGrpc); return handler.PushServerInitialMetadata(std::move(md)); }, @@ -116,7 +116,7 @@ TRANSPORT_TEST(ManyUnaryRequests) { }, [handler](StatusFlag result) mutable { EXPECT_TRUE(result.ok()); - auto md = Arena::MakePooled(GetContext()); + auto md = Arena::MakePooled(); md->Set(GrpcStatusMetadata(), GRPC_STATUS_UNIMPLEMENTED); return handler.PushServerTrailingMetadata(std::move(md)); }, diff --git a/test/core/util/evaluate_args_test_util.h b/test/core/util/evaluate_args_test_util.h index a6161c3fb73..9d54260dfd6 100644 --- a/test/core/util/evaluate_args_test_util.h +++ b/test/core/util/evaluate_args_test_util.h @@ -74,8 +74,7 @@ class EvaluateArgsTestUtil { MemoryAllocator allocator_ = ResourceQuota::Default()->memory_quota()->CreateMemoryAllocator( "EvaluateArgsTestUtil"); - ScopedArenaPtr arena_ = MakeScopedArena(1024, &allocator_); - grpc_metadata_batch metadata_{arena_.get()}; + grpc_metadata_batch metadata_; MockAuthorizationEndpoint endpoint_{/*local_uri=*/"", /*peer_uri=*/""}; grpc_auth_context auth_context_{nullptr}; EvaluateArgs::PerChannelArgs* channel_args_ = nullptr; diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 1ba7787cc0b..df358551224 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -75,7 +75,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) { ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; b.Set(grpc_core::GrpcTimeoutMetadata(), saved_now + grpc_core::Duration::Seconds(30)); @@ -111,7 +111,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; Fixture::Prepare(&b); grpc_core::HPackCompressor c; @@ -351,7 +351,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { ->CreateMemoryAllocator("test")); auto* arena = grpc_core::Arena::Create(kArenaSize, &memory_allocator); grpc_core::ManualConstructor b; - b.Init(arena); + b.Init(); p.BeginFrame(&*b, std::numeric_limits::max(), std::numeric_limits::max(), grpc_core::HPackParser::Boundary::None, @@ -377,7 +377,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { b.Destroy(); arena->Destroy(); arena = grpc_core::Arena::Create(kArenaSize, &memory_allocator); - b.Init(arena); + b.Init(); p.BeginFrame(&*b, std::numeric_limits::max(), std::numeric_limits::max(), grpc_core::HPackParser::Boundary::None, @@ -410,7 +410,7 @@ class FromEncoderFixture { ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; EncoderFixture::Prepare(&b); grpc_core::HPackCompressor c; diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 974bf2ad50b..0160015eeab 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -333,7 +333,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { ->memory_quota() ->CreateMemoryAllocator("test")); auto arena = grpc_core::MakeScopedArena(1024, &memory_allocator); - grpc_metadata_batch b(arena.get()); + grpc_metadata_batch b; Metadata::Prepare(&b); f.FlushExecCtx();