Make `busy_counter_` only present in debug builds.

This reduces per-stream memory usage of QUIC.

PiperOrigin-RevId: 945405941
diff --git a/quiche/quic/core/quic_session.cc b/quiche/quic/core/quic_session.cc
index a8f8e79..49b7427 100644
--- a/quiche/quic/core/quic_session.cc
+++ b/quiche/quic/core/quic_session.cc
@@ -761,6 +761,7 @@
                   << frame.stream_id << ", offset: " << frame.offset;
 }
 
+#ifndef NDEBUG
 bool QuicSession::CheckStreamNotBusyLooping(QuicStream* stream,
                                             uint64_t previous_bytes_written,
                                             bool previous_fin_sent) {
@@ -791,6 +792,7 @@
   }
   return true;
 }
+#endif
 
 bool QuicSession::CheckStreamWriteBlocked(QuicStream* stream) const {
   if (!stream->write_side_closed() && stream->HasBufferedData() &&
@@ -906,15 +908,19 @@
     if (stream != nullptr && !stream->IsFlowControlBlocked()) {
       // If the stream can't write all bytes it'll re-add itself to the blocked
       // list.
+#ifndef NDEBUG
       uint64_t previous_bytes_written = stream->stream_bytes_written();
       bool previous_fin_sent = stream->fin_sent();
       QUIC_DVLOG(1) << ENDPOINT << "stream " << stream->id()
                     << " bytes_written " << previous_bytes_written << " fin "
                     << previous_fin_sent;
+#endif
       stream->OnCanWrite();
       QUICHE_DCHECK(CheckStreamWriteBlocked(stream));
+#ifndef NDEBUG
       QUICHE_DCHECK(CheckStreamNotBusyLooping(stream, previous_bytes_written,
                                               previous_fin_sent));
+#endif
     }
     currently_writing_stream_id_ = 0;
   }
diff --git a/quiche/quic/core/quic_session.h b/quiche/quic/core/quic_session.h
index 593bd2d..38d1fd9 100644
--- a/quiche/quic/core/quic_session.h
+++ b/quiche/quic/core/quic_session.h
@@ -1100,11 +1100,13 @@
   // control window in a negotiated config. Closes the connection if invalid.
   void OnNewSessionFlowControlWindow(QuicStreamOffset new_window);
 
+#ifndef NDEBUG
   // Debug helper for |OnCanWrite()|, check that OnStreamWrite() makes
   // forward progress.  Returns false if busy loop detected.
   bool CheckStreamNotBusyLooping(QuicStream* stream,
                                  uint64_t previous_bytes_written,
                                  bool previous_fin_sent);
+#endif
 
   // Called in OnConfigNegotiated for Finch trials to measure performance of
   // starting with larger flow control receive windows.
diff --git a/quiche/quic/core/quic_stream.cc b/quiche/quic/core/quic_stream.cc
index 3f269ca..d140e25 100644
--- a/quiche/quic/core/quic_stream.cc
+++ b/quiche/quic/core/quic_stream.cc
@@ -390,7 +390,9 @@
       connection_error_(QUIC_NO_ERROR),
       flow_controller_(std::move(flow_controller)),
       connection_flow_controller_(connection_flow_controller),
+#ifndef NDEBUG
       busy_counter_(0),
+#endif
       send_buffer_(
           session->connection()->helper()->GetStreamSendBufferAllocator()),
       buffered_data_threshold_(GetQuicFlag(quic_buffered_data_threshold)),
@@ -1485,9 +1487,11 @@
   } else {
     session_->MarkConnectionLevelWriteBlocked(id());
   }
+#ifndef NDEBUG
   if (consumed_data.bytes_consumed > 0 || consumed_data.fin_consumed) {
     busy_counter_ = 0;
   }
+#endif
   if (rst_stream_at_sent_ && stream_bytes_written() >= reliable_size_) {
     // If data up to reliable_size_ has been sent, the write side can finally
     // close.
diff --git a/quiche/quic/core/quic_stream.h b/quiche/quic/core/quic_stream.h
index 03244dd..a3a26f0 100644
--- a/quiche/quic/core/quic_stream.h
+++ b/quiche/quic/core/quic_stream.h
@@ -278,8 +278,10 @@
   uint64_t stream_bytes_read() const { return stream_bytes_read_; }
   uint64_t stream_bytes_written() const;
 
+#ifndef NDEBUG
   size_t busy_counter() const { return busy_counter_; }
   void set_busy_counter(size_t busy_counter) { busy_counter_ = busy_counter; }
+#endif
 
   // Adjust the flow control window according to new offset in |frame|.
   virtual void OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame);
@@ -601,9 +603,11 @@
   // The connection level flow controller. Not owned.
   QuicFlowController* connection_flow_controller_;
 
+#ifndef NDEBUG
   // A counter incremented when OnCanWrite() is called and no progress is made.
   // For debugging only.
   size_t busy_counter_;
+#endif
 
   // Send buffer of this stream. Send buffer is cleaned up when data gets acked
   // or discarded.