Linux

epoll vs poll vs select, Measured: Where the Crossover Actually Is

One wait call over 10,000 idle file descriptors costs poll 0.30 ms and epoll 0.0003 ms. Wake latency ties at 10 fds and differs 30-fold at 10,000.

Written November 9, 2026 · Tested with GCC 13.3.0 · 11 min read

By the end of this guide
  • The three calls, briefly
  • Arm A: the cost of one wait call
  • Arm B: wake latency, one descriptor becomes ready
  • The control: the ready descriptor's position does not matter

What this guide is

Every tutorial on Linux I/O multiplexing says the same three things: select is O(n), poll is O(n), epoll is O(ready). The statements are true and almost useless, because they never say where the difference starts to matter. At 10 file descriptors the three calls are indistinguishable. At 10,000 they differ by a factor of 1,000. This guide measures the curve between those two points, in two arms: the cost of one wait call over idle descriptors, and the time from one descriptor becoming ready to the waiter waking up.

The watched descriptors are pipes: each pipe contributes one read end to the wait set, and the writer writes one byte to make exactly one descriptor ready. Every cell is 30 repetitions, and every number in the tables below is the median of those 30, defined as the upper middle value of the sorted 30.

The three calls, briefly

The three calls answer the same question, "wake me when one of these descriptors is ready," with three different contracts, and the contracts explain the curves below.

select takes three fixed-size bitmasks, one per direction, and a count. The set size is capped by FD_SETSIZE, which is 1024 on Linux, and the manual page states that the sets are modified on return, so the caller rebuilds them on every call. That rebuild is part of the honest cost of select, and the probe pays it: the fd set is rebuilt from scratch on every repetition.

poll takes an array of struct pollfd, one entry per descriptor, with no FD_SETSIZE cap. The kernel fills in each entry's revents field with what actually happened. The caller hands the kernel the whole array on every call, and the kernel walks it on every call. That walk is the cost that grows with the descriptor count.

epoll splits the work in two. The caller registers each descriptor once with epoll_ctl, and from then on calls epoll_wait, which returns only the descriptors that are ready, from the kernel's ready list. The registration is a one-time cost, measured below, and the wait itself does not touch the idle descriptors. The default mode is level-triggered: a descriptor that stays ready keeps being reported.

Arm A: the cost of one wait call

The first arm times a single non-blocking wait call over N idle descriptors. The timeout is zero, so nothing is ready and the call returns immediately. This is the pure per-call cost of the mechanism, with no wakeup and no scheduling in the number.

N select poll epoll
10 0.0009 0.0007 0.0003
100 0.0041 0.0040 0.0004
1,000 — 0.0282 0.0004
5,000 — 0.1433 0.0003
10,000 — 0.2979 0.0003

All times are milliseconds, medians of 30. The dash for select above 100 is not missing data: select stops being usable well before 1,000 pipes, and the ceiling is measured in its own section below.

Three readings follow from the table. First, poll scales linearly: from 0.0007 ms at 10 descriptors to 0.2979 ms at 10,000, a 426-fold rise, about 30 nanoseconds per descriptor at the top end. Second, epoll is flat: 0.0003 ms at every descriptor count, within the measurement floor. At 10,000 descriptors the poll-to-epoll gap on a single call is about 1,000-fold. Third, select and poll are effectively tied where both run: 0.0041 against 0.0040 ms at 100 descriptors. The old call is not slower than the newer one at small counts; it is capped, not slow.

Arm B: wake latency, one descriptor becomes ready

The second arm is the one a server actually feels. A waiter thread blocks in the call over N descriptors. The main thread waits 20 ms so the waiter is properly asleep, writes one byte to one pipe, and records the time just before the write. The waiter records the time just after the call returns. The latency is the difference: the time from the byte being written to the waiter waking up. The ready descriptor is the last one in the set, the worst case for a call that scans.

N select poll epoll poll / epoll
10 0.0430 0.0424 0.0411 ~1
100 0.0528 0.0541 0.0401 ~1.3
1,000 — 0.1642 0.0418 3.9
5,000 — 0.6488 0.0426 15.2
10,000 — 1.2060 0.0409 29.5

All times are milliseconds, medians of 30. At 10 descriptors all three calls sit on the same floor, about 0.04 ms, which is the scheduling cost of waking a thread, not the cost of any mechanism. epoll stays on that floor at every descriptor count: 0.039 to 0.043 ms from 10 to 10,000. poll leaves the floor as the count grows: 0.0424 ms at 10, 0.1642 ms at 1,000, 1.2060 ms at 10,000. The crossover is between 100 and 1,000 descriptors: at 100 the poll-to-epoll ratio is about 1.3-fold, inside run-to-run noise; at 1,000 it is 3.9-fold, and it roughly triples with each step up in descriptor count after that.

The practical reading is a threshold, not a ranking. Below roughly 100 watched descriptors the choice among the three calls costs nothing measurable in wake latency. Above roughly 1,000, poll pays a real and growing wake tax, and epoll does not.

