Plumb through flow_control->flow_conrol_enabled()

pull/13289/head
ncteisen 7 years ago
parent 734256a5d0
commit 0aaee995a3
  1. 25
      src/core/ext/transport/chttp2/transport/chttp2_transport.cc
  2. 19
      src/core/ext/transport/chttp2/transport/flow_control.cc
  3. 10
      src/core/ext/transport/chttp2/transport/flow_control.h
  4. 7
      src/core/ext/transport/chttp2/transport/frame_settings.cc
  5. 2
      src/core/ext/transport/chttp2/transport/parsing.cc
  6. 4
      src/core/ext/transport/chttp2/transport/stream_lists.cc

@ -338,12 +338,10 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
} }
} }
t->dirtied_local_settings = 1; t->dirtied_local_settings = 1;
if (!true /*diable flow control */) {
/* Hack: it's common for implementations to assume 65536 bytes initial send /* Hack: it's common for implementations to assume 65536 bytes initial send
window -- this should by rights be 0 */ window -- this should by rights be 0 */
t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE; t->force_send_settings = 1 << GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE;
t->sent_local_settings = 0; t->sent_local_settings = 0;
}
t->write_buffer_size = grpc_core::chttp2::kDefaultWindow; t->write_buffer_size = grpc_core::chttp2::kDefaultWindow;
if (is_client) { if (is_client) {
@ -546,23 +544,8 @@ static void init_transport(grpc_exec_ctx* exec_ctx, grpc_chttp2_transport* t,
} }
} }
// Tune the heck out of this
const uint32_t kFrameSize = 1024 * 1024;
if (true /* disable flow control*/) { if (true /* disable flow control*/) {
t->flow_control.Init<grpc_core::chttp2::TransportFlowControlDisabled>(); t->flow_control.Init<grpc_core::chttp2::TransportFlowControlDisabled>(t);
t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
kFrameSize;
t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
kFrameSize;
t->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
kFrameSize;
t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
grpc_core::chttp2::kMaxWindow;
t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
grpc_core::chttp2::kMaxWindow;
t->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
grpc_core::chttp2::kMaxWindow;
enable_bdp = false; enable_bdp = false;
} else { } else {
t->flow_control.Init<grpc_core::chttp2::TransportFlowControl>(exec_ctx, t, t->flow_control.Init<grpc_core::chttp2::TransportFlowControl>(exec_ctx, t,
@ -739,13 +722,13 @@ static int init_stream(grpc_exec_ctx* exec_ctx, grpc_transport* gt,
post_destructive_reclaimer(exec_ctx, t); post_destructive_reclaimer(exec_ctx, t);
} }
if (true /* disable flow control */) { if (t->flow_control->flow_control_enabled()) {
s->flow_control.Init<grpc_core::chttp2::StreamFlowControlDisabled>();
} else {
s->flow_control.Init<grpc_core::chttp2::StreamFlowControl>( s->flow_control.Init<grpc_core::chttp2::StreamFlowControl>(
static_cast<grpc_core::chttp2::TransportFlowControl*>( static_cast<grpc_core::chttp2::TransportFlowControl*>(
t->flow_control.get()), t->flow_control.get()),
s); s);
} else {
s->flow_control.Init<grpc_core::chttp2::StreamFlowControlDisabled>();
} }
GPR_TIMER_END("init_stream", 0); GPR_TIMER_END("init_stream", 0);

@ -149,6 +149,25 @@ void FlowControlAction::Trace(grpc_chttp2_transport* t) const {
gpr_free(mf_str); gpr_free(mf_str);
} }
TransportFlowControlDisabled::TransportFlowControlDisabled(
grpc_chttp2_transport* t) {
remote_window_ = kMaxWindow;
target_initial_window_size_ = kMaxWindow;
announced_window_ = kMaxWindow;
t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
kFrameSize;
t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
kFrameSize;
t->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE] =
kFrameSize;
t->settings[GRPC_PEER_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
kMaxWindow;
t->settings[GRPC_SENT_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
kMaxWindow;
t->settings[GRPC_ACKED_SETTINGS][GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE] =
kMaxWindow;
}
TransportFlowControl::TransportFlowControl(grpc_exec_ctx* exec_ctx, TransportFlowControl::TransportFlowControl(grpc_exec_ctx* exec_ctx,
const grpc_chttp2_transport* t, const grpc_chttp2_transport* t,
bool enable_bdp_probe) bool enable_bdp_probe)

@ -45,11 +45,12 @@ namespace chttp2 {
static constexpr uint32_t kDefaultWindow = 65535; static constexpr uint32_t kDefaultWindow = 65535;
static constexpr int64_t kMaxWindow = (int64_t)((1u << 31) - 1); static constexpr int64_t kMaxWindow = (int64_t)((1u << 31) - 1);
// TODO(ncteisen): Tune this
static constexpr uint32_t kFrameSize = 1024 * 1024;
class TransportFlowControl; class TransportFlowControl;
class StreamFlowControl; class StreamFlowControl;
// Encapsulates a collections of actions the transport needs to take with // Encapsulates a collections of actions the transport needs to take with
// regard to flow control. Each action comes with urgencies that tell the // regard to flow control. Each action comes with urgencies that tell the
// transport how quickly the action must take place. // transport how quickly the action must take place.
@ -202,13 +203,8 @@ class TransportFlowControlBase {
// performance. // performance.
class TransportFlowControlDisabled final : public TransportFlowControlBase { class TransportFlowControlDisabled final : public TransportFlowControlBase {
public: public:
// Maxes out all values // Maxes out all values
TransportFlowControlDisabled() { TransportFlowControlDisabled(grpc_chttp2_transport* t);
remote_window_ = kMaxWindow;
target_initial_window_size_ = kMaxWindow;
announced_window_ = kMaxWindow;
}
bool flow_control_enabled() const override { return false; } bool flow_control_enabled() const override { return false; }

@ -187,9 +187,10 @@ grpc_error* grpc_chttp2_settings_parser_parse(grpc_exec_ctx* exec_ctx, void* p,
if (grpc_wire_id_to_setting_id(parser->id, &id)) { if (grpc_wire_id_to_setting_id(parser->id, &id)) {
const grpc_chttp2_setting_parameters* sp = const grpc_chttp2_setting_parameters* sp =
&grpc_chttp2_settings_parameters[id]; &grpc_chttp2_settings_parameters[id];
if ((id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE || // If flow control is disabled we skip these.
id == GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE) && if (!t->flow_control->flow_control_enabled() &&
true /* disable flow conrtol */) { (id == GRPC_CHTTP2_SETTINGS_INITIAL_WINDOW_SIZE ||
id == GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE)) {
continue; continue;
} }
if (parser->value < sp->min_value || parser->value > sp->max_value) { if (parser->value < sp->min_value || parser->value > sp->max_value) {

@ -197,7 +197,7 @@ grpc_error* grpc_chttp2_perform_read(grpc_exec_ctx* exec_ctx,
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
goto dts_fh_0; /* loop */ goto dts_fh_0; /* loop */
} else if (!true /*disable flow control*/ && } else if (t->flow_control->flow_control_enabled() &&
t->incoming_frame_size > t->incoming_frame_size >
t->settings[GRPC_ACKED_SETTINGS] t->settings[GRPC_ACKED_SETTINGS]
[GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]) { [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE]) {

@ -183,7 +183,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, void grpc_chttp2_list_add_stalled_by_transport(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) { grpc_chttp2_stream* s) {
GPR_ASSERT(!true /*flow control disabled */); GPR_ASSERT(t->flow_control->flow_control_enabled());
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT); stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT);
} }
@ -199,7 +199,7 @@ void grpc_chttp2_list_remove_stalled_by_transport(grpc_chttp2_transport* t,
void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t, void grpc_chttp2_list_add_stalled_by_stream(grpc_chttp2_transport* t,
grpc_chttp2_stream* s) { grpc_chttp2_stream* s) {
GPR_ASSERT(!true /*flow control disabled */); GPR_ASSERT(t->flow_control->flow_control_enabled());
stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM); stream_list_add(t, s, GRPC_CHTTP2_LIST_STALLED_BY_STREAM);
} }

Loading…
Cancel
Save