Waking a Thread: pipe vs eventfd vs signalfd, Measured
Pipe, eventfd, and signalfd all wake a blocked thread in about 0.04 milliseconds — there is no latency winner. The choice is what each one does with 1,000 rapid events: the pipe keeps all 1,000, eventfd counts them, signalfd keeps one.
Written November 9, 2026 · Tested with GCC 13.3.0 · 13 min read
- The three mechanisms, briefly
- The table: wake latency
- No latency winner
- The same floor, three times
What this guide is
A thread blocked in poll needs waking from another thread. Linux offers three file-descriptor ways to do it: write one byte to a pipe, write to an eventfd, or send a signal that a signalfd turns into a readable event. Every reference page says eventfd is the lightweight one — one descriptor instead of two, a counter instead of a 64 KiB buffer, lower kernel overhead. One popular guide goes further and states that benchmarks show eventfd operations complete faster than pipe operations, with the gap widening as the descriptor count grows. It publishes no table for that claim.
This guide measures all three on the same box, with the same harness and the same definition of latency: a writer thread posts one event, a waiter thread is blocked in poll, and the clock runs from just before the post to just after poll returns. The probe ran twice tonight and twice the night before, 30 repetitions per mechanism per run, and this guide reports all four runs. Where the runs disagree, the guide says so instead of picking the flattering one.
The three mechanisms, briefly
The three calls differ in what they carry and what they cost, and those differences explain the tables below.
A pipe is a byte stream with two ends. pipe returns two descriptors: pipefd[0] is the read end, pipefd[1] is the write end, and data written to the write end is buffered by the kernel until it is read. To wake a waiter, the writer writes one byte; the waiter reads one byte. The pipe costs two descriptors and preserves every byte in order.
An eventfd is a kernel-held 64-bit counter behind one descriptor, created with eventfd(2), available since Linux 2.6.22. A write adds an 8-byte value to the counter; a read returns the counter and resets it to zero, unless EFD_SEMAPHORE was set, in which case a read returns 1 and decrements the counter by 1. The descriptor is readable when the counter is greater than zero, so it slots into poll, select, and epoll like any other descriptor. One descriptor, no buffer, and the counter never loses a count — it adds them up.
A signalfd turns a signal into a readable file descriptor. The caller blocks the signals it wants in a mask with sigprocmask or pthread_sigmask, then signalfd returns a descriptor that becomes readable when one of those signals is delivered, and a read returns one signalfd_siginfo per signal. It cannot receive SIGKILL or SIGSTOP. The point of it is that signals join the same poll loop as the file descriptors, with no signal handler and no self-pipe. Its cost is the one this guide measures: a standard signal does not queue. When several identical standard signals arrive before the reader drains them, the kernel keeps one pending instance and drops the rest.
The table: wake latency
All times are milliseconds, medians of 30 repetitions, with the 90th percentile, maximum, and minimum in brackets. The median is the upper middle of the 30 sorted repetitions, the same definition as the sibling wait-latency guide.
- Pipe wake — run 1: 0.0428 (p90 0.0494, max 0.0635, min 0.0308); run 2: 0.0424 (p90 0.0463, max 0.0842, min 0.0308).
- eventfd wake — run 1: 0.0431 (p90 0.0513, max 0.0523, min 0.0301); run 2: 0.0402 (p90 0.0502, max 0.0515, min 0.0291).
- signalfd wake — run 1: 0.0462 (p90 0.0576, max 0.0894, min 0.0332); run 2: 0.0448 (p90 0.0544, max 0.0617, min 0.0334).
The night before, 2026-11-08, same probe, same box:
- Pipe wake — run 1: 0.0422; run 2: 0.0430.
- eventfd wake — run 1: 0.0409; run 2: 0.0435 (p90 0.0538, max 0.2173).
- signalfd wake — run 1: 0.0498; run 2: 0.0484.
No latency winner
All three sit on the same ~0.04 ms floor, and that is the headline. eventfd against the pipe is within 5 percent on median in all four runs: 1.007 and 0.948 tonight, 0.969 and 1.012 the night before. That is run-to-run noise, not a mechanism difference. The popular guide's claim that eventfd operations complete faster than pipe operations does not survive this measurement — not because eventfd is slow, but because the pipe is just as fast at waking one blocked thread. The counter and the single descriptor are real advantages, but they are not latency advantages at this shape of work.
signalfd is the slowest of the three on median in all four runs, but only slightly. Against the pipe it is 8 percent slower in tonight's first run (0.0462 against 0.0428), 6 percent in the second (0.0448 against 0.0424), and 18 and 13 percent on the night before (0.0498 against 0.0422, 0.0484 against 0.0430). Across the four runs, the honest statement is 6 to 18 percent slower on median — real, small, and not stable enough to quote as a single number. Its 90th percentile is also the worst of the three in all four runs, which is the more useful warning: the signal path is not only a little slower on average, it spreads wider at the tail.
One outlier deserves a line of its own. The night before, eventfd's second run had a maximum of 0.2173 ms — one repetition more than four times its median. Tonight's two runs topped out at 0.0523 and 0.0515 ms, and no other mechanism produced a maximum above 0.0902 ms in any run. The 0.2173 ms repetition is a scheduler outlier, not a mechanism cost: a thread that is woken still has to be scheduled onto a CPU, and occasionally the scheduler is busy elsewhere. It is reported here because it happened, and it is not in the table's headline because it did not repeat.
The coalescing trap: the real difference
- Pipe — one read returns 1,000 bytes. Every event is preserved, in order.
- eventfd — one read returns a single counter of 1,000. The count is preserved, the individual events are merged into it.
- signalfd — the drain returns 1
siginfo. 999 of the 1,000 signals are lost.
That is the guide's sharp edge, and it is a property of the mechanisms, not of the measurement. Standard signals do not queue: when several identical signals arrive before the reader drains them, the kernel keeps one pending instance. The eventfd counter adds instead of dropping, so nothing is lost, but the individual events are gone — a read cannot tell you when each of the 1,000 posts happened, only that 1,000 happened. Only the pipe preserves every event as a separate, ordered byte.
The choice follows from what the reader needs, not from the latency table. If the reader must act on every event separately, use the pipe. If the reader only needs to know how many events arrived, use eventfd and read the count. If the reader must not lose a signal and the signal can arrive in bursts, do not use signalfd with a standard signal: either drain fast enough that bursts never form, or use a real-time signal, which does queue — that cell was not measured here and is not claimed.
There is one more difference the latency table hides, and it cuts the other way. eventfd needs one descriptor; the pipe needs two. In a loop that watches thousands of wakeup channels, that halves the descriptor count and removes a 64 KiB pipe buffer per channel. That is a real reason to pick eventfd, and it is the reason the manual page gives: lower kernel overhead and one descriptor instead of two. It is a capacity and simplicity reason, not a wake-latency reason, and the guide states it as one.
The same floor, three times
The ~0.04 ms floor is not specific to these three mechanisms. The sibling guide on wait calls measured the same floor for poll, epoll, and select waking at low descriptor counts: 0.0411 to 0.0430 ms at 10 descriptors, with epoll flat at that floor out to 10,000 descriptors. The file-change guide measured it again for inotify waking on a file change: 0.087 ms on median, with the same scheduling shape. Three different questions, one floor: waking a blocked thread costs about 40 microseconds, and the mechanism underneath it does not move that number. Below that floor there is nothing to optimize — the cost is the scheduler waking a thread, not the descriptor type.
One outside number is worth naming so it is not mistaken for a contradiction. A Wayland loop-wakeup study measured eventfd alone at a median of 11 microseconds, minimum 6, across 300 posts. That is a different harness: a producer posting into a loop that is already running its own dispatch cycle, on bare metal, with the poll wake itself at 6 to 25 microseconds. This guide wakes a thread blocked in poll from another thread on WSL2, so the scheduler's thread wakeup is inside the measured interval. The two numbers describe different paths and do not contradict each other; what this guide adds is the three mechanisms measured against each other on one harness, where the difference is zero.
What the numbers do not say
The probe wakes one thread, once per repetition, with the waiter already blocked. It does not measure throughput: how many wakeups per second each mechanism sustains, or how the cost grows when thousands of threads wake at once. The copyprogramming claim that the gap widens as the descriptor count grows is a throughput claim at scale, and this probe does not test it — it tests one waiter, three mechanisms, one wakeup at a time.
The probe does not pin CPUs. Both threads run wherever the scheduler puts them on 32 CPUs, the same as the sibling wait-latency guide, so the numbers include real scheduling jitter. Pinning would tighten the ranges and would not change the ranking: the medians already agree across four runs within a few percent.
The signal arm uses SIGUSR1, a standard signal, sent with pthread_kill to the waiter thread. Real-time signals queue and would behave differently under the coalescing test; they were not measured. The eventfd arm uses counter mode, not EFD_SEMAPHORE mode, so the one-read-consumes-all result is the counter-mode result. Semaphore mode returns 1 per read and decrements, which changes the drain shape but not the wake latency.
The machine is WSL2, kernel 6.18.33.2, 32 CPUs, GCC 13.3.0, no CPU pinning, warm page cache. A bare-metal machine with fewer CPUs or a loaded scheduler would show a different floor, and a real-time kernel would show a tighter one. The ranking — a tie on latency, a sharp split on loss — is the part that should travel; the 0.04 ms absolute number is this box's.
Checklist
- Before choosing a wakeup mechanism on latency, check the table: all three wake a blocked thread in about 0.04 ms, so latency does not decide this choice.
- Before picking
eventfdfor speed, check what is faster: the counter and the single descriptor are real advantages, but the wake latency ties the pipe within 5 percent in all four runs. - Before using
signalfdwith a standard signal for bursty events, count the loss: 1,000 rapid signals drain as 1siginfo, and the other 999 are gone. - Before treating
eventfdas lossless, check the read: the count survives, the individual events do not — one read returns 1,000, not 1,000 separate events. - Before trusting a single median for
signalfd, check the range: it is 6 to 18 percent slower than the pipe across four runs, and its 90th percentile is the worst of the three in every run. - Before comparing these numbers to the Wayland 11-microsecond figure, check the harness: that is
eventfdalone inside a running loop, this is a cross-thread wakeup on WSL2, and the two measure different paths. - Before reproducing the probe, drain the
signalfdin the thread the signal was sent to, and keep the pipe's write end separate from the polled read end — both mistakes fail all 30 repetitions. - Before applying the 0.04 ms floor elsewhere, remember the setup: WSL2, 32 CPUs, no pinning, one waiter — the floor is scheduling, and the ranking is the portable part.
Related guides on this site
- inotify vs Polling: Measured Wake Latency, Queue Overflow, and the Non-Recursive Trap
- epoll vs poll vs select, Measured: Where the Crossover Actually Is
- How Fast Does systemd Restart a Crashed Service? Restart=always vs on-failure, Measured — and the Crash Loop It Refuses
- Copying a Directory Tree, Measured: cp -a vs rsync -a vs tar-pipe
Sources
- Linux man-pages project, pipe(2) — read on the box 2026-11-09:
pipereturns two descriptors,pipefd[0]the read end andpipefd[1]the write end; data written to the write end is buffered by the kernel until it is read. - Linux man-pages project, eventfd(2) — read on the box 2026-11-09:
eventfdcreates an object holding an unsigned 64-bit counter; a read returns the counter and resets it to zero, or returns 1 and decrements by 1 withEFD_SEMAPHORE; a write adds to the counter; the descriptor is readable when the counter is greater than zero; available since Linux 2.6.22. - Linux man-pages project, signalfd(2) — read on the box 2026-11-09:
signalfdcreates a descriptor for accepting signals targeted at the caller, monitored byselect,poll, andepoll; the signals in the mask should be blocked withsigprocmask;SIGKILLandSIGSTOPcannot be received through it. - IPC-Bench, Signals and Event Descriptors — read in full 2026-11-09: the suite's signal implementation is marked broken because signals can be lost or coalesced and timing is hard to measure;
eventfdis functional but its performance data is "Not published" in the benchmark table; counters are never lost, signals can be lost or coalesced. - Sparkles, Wayland F05 — loop wakeup and external fds — read in full 2026-11-09:
eventfdalone, 300 posts into a Wayland loop, median 11 microseconds, minimum 6, p90 24, p99 238, maximum 406; the poll wake itself is 6 to 25 microseconds and the long tail is the loop being busy in a dispatch pass, not the kernel. - copyprogramming, Understanding eventfd in Linux — read in full 2026-11-09: states
eventfduses 50 to 80 percent less memory than pipes and that benchmarks showeventfdoperations complete faster than pipe operations, with the gap widening as the descriptor count grows; it publishes no measured table for that claim. - Veldica, epoll vs poll vs select, Measured: Where the Crossover Actually Is — the sibling guide: the same ~0.04 ms wake floor measured for wait calls at low descriptor counts, and the same median definition (upper middle of 30).
- Veldica, inotify vs Polling: Measured Wake Latency, Queue Overflow, and the Non-Recursive Trap — the sibling guide: the same scheduling floor measured for file-change notification, and the same no-pinning harness.
Keep Exploring
Paste a [Service] section and get a plain-language verdict on every sandboxing setting it finds.
Paste sshd -G output and get a hardening verdict on the values your server actually runs.
Paste a server block and get WebSocket, TLS, HSTS, and proxy-header verdicts.
Paste a systemd timer expression and get the specific reason it fails, the normalized form, and the past-date traps the built-in check hides.
The full sysadmin hub \u2014 systemd, cgroups, file tools, and measured Linux comparisons.