python-trio / python-trio/trio

Maybe use a more efficient wakeup mechanism

Open
#1,554 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

low-level
Dominant language
Python
Stars
7.3k
Forks
431
Avg merge
2d 17h
Merged PRs (30d)
6

Description

#1551 had some discussion of I/O wakeup mechanisms. For signal delivery, AFAICT we don't have any option than the current WakeupSocketpair without interpreter changes, and signals aren't delivered often enough for it to matter anyway. For cross-thread wakeups and the new guest mode wakeups, though, each of our I/O backends has a more efficient way to do a wakeup, and maybe we should use it.

  • epoll: epoll is Linux-specific, so we can use the Linux-specific eventfd interface. The man page specifies:

    Applications can use an eventfd file descriptor instead of a pipe (see pipe(2)) in all cases where a pipe is used simply to signal events. The kernel overhead of an eventfd file descriptor is much lower than that of a pipe, and only one file descriptor is required (versus the two required for a pipe).

  • kqueue: there is an EVFILT_USER for things like this; it's only documented on FreeBSD but it appears to work the same on OS X.
  • Windows: post a completion to the IOCP directly, like #1551 does

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Begin with issue #1551 and the existing I/O backend wakeup paths; the issue names epoll/eventfd, kqueue/EVFILT_USER, and Windows IOCP. Determine the scope and compatibility requirements for cross-thread and guest-mode wakeups, then define backend-specific completion criteria and tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.