Skip to content

proposal: x/sys/unix: add EpollWaitBlock function to handoff p asap. #76290

@jayantxie

Description

@jayantxie

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.

Associated issue

#57103

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions