Skip to content

SwiftQUIC: PERF: Avoid per-path scan unless round trip time has elapsed - #79

Merged
agnosticdev merged 2 commits into
mainfrom
agnosticdev/PerPathScan
Aug 14, 2026
Merged

SwiftQUIC: PERF: Avoid per-path scan unless round trip time has elapsed#79
agnosticdev merged 2 commits into
mainfrom
agnosticdev/PerPathScan

Conversation

@agnosticdev

Copy link
Copy Markdown
Collaborator

Each call to updateMaximumUnreadInboundBytesAllowed does a per-path scan on each inbound packet to tune the receive buffer.
This change gates the per-path scan behind a full round trip elapsing. This is based on the smoothedRTT of the current path.

Top of tree:

98.93 M 52.6%		  QUICStreamInstance.updateMaximumUnreadInboundBytesAllowed(dataLengthAdded:connection:)
84.00 M 44.7%	-      	specialized ManyToManyProtocolHandler.applyToAllPaths(_:)
44.00 M 23.4%	-      	  specialized Sequence.forEach(_:)
40.00 M 21.3%	-      	  protocol witness for ManyToManyProtocolHandler.multiplexingPaths.getter in conformance QUICConnection
2.00 M  1.1%	-	    FlowControlGlobals.shared.unsafeMutableAddressor
1.00 M  0.5%	- 	    QUICStreamInstance.computeReceiveHighWaterMarkIncrease(dataLength:rtt:mss:now:)

With this change:

42.62 M 48.1%	-      	QUICStreamInstance.updateMaximumUnreadInboundBytesAllowed(dataLengthAdded:connection:)
42.62 M 48.1%	-	      QUICStreamInstance.computeReceiveHighWaterMarkIncrease(dataLength:connection:now:)
35.62 M 40.2%	-      	   QUICPath.smoothedRTT.getter
22.00 M 24.8%	-	        swift_beginAccess	
8.19 M  9.2%	-	        <deduplicated_symbol>	
5.42 M  6.1%	- 	        DYLD-STUB$$swift_beginAccess

Savings of 56 megacycles for both client and server so 112 megacycles total.

@agnosticdev

Copy link
Copy Markdown
Collaborator Author

Note that the build issue on nightly-main is a known issue right now.

@rnro rnro added the 🔨 semver/patch No public API change. label Aug 13, 2026
var largestPathMSS: UInt64 = 0
var largestPathRTT: NetworkDuration = .zero

connection.applyToAllPaths { path in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code was getting the largest MSS and RTT across all paths. The newer code looks like it just looks at the current path. Is that a problem?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I asked @agnosticdev to remove it because this left over code (MPQUIC) which we don't need right now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we do not need it right now.

@agnosticdev agnosticdev added 🔨 semver/patch No public API change. and removed 🔨 semver/patch No public API change. labels Aug 14, 2026
@agnosticdev
agnosticdev merged commit 85103b4 into main Aug 14, 2026
24 of 25 checks passed
@agnosticdev
agnosticdev deleted the agnosticdev/PerPathScan branch August 14, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants