-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Background
To support passive detection of connection active state for net.Conn, I attempted to create an independent epoll loop to monitor connection closure signals, thereby setting corresponding flags to extend functionality beyond the net package. This interface will significantly reduce the number of goroutines in multi-connection pool scenarios while minimizing the overhead of asynchronous reader/writer calls.
The codes is here: https://github.com/cloudwego/gopkg/pull/49/files.
However, when finalizing the feature submission, I encountered a tricky issue. I discovered that calling the syscall.EpollWait function is a blocking system call (as connection closures are low-frequency events), which occupies a P until sysmon detects it and hands off the P.
To avoid the latency impact of occupying a P, it is necessary to call runtime.entersyscallblock, but it is an unexported function.
Proposal
Therefore, I propose adding an EpollWaitBlock syscall to the src/syscall package, which would call entersyscallblock to immediately hand off the P.