pull/36227/head
Craig Tiller 10 months ago
parent d9badb171a
commit 08392ddd36
  1. 1
      bazel/experiments.bzl
  2. 52
      src/core/ext/filters/backend_metrics/backend_metric_filter.cc
  3. 12
      src/core/ext/filters/backend_metrics/backend_metric_filter.h
  4. 15
      src/core/lib/experiments/experiments.cc
  5. 8
      src/core/lib/experiments/experiments.h
  6. 6
      src/core/lib/experiments/experiments.yaml

@ -43,7 +43,6 @@ EXPERIMENT_ENABLES = {
"tcp_rcv_lowat": "tcp_rcv_lowat", "tcp_rcv_lowat": "tcp_rcv_lowat",
"trace_record_callops": "trace_record_callops", "trace_record_callops": "trace_record_callops",
"unconstrained_max_quota_buffer_size": "unconstrained_max_quota_buffer_size", "unconstrained_max_quota_buffer_size": "unconstrained_max_quota_buffer_size",
"v3_backend_metric_filter": "v3_backend_metric_filter",
"work_serializer_clears_time_cache": "work_serializer_clears_time_cache", "work_serializer_clears_time_cache": "work_serializer_clears_time_cache",
"work_serializer_dispatch": "event_engine_client,work_serializer_dispatch", "work_serializer_dispatch": "event_engine_client,work_serializer_dispatch",
} }

@ -117,55 +117,15 @@ absl::optional<std::string> MaybeSerializeBackendMetrics(
} }
} // namespace } // namespace
const grpc_channel_filter LegacyBackendMetricFilter::kFilter =
MakePromiseBasedFilter<LegacyBackendMetricFilter, FilterEndpoint::kServer>(
"backend_metric");
const grpc_channel_filter BackendMetricFilter::kFilter = const grpc_channel_filter BackendMetricFilter::kFilter =
MakePromiseBasedFilter<BackendMetricFilter, FilterEndpoint::kServer>( MakePromiseBasedFilter<BackendMetricFilter, FilterEndpoint::kServer>(
"backend_metric"); "backend_metric");
absl::StatusOr<LegacyBackendMetricFilter> LegacyBackendMetricFilter::Create(
const ChannelArgs&, ChannelFilter::Args) {
return LegacyBackendMetricFilter();
}
absl::StatusOr<BackendMetricFilter> BackendMetricFilter::Create( absl::StatusOr<BackendMetricFilter> BackendMetricFilter::Create(
const ChannelArgs&, ChannelFilter::Args) { const ChannelArgs&, ChannelFilter::Args) {
return BackendMetricFilter(); return BackendMetricFilter();
} }
ArenaPromise<ServerMetadataHandle> LegacyBackendMetricFilter::MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) {
return ArenaPromise<ServerMetadataHandle>(Map(
next_promise_factory(std::move(call_args)),
[this](ServerMetadataHandle trailing_metadata) {
auto* ctx = &GetContext<
grpc_call_context_element>()[GRPC_CONTEXT_BACKEND_METRIC_PROVIDER];
if (ctx == nullptr) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_backend_metric_filter_trace)) {
gpr_log(GPR_INFO, "[%p] No BackendMetricProvider.", this);
}
return trailing_metadata;
}
absl::optional<std::string> serialized = MaybeSerializeBackendMetrics(
reinterpret_cast<BackendMetricProvider*>(ctx->value));
if (serialized.has_value() && !serialized->empty()) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_backend_metric_filter_trace)) {
gpr_log(GPR_INFO,
"[%p] Backend metrics serialized. size: %" PRIuPTR, this,
serialized->size());
}
trailing_metadata->Set(
EndpointLoadMetricsBinMetadata(),
Slice::FromCopiedString(std::move(*serialized)));
} else if (GRPC_TRACE_FLAG_ENABLED(grpc_backend_metric_filter_trace)) {
gpr_log(GPR_INFO, "[%p] No backend metrics.", this);
}
return trailing_metadata;
}));
}
void BackendMetricFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) { void BackendMetricFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) {
auto* ctx = &GetContext< auto* ctx = &GetContext<
grpc_call_context_element>()[GRPC_CONTEXT_BACKEND_METRIC_PROVIDER]; grpc_call_context_element>()[GRPC_CONTEXT_BACKEND_METRIC_PROVIDER];
@ -190,15 +150,9 @@ void BackendMetricFilter::Call::OnServerTrailingMetadata(ServerMetadata& md) {
} }
void RegisterBackendMetricFilter(CoreConfiguration::Builder* builder) { void RegisterBackendMetricFilter(CoreConfiguration::Builder* builder) {
if (IsV3BackendMetricFilterEnabled()) { builder->channel_init()
builder->channel_init() ->RegisterFilter<BackendMetricFilter>(GRPC_SERVER_CHANNEL)
->RegisterFilter<BackendMetricFilter>(GRPC_SERVER_CHANNEL) .IfHasChannelArg(GRPC_ARG_SERVER_CALL_METRIC_RECORDING);
.IfHasChannelArg(GRPC_ARG_SERVER_CALL_METRIC_RECORDING);
} else {
builder->channel_init()
->RegisterFilter<LegacyBackendMetricFilter>(GRPC_SERVER_CHANNEL)
.IfHasChannelArg(GRPC_ARG_SERVER_CALL_METRIC_RECORDING);
}
} }
} // namespace grpc_core } // namespace grpc_core

