Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Feb 19, 2025
2 parents b7a1efd + dbb582a commit e2b0c59
Show file tree
Hide file tree
Showing 13 changed files with 877 additions and 177 deletions.
2 changes: 0 additions & 2 deletions bazel/experiments.bzl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 1 addition & 19 deletions src/core/ext/transport/chttp2/transport/chttp2_transport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ using TaskHandle = ::grpc_event_engine::experimental::EventEngine::TaskHandle;

grpc_core::CallTracerAnnotationInterface* CallTracerIfSampled(
grpc_chttp2_stream* s) {
if (!grpc_core::IsTraceRecordCallopsEnabled()) {
return nullptr;
}
auto* call_tracer =
s->arena->GetContext<grpc_core::CallTracerAnnotationInterface>();
if (call_tracer == nullptr || !call_tracer->IsSampled()) {
Expand All @@ -242,9 +239,6 @@ grpc_core::CallTracerAnnotationInterface* CallTracerIfSampled(

std::shared_ptr<grpc_core::TcpTracerInterface> TcpTracerIfSampled(
grpc_chttp2_stream* s) {
if (!grpc_core::IsTraceRecordCallopsEnabled()) {
return nullptr;
}
auto* call_attempt_tracer =
s->arena->GetContext<grpc_core::CallTracerInterface>();
if (call_attempt_tracer == nullptr || !call_attempt_tracer->IsSampled()) {
Expand Down Expand Up @@ -1395,7 +1389,7 @@ static void trace_annotations(grpc_chttp2_stream* s) {
.Add(s->t->flow_control.stats())
.Add(s->flow_control.stats()));
}
} else if (grpc_core::IsTraceRecordCallopsEnabled()) {
} else {
auto* call_tracer = s->arena->GetContext<grpc_core::CallTracerInterface>();
if (call_tracer != nullptr && call_tracer->IsSampled()) {
call_tracer->RecordAnnotation(
Expand Down Expand Up @@ -1504,18 +1498,6 @@ static void send_message_locked(
absl::OkStatus(),
"fetching_send_message_finished");
} else {
// Buffer hint is used to buffer the message in the transport until the
// write buffer size (specified through GRPC_ARG_HTTP2_WRITE_BUFFER_SIZE) is
// reached. This is to batch writes sent down to tcp. However, if the memory
// pressure is high, disable the buffer hint to flush data down to tcp as
// soon as possible to avoid OOM.
if (grpc_core::IsDisableBufferHintOnHighMemoryPressureEnabled() &&
t->memory_owner.GetPressureInfo().pressure_control_value >= 0.8) {
// Disable write buffer hint if memory pressure is high. The value of 0.8
// is chosen to match the threshold used by the tcp endpoint (in
// allocating memory for socket reads).
op_payload->send_message.flags &= ~GRPC_WRITE_BUFFER_HINT;
}
flags = op_payload->send_message.flags;
uint8_t* frame_hdr = grpc_slice_buffer_tiny_add(&s->flow_controlled_buffer,
GRPC_HEADER_SIZE_IN_BYTES);
Expand Down
40 changes: 1 addition & 39 deletions src/core/ext/transport/chttp2/transport/stream_lists.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,26 +128,6 @@ static void stream_list_add_tail(grpc_chttp2_transport* t,
<< "]: add to " << stream_list_id_string(id);
}

static void stream_list_add_head(grpc_chttp2_transport* t,
grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
grpc_chttp2_stream* old_head;
CHECK(!s->included.is_set(id));
old_head = t->lists[id].head;
s->links[id].next = old_head;
s->links[id].prev = nullptr;
if (old_head) {
old_head->links[id].prev = s;
} else {
t->lists[id].tail = s;
}
t->lists[id].head = s;
s->included.set(id);
GRPC_TRACE_LOG(http2_stream_state, INFO)
<< t << "[" << s->id << "][" << (t->is_client ? "cli" : "svr")
<< "]: add to " << stream_list_id_string(id);
}

static bool stream_list_add(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
if (s->included.is_set(id)) {
Expand All @@ -157,24 +137,11 @@ static bool stream_list_add(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
return true;
}

static bool stream_list_prepend(grpc_chttp2_transport* t, grpc_chttp2_stream* s,
grpc_chttp2_stream_list_id id) {
if (s->included.is_set(id)) {
return false;
}
stream_list_add_head(t, s, id);
return true;
}

// wrappers for specializations

bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
CHECK_NE(s->id, 0u);
if (grpc_core::IsPrioritizeFinishedRequestsEnabled() &&
s->send_trailing_metadata != nullptr) {
return stream_list_prepend(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}
return stream_list_add(t, s, GRPC_CHTTP2_LIST_WRITABLE);
}

Expand Down Expand Up @@ -219,12 +186,7 @@ void grpc_chttp2_list_remove_waiting_for_concurrency(grpc_chttp2_transport* t,

void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) {
if (grpc_core::IsPrioritizeFinishedRequestsEnabled() &&
s->send_trailing_metadata != nullptr) {
stream_list_prepend(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
} else {
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
}

bool grpc_chttp2_list_pop_stalled_by_transport(grpc_chttp2_transport* t,
Expand Down
4 changes: 2 additions & 2 deletions src/core/ext/transport/chttp2/transport/writing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ class StreamWriteContext {
.Add(s_->flow_control.stats())
.Add(write_stats));
}
} else if (grpc_core::IsTraceRecordCallopsEnabled()) {
} else {
auto* call_tracer =
s_->arena->GetContext<grpc_core::CallTracerInterface>();
if (call_tracer != nullptr && call_tracer->IsSampled()) {
Expand Down Expand Up @@ -646,7 +646,7 @@ class StreamWriteContext {
.Add(s_->t->flow_control.stats())
.Add(s_->flow_control.stats()));
}
} else if (grpc_core::IsTraceRecordCallopsEnabled()) {
} else {
auto* call_tracer =
s_->arena->GetContext<grpc_core::CallTracerInterface>();
if (call_tracer != nullptr && call_tracer->IsSampled()) {
Expand Down
36 changes: 0 additions & 36 deletions src/core/lib/experiments/experiments.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions src/core/lib/experiments/experiments.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e2b0c59

Please sign in to comment.