Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

give common blocking functions a clear name #2984

Merged
merged 1 commit into from
Nov 23, 2024

Conversation

weissi
Copy link
Member

@weissi weissi commented Nov 21, 2024

Motivation:

In many situations, for example continuous profiling with sampling profilers, it's important to distinguish between on- and off-CPU work. That's most easily done if there are clear function names/prefixes to grep for that are common places to just wait (off-CPU) and do no real work. In SwiftNIO those are chiefly three places:

  1. The EventLoops waiting for work
  2. The NIOThreadPool threads waiting for work
  3. EventLoopFuture.wait()

This patch makes sure that each of those will have a function with prefix _blockingWaitFor in the function name which is easily greppable.

Modifications:

  • Create some non-inlinable functions with _blockingWaitFor... that just wait for ....

Result:

SwiftNIO makes operational excellence easier and your SRE team more happy.

@weissi weissi requested a review from Lukasa November 21, 2024 11:18
@weissi weissi added the semver/patch No public API change. label Nov 21, 2024
@weissi weissi force-pushed the jw-blocking-names branch 5 times, most recently from cb35884 to 699bb33 Compare November 21, 2024 12:30
@@ -534,14 +567,15 @@ internal enum Posix {
}

@inline(never)
internal static func bind(descriptor: CInt, ptr: UnsafePointer<sockaddr>, bytes: Int) throws {
public static func bind(descriptor: CInt, ptr: UnsafePointer<sockaddr>, bytes: Int) throws {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we drop the changes to public here? They're very misleading.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Lukasa there were other, newer (for NIOFileSystem etc) functions that used public, so I thought I'd make it consistent with the other new stuff

@weissi weissi force-pushed the jw-blocking-names branch 2 times, most recently from 3fe2f8e to 108fbdb Compare November 21, 2024 14:49
@weissi weissi force-pushed the jw-blocking-names branch 3 times, most recently from db5199d to 9258900 Compare November 23, 2024 22:21
@weissi weissi enabled auto-merge (squash) November 23, 2024 22:31
@weissi weissi merged commit 70dfce8 into apple:main Nov 23, 2024
42 of 43 checks passed
@weissi weissi deleted the jw-blocking-names branch November 23, 2024 22:48
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.

2 participants