@ -31,18 +31,6 @@
namespace grpc_core { namespace grpc_core {
class LegacyBackendMetricFilter : public ChannelFilter {
public:
static const grpc_channel_filter kFilter;
static absl::StatusOr<LegacyBackendMetricFilter> Create(
const ChannelArgs& args, ChannelFilter::Args);
// Construct a promise for one call.
ArenaPromise<ServerMetadataHandle> MakeCallPromise(
CallArgs call_args, NextPromiseFactory next_promise_factory) override;
};
class BackendMetricFilter : public ImplementChannelFilter<BackendMetricFilter> { class BackendMetricFilter : public ImplementChannelFilter<BackendMetricFilter> {
public: public:
static const grpc_channel_filter kFilter; static const grpc_channel_filter kFilter;

@ -128,9 +128,6 @@ const char* const description_unconstrained_max_quota_buffer_size =
"Discard the cap on the max free pool size for one memory allocator"; "Discard the cap on the max free pool size for one memory allocator";
const char* const additional_constraints_unconstrained_max_quota_buffer_size = const char* const additional_constraints_unconstrained_max_quota_buffer_size =
"{}"; "{}";
const char* const description_v3_backend_metric_filter =
"Use the backend metric filter utilizing the v3 filter api";
const char* const additional_constraints_v3_backend_metric_filter = "{}";
const char* const description_work_serializer_clears_time_cache = const char* const description_work_serializer_clears_time_cache =
"Have the work serializer clear the time cache when it dispatches work."; "Have the work serializer clear the time cache when it dispatches work.";
const char* const additional_constraints_work_serializer_clears_time_cache = const char* const additional_constraints_work_serializer_clears_time_cache =
@ -214,8 +211,6 @@ const ExperimentMetadata g_experiment_metadata[] = {
description_unconstrained_max_quota_buffer_size, description_unconstrained_max_quota_buffer_size,
additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0, additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0,
false, true}, false, true},
{"v3_backend_metric_filter", description_v3_backend_metric_filter,
additional_constraints_v3_backend_metric_filter, nullptr, 0, false, true},
{"work_serializer_clears_time_cache", {"work_serializer_clears_time_cache",
description_work_serializer_clears_time_cache, description_work_serializer_clears_time_cache,
additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true, additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true,
@ -333,9 +328,6 @@ const char* const description_unconstrained_max_quota_buffer_size =
"Discard the cap on the max free pool size for one memory allocator"; "Discard the cap on the max free pool size for one memory allocator";
const char* const additional_constraints_unconstrained_max_quota_buffer_size = const char* const additional_constraints_unconstrained_max_quota_buffer_size =
"{}"; "{}";
const char* const description_v3_backend_metric_filter =
"Use the backend metric filter utilizing the v3 filter api";
const char* const additional_constraints_v3_backend_metric_filter = "{}";
const char* const description_work_serializer_clears_time_cache = const char* const description_work_serializer_clears_time_cache =
"Have the work serializer clear the time cache when it dispatches work."; "Have the work serializer clear the time cache when it dispatches work.";
const char* const additional_constraints_work_serializer_clears_time_cache = const char* const additional_constraints_work_serializer_clears_time_cache =
@ -419,8 +411,6 @@ const ExperimentMetadata g_experiment_metadata[] = {
description_unconstrained_max_quota_buffer_size, description_unconstrained_max_quota_buffer_size,
additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0, additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0,
false, true}, false, true},
{"v3_backend_metric_filter", description_v3_backend_metric_filter,
additional_constraints_v3_backend_metric_filter, nullptr, 0, false, true},
{"work_serializer_clears_time_cache", {"work_serializer_clears_time_cache",
description_work_serializer_clears_time_cache, description_work_serializer_clears_time_cache,
additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true, additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true,
@ -538,9 +528,6 @@ const char* const description_unconstrained_max_quota_buffer_size =
"Discard the cap on the max free pool size for one memory allocator"; "Discard the cap on the max free pool size for one memory allocator";
const char* const additional_constraints_unconstrained_max_quota_buffer_size = const char* const additional_constraints_unconstrained_max_quota_buffer_size =
"{}"; "{}";
const char* const description_v3_backend_metric_filter =
"Use the backend metric filter utilizing the v3 filter api";
const char* const additional_constraints_v3_backend_metric_filter = "{}";
const char* const description_work_serializer_clears_time_cache = const char* const description_work_serializer_clears_time_cache =
"Have the work serializer clear the time cache when it dispatches work."; "Have the work serializer clear the time cache when it dispatches work.";
const char* const additional_constraints_work_serializer_clears_time_cache = const char* const additional_constraints_work_serializer_clears_time_cache =
@ -624,8 +611,6 @@ const ExperimentMetadata g_experiment_metadata[] = {
description_unconstrained_max_quota_buffer_size, description_unconstrained_max_quota_buffer_size,
additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0, additional_constraints_unconstrained_max_quota_buffer_size, nullptr, 0,
false, true}, false, true},
{"v3_backend_metric_filter", description_v3_backend_metric_filter,
additional_constraints_v3_backend_metric_filter, nullptr, 0, false, true},
{"work_serializer_clears_time_cache", {"work_serializer_clears_time_cache",
description_work_serializer_clears_time_cache, description_work_serializer_clears_time_cache,
additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true, additional_constraints_work_serializer_clears_time_cache, nullptr, 0, true,

@ -95,7 +95,6 @@ inline bool IsTcpFrameSizeTuningEnabled() { return false; }
inline bool IsTcpRcvLowatEnabled() { return false; } inline bool IsTcpRcvLowatEnabled() { return false; }
inline bool IsTraceRecordCallopsEnabled() { return false; } inline bool IsTraceRecordCallopsEnabled() { return false; }
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; }
inline bool IsV3BackendMetricFilterEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; } inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
inline bool IsWorkSerializerDispatchEnabled() { return false; } inline bool IsWorkSerializerDispatchEnabled() { return false; }
@ -140,7 +139,6 @@ inline bool IsTcpFrameSizeTuningEnabled() { return false; }
inline bool IsTcpRcvLowatEnabled() { return false; } inline bool IsTcpRcvLowatEnabled() { return false; }
inline bool IsTraceRecordCallopsEnabled() { return false; } inline bool IsTraceRecordCallopsEnabled() { return false; }
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; }
inline bool IsV3BackendMetricFilterEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; } inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
inline bool IsWorkSerializerDispatchEnabled() { return false; } inline bool IsWorkSerializerDispatchEnabled() { return false; }
@ -186,7 +184,6 @@ inline bool IsTcpFrameSizeTuningEnabled() { return false; }
inline bool IsTcpRcvLowatEnabled() { return false; } inline bool IsTcpRcvLowatEnabled() { return false; }
inline bool IsTraceRecordCallopsEnabled() { return false; } inline bool IsTraceRecordCallopsEnabled() { return false; }
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; } inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { return false; }
inline bool IsV3BackendMetricFilterEnabled() { return false; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; } inline bool IsWorkSerializerClearsTimeCacheEnabled() { return true; }
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_DISPATCH #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_DISPATCH
@ -221,7 +218,6 @@ enum ExperimentIds {
kExperimentIdTcpRcvLowat, kExperimentIdTcpRcvLowat,
kExperimentIdTraceRecordCallops, kExperimentIdTraceRecordCallops,
kExperimentIdUnconstrainedMaxQuotaBufferSize, kExperimentIdUnconstrainedMaxQuotaBufferSize,
kExperimentIdV3BackendMetricFilter,
kExperimentIdWorkSerializerClearsTimeCache, kExperimentIdWorkSerializerClearsTimeCache,
kExperimentIdWorkSerializerDispatch, kExperimentIdWorkSerializerDispatch,
kNumExperiments kNumExperiments
@ -330,10 +326,6 @@ inline bool IsTraceRecordCallopsEnabled() {
inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() { inline bool IsUnconstrainedMaxQuotaBufferSizeEnabled() {
return IsExperimentEnabled(kExperimentIdUnconstrainedMaxQuotaBufferSize); return IsExperimentEnabled(kExperimentIdUnconstrainedMaxQuotaBufferSize);
} }
#define GRPC_EXPERIMENT_IS_INCLUDED_V3_BACKEND_METRIC_FILTER
inline bool IsV3BackendMetricFilterEnabled() {
return IsExperimentEnabled(kExperimentIdV3BackendMetricFilter);
}
#define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE #define GRPC_EXPERIMENT_IS_INCLUDED_WORK_SERIALIZER_CLEARS_TIME_CACHE
inline bool IsWorkSerializerClearsTimeCacheEnabled() { inline bool IsWorkSerializerClearsTimeCacheEnabled() {
return IsExperimentEnabled(kExperimentIdWorkSerializerClearsTimeCache); return IsExperimentEnabled(kExperimentIdWorkSerializerClearsTimeCache);

@ -215,12 +215,6 @@
expiry: 2024/09/01 expiry: 2024/09/01
owner: ctiller@google.com owner: ctiller@google.com
test_tags: [resource_quota_test] test_tags: [resource_quota_test]
- name: v3_backend_metric_filter
description:
Use the backend metric filter utilizing the v3 filter api
expiry: 2024/05/05
owner: ctiller@google.com
test_tags: []
- name: work_serializer_clears_time_cache - name: work_serializer_clears_time_cache
description: description:
Have the work serializer clear the time cache when it dispatches work. Have the work serializer clear the time cache when it dispatches work.

Loading…
Cancel
Save