Fix logging in QuicFlowController gfe-relnote: n/a (change to DLOGs only) PiperOrigin-RevId: 258415201 Change-Id: I1c95c8ae0621506a496ce8f63d0673ce80f43feb
diff --git a/quic/core/quic_flow_controller.cc b/quic/core/quic_flow_controller.cc index 3fb5d75..dbc5100 100644 --- a/quic/core/quic_flow_controller.cc +++ b/quic/core/quic_flow_controller.cc
@@ -21,6 +21,13 @@ #define ENDPOINT \ (perspective_ == Perspective::IS_SERVER ? "Server: " : "Client: ") +std::string QuicFlowController::LogLabel() { + if (is_connection_flow_controller_) { + return "connection"; + } + return QuicStrCat("stream ", id_); +} + QuicFlowController::QuicFlowController( QuicSession* session, QuicStreamId id, @@ -51,7 +58,7 @@ QuicUtils::GetInvalidStreamId( session_->connection()->transport_version()) == id_); - QUIC_DVLOG(1) << ENDPOINT << "Created flow controller for stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << "Created flow controller for " << LogLabel() << ", setting initial receive window offset to: " << receive_window_offset_ << ", max receive window to: " << receive_window_size_ @@ -62,8 +69,8 @@ void QuicFlowController::AddBytesConsumed(QuicByteCount bytes_consumed) { bytes_consumed_ += bytes_consumed; - QUIC_DVLOG(1) << ENDPOINT << "Stream " << id_ << " consumed " - << bytes_consumed_ << " bytes."; + QUIC_DVLOG(1) << ENDPOINT << LogLabel() << " consumed " << bytes_consumed_ + << " bytes."; MaybeSendWindowUpdate(); } @@ -75,7 +82,7 @@ return false; } - QUIC_DVLOG(1) << ENDPOINT << "Stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << LogLabel() << " highest byte offset increased from " << highest_received_byte_offset_ << " to " << new_offset; highest_received_byte_offset_ = new_offset; @@ -84,7 +91,7 @@ void QuicFlowController::AddBytesSent(QuicByteCount bytes_sent) { if (bytes_sent_ + bytes_sent > send_window_offset_) { - QUIC_BUG << ENDPOINT << "Stream " << id_ << " Trying to send an extra " + QUIC_BUG << ENDPOINT << LogLabel() << " Trying to send an extra " << bytes_sent << " bytes, when bytes_sent = " << bytes_sent_ << ", and send_window_offset_ = " << send_window_offset_; bytes_sent_ = send_window_offset_; @@ -99,13 +106,13 @@ } bytes_sent_ += bytes_sent; - QUIC_DVLOG(1) << ENDPOINT << "Stream " << id_ << " sent " << bytes_sent_ + QUIC_DVLOG(1) << ENDPOINT << LogLabel() << " sent " << bytes_sent_ << " bytes."; } bool QuicFlowController::FlowControlViolation() { if (highest_received_byte_offset_ > receive_window_offset_) { - QUIC_DLOG(INFO) << ENDPOINT << "Flow control violation on stream " << id_ + QUIC_DLOG(INFO) << ENDPOINT << "Flow control violation on " << LogLabel() << ", receive window offset: " << receive_window_offset_ << ", highest received byte offset: " << highest_received_byte_offset_; @@ -128,7 +135,7 @@ QuicTime prev = prev_window_update_time_; prev_window_update_time_ = now; if (!prev.IsInitialized()) { - QUIC_DVLOG(1) << ENDPOINT << "first window update for stream " << id_; + QUIC_DVLOG(1) << ENDPOINT << "first window update for " << LogLabel(); return; } @@ -140,7 +147,7 @@ QuicTime::Delta rtt = connection_->sent_packet_manager().GetRttStats()->smoothed_rtt(); if (rtt.IsZero()) { - QUIC_DVLOG(1) << ENDPOINT << "rtt zero for stream " << id_; + QUIC_DVLOG(1) << ENDPOINT << "rtt zero for " << LogLabel(); return; } @@ -157,7 +164,7 @@ IncreaseWindowSize(); if (receive_window_size_ > old_window) { - QUIC_DVLOG(1) << ENDPOINT << "New max window increase for stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << "New max window increase for " << LogLabel() << " after " << since_last.ToMicroseconds() << " us, and RTT is " << rtt.ToMicroseconds() << "us. max wndw: " << receive_window_size_; @@ -168,7 +175,7 @@ } else { // TODO(ckrasic) - add a varz to track this (?). QUIC_LOG_FIRST_N(INFO, 1) - << ENDPOINT << "Max window at limit for stream " << id_ << " after " + << ENDPOINT << "Max window at limit for " << LogLabel() << " after " << since_last.ToMicroseconds() << " us, and RTT is " << rtt.ToMicroseconds() << "us. Limit size: " << receive_window_size_; } @@ -199,7 +206,7 @@ } if (available_window >= threshold) { - QUIC_DVLOG(1) << ENDPOINT << "Not sending WindowUpdate for stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << "Not sending WindowUpdate for " << LogLabel() << ", available window: " << available_window << " >= threshold: " << threshold; return; @@ -214,7 +221,7 @@ // Update our receive window. receive_window_offset_ += (receive_window_size_ - available_window); - QUIC_DVLOG(1) << ENDPOINT << "Sending WindowUpdate frame for stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << "Sending WindowUpdate frame for " << LogLabel() << ", consumed bytes: " << bytes_consumed_ << ", available window: " << available_window << ", and threshold: " << WindowUpdateThreshold() @@ -229,8 +236,7 @@ last_blocked_send_window_offset_ >= send_window_offset_) { return false; } - QUIC_DLOG(INFO) << ENDPOINT << "Stream " << id_ - << " is flow control blocked. " + QUIC_DLOG(INFO) << ENDPOINT << LogLabel() << " is flow control blocked. " << "Send window: " << SendWindowSize() << ", bytes sent: " << bytes_sent_ << ", send limit: " << send_window_offset_; @@ -250,7 +256,7 @@ return false; } - QUIC_DVLOG(1) << ENDPOINT << "UpdateSendWindowOffset for stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << "UpdateSendWindowOffset for " << LogLabel() << " with new offset " << new_send_window_offset << " current offset: " << send_window_offset_ << " bytes_sent: " << bytes_sent_; @@ -286,7 +292,7 @@ void QuicFlowController::UpdateReceiveWindowSize(QuicStreamOffset size) { DCHECK_LE(size, receive_window_size_limit_); - QUIC_DVLOG(1) << ENDPOINT << "UpdateReceiveWindowSize for stream " << id_ + QUIC_DVLOG(1) << ENDPOINT << "UpdateReceiveWindowSize for " << LogLabel() << ": " << size; if (receive_window_size_ != receive_window_offset_) { QUIC_BUG << "receive_window_size_:" << receive_window_size_
diff --git a/quic/core/quic_flow_controller.h b/quic/core/quic_flow_controller.h index 4de292c..e627c8c 100644 --- a/quic/core/quic_flow_controller.h +++ b/quic/core/quic_flow_controller.h
@@ -121,6 +121,10 @@ // Double the window size as long as we haven't hit the max window size. void IncreaseWindowSize(); + // Returns "stream $ID" (where $ID is set to |id_|) or "connection" based on + // |is_connection_flow_controller_|. + std::string LogLabel(); + // The parent session/connection, used to send connection close on flow // control violation, and WINDOW_UPDATE and BLOCKED frames when appropriate. // Not owned.