The control: the ready descriptor's position does not matter

A natural guess about poll's wake cost is that the waiter scans the array after waking and the cost depends on where the ready descriptor sits. The probe tests that guess directly at 10,000 descriptors, with the ready descriptor first in the array instead of last.

Ready first: 1.2070 ms. Ready last: 1.2060 ms. The two medians are identical to three decimal places. The cost is not the post-wake scan. poll pays its O(N) price before it sleeps, in the per-call copy of the descriptor array and the wait-queue registration, regardless of where the ready descriptor sits. Any explanation of poll's scaling that talks only about the rescan is wrong, and this control is the evidence.

The ceiling: select stops at 511 pipes, not 1,024

FD_SETSIZE is 1024, so a common reading is that select handles up to 1,024 descriptors. The probe measures the real ceiling: with 10,000 pipes open, only 511 read ends have a descriptor number below 1024, and the first unwatchable pipe is number 511. Each pipe costs two descriptors, one for each end, so the watchable count is roughly half the limit. select stops being usable at about 511 watched pipes, not 1,024. The number is measured, not asserted: the program counts read ends below FD_SETSIZE and prints the count.

The same constraint is why the tables above cap select at 100 descriptors. Past about 510 pipes, a descriptor number passes 1024, and passing it to FD_SET writes outside the bitmask, which is undefined behavior, not a benchmark. The ceiling is the measurement; the capped tables are the consequence.

The setup cost: epoll registration is real, and one-time

epoll's flat wait cost is bought with registration: every descriptor is added once with epoll_ctl before the first wait. The probe times that registration.

N Total Per descriptor
10 0.0114 ms 1.14 us
100 0.1259 ms 1.26 us
1,000 1.6907 ms 1.69 us
5,000 5.3022 ms 1.06 us
10,000 10.4904 ms 1.05 us

Registration costs about 1 to 1.7 microseconds per descriptor, or 10.49 ms once for 10,000 descriptors. That is a real cost, and it is amortized over every wait that follows: a server that waits thousands of times pays it once. A program that registers descriptors, waits once, and exits would not see epoll's advantage. The flat wait curve and the setup cost are two halves of the same fact, and a guide that reports one without the other is misleading.

What this guide does not show

The 0.04 ms wake floor at low descriptor counts is scheduling, not mechanism. All three calls land on it, and none of them can go below it on this kernel, because the floor is the time to wake a sleeping thread. Do not read the floor as a property of any call.

The watched descriptors are pipes, not sockets. Pipes are the cleanest way to control exactly which descriptor becomes ready, and the mechanism costs measured here are the wait calls themselves, not network behavior. A server with sockets, timers, and signal handling has more moving parts, and its numbers would differ in the details while the shape, flat epoll against linear poll, is the property of the calls.

The CUPS scheduler note, that epoll measured 5.5 percent slower than select at 50 clients, is a different measurement: throughput under scheduler load, not wait latency against descriptor count. It does not contradict this guide's curve, and this guide does not contradict it. At 50 descriptors this guide's own tables show all three calls tied, which is consistent with either outcome in a throughput test.

The numbers are medians of 30 repetitions on one machine: WSL2 kernel 6.18.33.2, 32 CPUs, GCC 13.3.0, no CPU pinning, warm page cache. The poll arm at 1,000 descriptors had one slow repetition at 0.1828 ms against a median of 0.0282 ms, and the poll wake arm at 10,000 ranged from 0.9420 to 1.3159 ms. Medians are stable across the two nights this probe ran; the ranges are the honest spread, and the guide reports medians, not best cases.

Checklist

  • Before choosing a wait call for a small descriptor set, check the count: below roughly 100 descriptors all three calls tie on wake latency, so the choice costs nothing and should be made on portability and code shape, not speed.
  • Before assuming select handles 1,024 descriptors, count the real ceiling: each pipe costs two descriptors, so select stops being usable at about 511 watched pipes on this system, and passing a descriptor at or above FD_SETSIZE to FD_SET is undefined behavior.
  • Before explaining poll's scaling as a rescan, run the control: with the ready descriptor first instead of last, poll's wake latency at 10,000 descriptors is 1.2070 ms against 1.2060 ms, identical, so the cost is paid before the call sleeps.
  • Before claiming epoll is free, price the registration: about 1 to 1.7 microseconds per descriptor, 10.49 ms once for 10,000, amortized over every wait that follows.
  • Before reading the 0.04 ms floor as a mechanism property, remember it is scheduling: all three calls land on it at low descriptor counts, and none of them can go below it.
  • Before comparing these numbers to a throughput benchmark, check what was measured: the CUPS result is throughput under load, this guide is wait latency against descriptor count, and the two do not contradict each other.
  • Before reproducing the probe, raise the descriptor limit: 10,000 pipes need 20,000 descriptors, and the default limit of 1,024 stops the run before it starts.

Sources

Keep Exploring