Skip to content

Conversation

@weissi
Copy link
Member

@weissi weissi commented Nov 7, 2025

Motivation:

Unfortunately, even if no metics delegate has been configured, significant work is being done each EL tick. Concretely:

  • 2 NIODealine.now() calls which are expensive particularly on some hypervisors (may cause a VMEXIT!)
  • Some unnecessary calculations

Modifications:

  • Only perform the metrics delegate work if a delegate has actually been set

Result:

If no delegate is set, each EL tick will now be faster.

@weissi weissi requested a review from Lukasa November 7, 2025 23:59
@weissi weissi added the 🔨 semver/patch No public API change. label Nov 8, 2025
@weissi
Copy link
Member Author

weissi commented Nov 8, 2025

CC @hamzahrmalik

@weissi weissi force-pushed the jw-no-delegate-no-slow branch from 73c7489 to f66497b Compare November 8, 2025 00:03
Copy link
Contributor

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

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

Thanks!

@weissi weissi enabled auto-merge (squash) November 10, 2025 10:22
@weissi
Copy link
Member Author

weissi commented Nov 10, 2025

@glbrntt do you know about the benchmarks?

--- a/Benchmarks/Thresholds/6.2/NIOPosixBenchmarks.TCPEcho.p90.json
+++ b/Benchmarks/Thresholds/6.2/NIOPosixBenchmarks.TCPEcho.p90.json
@@ -1,3 +1,4 @@
 {
-  "mallocCountTotal" : 608
-}
+  "mallocCountTotal" : 613,
+  "wallClock" : 6097356667
+}
\ No newline at end of file
diff --git a/Benchmarks/Thresholds/6.2/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json b/Benchmarks/Thresholds/6.2/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
index f0d21b9..b0c41ef 100644
--- a/Benchmarks/Thresholds/6.2/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
+++ b/Benchmarks/Thresholds/6.2/NIOPosixBenchmarks.TCPEchoAsyncChannel.p90.json
@@ -1,3 +1,4 @@
 {
-  "mallocCountTotal" : 82530
+  "mallocCountTotal" : 82278,
+  "wallClock" : 14359068200
 }

what does that mean?

@Lukasa
Copy link
Contributor

Lukasa commented Nov 10, 2025

Nothing, it means that swift-package-benchmark has stopped being reliable. I'll re-run for now.

@weissi
Copy link
Member Author

weissi commented Nov 10, 2025

Nothing, it means that swift-package-benchmark has stopped being reliable. I'll re-run for now.

Hmm, I've done it a bunch of times for 6.2, seems consistently failing. But I did only re-run the failing tests not everything

@weissi
Copy link
Member Author

weissi commented Nov 10, 2025

@Lukasa yeah failed again :\

@weissi
Copy link
Member Author

weissi commented Nov 14, 2025

@Lukasa how can I get this in? The PRBs are very unstable, sometimes 1 fails, sometimes 3 fail, never gotten it to zero :'(

@glbrntt
Copy link
Contributor

glbrntt commented Nov 14, 2025

@Lukasa how can I get this in? The PRBs are very unstable, sometimes 1 fails, sometimes 3 fail, never gotten it to zero :'(

The alloc count is low in that test (TCPEcho) and presumably amortises to zero per iteration so we could just add some slack to that particular test. There's an example in the TCPEchoAsyncChannel test of how to do this. WDYT?

@Lukasa
Copy link
Contributor

Lukasa commented Nov 19, 2025

Works for me.

@weissi weissi merged commit 3eea092 into apple:main Nov 20, 2025
55 of 56 checks passed
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