From fb1ae21fb72ff3ad7d0dcf07f5209fbd2712a652 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Fri, 24 Oct 2025 21:24:51 +0800 Subject: [PATCH] chore: remove unused code --- transport/tuic/common/congestion.go | 4 ---- transport/tuic/congestion/bbr_sender.go | 3 --- transport/tuic/congestion/clock.go | 18 ------------------ transport/tuic/congestion/cubic.go | 5 +---- transport/tuic/congestion/cubic_sender.go | 7 +------ transport/tuic/congestion_v2/bbr_sender.go | 11 +++-------- transport/tuic/congestion_v2/clock.go | 20 -------------------- 7 files changed, 5 insertions(+), 63 deletions(-) delete mode 100644 transport/tuic/congestion/clock.go delete mode 100644 transport/tuic/congestion_v2/clock.go diff --git a/transport/tuic/common/congestion.go b/transport/tuic/common/congestion.go index afcf7a78..fb0956bc 100644 --- a/transport/tuic/common/congestion.go +++ b/transport/tuic/common/congestion.go @@ -21,7 +21,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) { case "cubic": quicConn.SetCongestionControl( congestion.NewCubicSender( - congestion.DefaultClock{}, congestion.GetInitialPacketSize(quicConn), false, ), @@ -29,7 +28,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) { case "new_reno": quicConn.SetCongestionControl( congestion.NewCubicSender( - congestion.DefaultClock{}, congestion.GetInitialPacketSize(quicConn), true, ), @@ -37,7 +35,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) { case "bbr_meta_v1": quicConn.SetCongestionControl( congestion.NewBBRSender( - congestion.DefaultClock{}, congestion.GetInitialPacketSize(quicConn), c.ByteCount(cwnd)*congestion.InitialMaxDatagramSize, congestion.DefaultBBRMaxCongestionWindow*congestion.InitialMaxDatagramSize, @@ -48,7 +45,6 @@ func SetCongestionController(quicConn *quic.Conn, cc string, cwnd int) { case "bbr": quicConn.SetCongestionControl( congestionv2.NewBbrSender( - congestionv2.DefaultClock{}, congestionv2.GetInitialPacketSize(quicConn), c.ByteCount(cwnd), ), diff --git a/transport/tuic/congestion/bbr_sender.go b/transport/tuic/congestion/bbr_sender.go index 7f41d5be..7a753491 100644 --- a/transport/tuic/congestion/bbr_sender.go +++ b/transport/tuic/congestion/bbr_sender.go @@ -101,7 +101,6 @@ const ( type bbrSender struct { mode bbrMode - clock Clock rttStats congestion.RTTStatsProvider bytesInFlight congestion.ByteCount // return total bytes of unacked packets. @@ -232,14 +231,12 @@ type bbrSender struct { } func NewBBRSender( - clock Clock, initialMaxDatagramSize, initialCongestionWindow, initialMaxCongestionWindow congestion.ByteCount, ) *bbrSender { b := &bbrSender{ mode: STARTUP, - clock: clock, sampler: NewBandwidthSampler(), maxBandwidth: NewWindowedFilter(int64(BandwidthWindowSize), MaxFilter), maxAckHeight: NewWindowedFilter(int64(BandwidthWindowSize), MaxFilter), diff --git a/transport/tuic/congestion/clock.go b/transport/tuic/congestion/clock.go deleted file mode 100644 index 405fae70..00000000 --- a/transport/tuic/congestion/clock.go +++ /dev/null @@ -1,18 +0,0 @@ -package congestion - -import "time" - -// A Clock returns the current time -type Clock interface { - Now() time.Time -} - -// DefaultClock implements the Clock interface using the Go stdlib clock. -type DefaultClock struct{} - -var _ Clock = DefaultClock{} - -// Now gets the current time -func (DefaultClock) Now() time.Time { - return time.Now() -} diff --git a/transport/tuic/congestion/cubic.go b/transport/tuic/congestion/cubic.go index 35c3f0cb..b92c5b6f 100644 --- a/transport/tuic/congestion/cubic.go +++ b/transport/tuic/congestion/cubic.go @@ -37,8 +37,6 @@ const betaLastMax float32 = 0.85 // Cubic implements the cubic algorithm from TCP type Cubic struct { - clock Clock - // Number of connections to simulate. numConnections int @@ -67,9 +65,8 @@ type Cubic struct { } // NewCubic returns a new Cubic instance -func NewCubic(clock Clock) *Cubic { +func NewCubic() *Cubic { c := &Cubic{ - clock: clock, numConnections: defaultNumConnections, } c.Reset() diff --git a/transport/tuic/congestion/cubic_sender.go b/transport/tuic/congestion/cubic_sender.go index dcf63a0a..54fb203e 100644 --- a/transport/tuic/congestion/cubic_sender.go +++ b/transport/tuic/congestion/cubic_sender.go @@ -23,7 +23,6 @@ type cubicSender struct { rttStats congestion.RTTStatsProvider cubic *Cubic pacer *pacer - clock Clock reno bool @@ -61,12 +60,10 @@ var ( // NewCubicSender makes a new cubic sender func NewCubicSender( - clock Clock, initialMaxDatagramSize congestion.ByteCount, reno bool, ) *cubicSender { return newCubicSender( - clock, reno, initialMaxDatagramSize, initialCongestionWindow*initialMaxDatagramSize, @@ -75,7 +72,6 @@ func NewCubicSender( } func newCubicSender( - clock Clock, reno bool, initialMaxDatagramSize, initialCongestionWindow, @@ -89,8 +85,7 @@ func newCubicSender( initialMaxCongestionWindow: initialMaxCongestionWindow, congestionWindow: initialCongestionWindow, slowStartThreshold: MaxByteCount, - cubic: NewCubic(clock), - clock: clock, + cubic: NewCubic(), reno: reno, maxDatagramSize: initialMaxDatagramSize, } diff --git a/transport/tuic/congestion_v2/bbr_sender.go b/transport/tuic/congestion_v2/bbr_sender.go index 6020ab39..ac17c355 100644 --- a/transport/tuic/congestion_v2/bbr_sender.go +++ b/transport/tuic/congestion_v2/bbr_sender.go @@ -96,7 +96,6 @@ const ( type bbrSender struct { rttStats congestion.RTTStatsProvider - clock Clock pacer *Pacer mode bbrMode @@ -244,12 +243,10 @@ type bbrSender struct { var _ congestion.CongestionControl = &bbrSender{} func NewBbrSender( - clock Clock, initialMaxDatagramSize congestion.ByteCount, initialCongestionWindowPackets congestion.ByteCount, ) *bbrSender { return newBbrSender( - clock, initialMaxDatagramSize, initialCongestionWindowPackets*initialMaxDatagramSize, congestion.MaxCongestionWindowPackets*initialMaxDatagramSize, @@ -257,13 +254,11 @@ func NewBbrSender( } func newBbrSender( - clock Clock, initialMaxDatagramSize, initialCongestionWindow, initialMaxCongestionWindow congestion.ByteCount, ) *bbrSender { b := &bbrSender{ - clock: clock, mode: bbrModeStartup, sampler: newBandwidthSampler(roundTripCount(bandwidthWindowSize)), lastSentPacket: invalidPacketNumber, @@ -297,7 +292,7 @@ func newBbrSender( } */ - b.enterStartupMode(b.clock.Now()) + b.enterStartupMode() b.setHighCwndGain(derivedHighCWNDGain) return b @@ -605,7 +600,7 @@ func (b *bbrSender) maybeUpdateMinRtt(now monotime.Time, sampleMinRtt time.Durat } // Enters the STARTUP mode. -func (b *bbrSender) enterStartupMode(now monotime.Time) { +func (b *bbrSender) enterStartupMode() { b.mode = bbrModeStartup // b.maybeTraceStateChange(logging.CongestionStateStartup) b.pacingGain = b.highGain @@ -757,7 +752,7 @@ func (b *bbrSender) maybeEnterOrExitProbeRtt(now monotime.Time, isRoundStart, mi if now.Sub(b.exitProbeRttAt) >= 0 && b.probeRttRoundPassed { b.minRttTimestamp = now if !b.isAtFullBandwidth { - b.enterStartupMode(now) + b.enterStartupMode() } else { b.enterProbeBandwidthMode(now) } diff --git a/transport/tuic/congestion_v2/clock.go b/transport/tuic/congestion_v2/clock.go deleted file mode 100644 index e6ea35db..00000000 --- a/transport/tuic/congestion_v2/clock.go +++ /dev/null @@ -1,20 +0,0 @@ -package congestion - -import ( - "github.com/metacubex/quic-go/monotime" -) - -// A Clock returns the current time -type Clock interface { - Now() monotime.Time -} - -// DefaultClock implements the Clock interface using the Go stdlib clock. -type DefaultClock struct{} - -var _ Clock = DefaultClock{} - -// Now gets the current time -func (DefaultClock) Now() monotime.Time { - return monotime.Now() -}