Skip to content

Commit 36f59c2

Browse files
wang178ccopybara-github
authored andcommitted
Add a knob (QuicSentPacketManager::ReduceMemoryUsage) to reduce the memory used by unacked_packet_map and bandwidth_sampler owned by QuicSentPacketManager.
In follow-up, this knob can be used if the session is idled long enough. PiperOrigin-RevId: 875952422
1 parent d556e8e commit 36f59c2

File tree

10 files changed

+21
-0
lines changed

10 files changed

+21
-0
lines changed

quiche/quic/core/congestion_control/bandwidth_sampler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ class QUICHE_EXPORT BandwidthSampler : public BandwidthSamplerInterface {
447447
return overestimate_avoidance_;
448448
}
449449

450+
void ReduceMemoryUsage() { connection_state_map_.shrink_to_fit(); }
451+
450452
private:
451453
friend class test::BandwidthSamplerPeer;
452454

quiche/quic/core/congestion_control/bbr2_misc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ class QUICHE_EXPORT Bbr2NetworkModel {
546546
return rounds_with_queueing_;
547547
}
548548

549+
void ReduceMemoryUsage() { bandwidth_sampler_.ReduceMemoryUsage(); }
550+
549551
private:
550552
// Called when a new round trip starts.
551553
void OnNewRound();

quiche/quic/core/congestion_control/bbr2_sender.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class QUICHE_EXPORT Bbr2Sender final : public SendAlgorithmInterface {
100100

101101
bool EnableECT0() override { return false; }
102102
bool EnableECT1() override { return false; }
103+
void ReduceMemoryUsage() override { model_.ReduceMemoryUsage(); }
103104
// End implementation of SendAlgorithmInterface.
104105

105106
const Bbr2Params& Params() const { return params_; }

quiche/quic/core/congestion_control/bbr_sender.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class QUICHE_EXPORT BbrSender : public SendAlgorithmInterface {
136136
void PopulateConnectionStats(QuicConnectionStats* stats) const override;
137137
bool EnableECT0() override { return false; }
138138
bool EnableECT1() override { return false; }
139+
void ReduceMemoryUsage() override { sampler_.ReduceMemoryUsage(); }
139140
// End implementation of SendAlgorithmInterface.
140141

141142
// Gets the number of RTTs BBR remains in STARTUP phase.

quiche/quic/core/congestion_control/send_algorithm_interface.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ class QUICHE_EXPORT SendAlgorithmInterface {
194194
// ECN mode is enabled, it is an error to call either of these methods.
195195
virtual bool EnableECT0() = 0;
196196
virtual bool EnableECT1() = 0;
197+
198+
// Called to reduce the memory usage of the send algorithm.
199+
virtual void ReduceMemoryUsage() = 0;
197200
};
198201

199202
} // namespace quic

quiche/quic/core/congestion_control/tcp_cubic_sender_bytes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class QUICHE_EXPORT TcpCubicSenderBytes : public SendAlgorithmInterface {
7878
void PopulateConnectionStats(QuicConnectionStats* /*stats*/) const override {}
7979
bool EnableECT0() override { return false; }
8080
bool EnableECT1() override { return false; }
81+
void ReduceMemoryUsage() override {}
8182
// End implementation of SendAlgorithmInterface.
8283

8384
QuicByteCount min_congestion_window() const { return min_congestion_window_; }

quiche/quic/core/packet_number_indexed_queue.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ class QUICHE_NO_EXPORT PacketNumberIndexedQueue {
9696
// Reserves the specified memory capacity in the underlying deque.
9797
void Reserve(size_t capacity) { entries_.reserve(capacity); }
9898

99+
// Reduces the capacity of the underlying deque.
100+
void shrink_to_fit() { entries_.shrink_to_fit(); }
101+
99102
private:
100103
// Wrapper around T used to mark whether the entry is actually in the map.
101104
struct QUICHE_NO_EXPORT EntryWrapper : T {

quiche/quic/core/quic_sent_packet_manager.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,11 @@ class QUICHE_EXPORT QuicSentPacketManager {
417417
return send_algorithm_.get();
418418
}
419419

420+
void ReduceMemoryUsage() {
421+
unacked_packets_.ReduceMemoryUsage();
422+
send_algorithm_->ReduceMemoryUsage();
423+
}
424+
420425
// Wrapper for SendAlgorithmInterface functions, since these functions are
421426
// not const.
422427
bool EnableECT0() {

quiche/quic/core/quic_unacked_packet_map.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ class QUICHE_EXPORT QuicUnackedPacketMap {
269269
", packets_in_flight: ", packets_in_flight_, "}");
270270
}
271271

272+
void ReduceMemoryUsage() { unacked_packets_.shrink_to_fit(); }
273+
272274
private:
273275
friend class test::QuicUnackedPacketMapPeer;
274276

quiche/quic/test_tools/quic_test_utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,7 @@ class MockSendAlgorithm : public SendAlgorithmInterface {
12551255
(const, override));
12561256
MOCK_METHOD(bool, EnableECT0, (), (override));
12571257
MOCK_METHOD(bool, EnableECT1, (), (override));
1258+
MOCK_METHOD(void, ReduceMemoryUsage, (), (override));
12581259
};
12591260

12601261
class MockLossAlgorithm : public LossDetectionInterface {

0 commit comments

Comments
 (0)