Following a system call When a read has nothing to return Pia's message handler makes its loudest appearance on the CPU profile precisely when nobody is sending it a message. The caller keeps asking a nonblocking socket whether anything has arrived. Normally a delivered message needs one read attempt in this trace. During the regression one message costs forty attempts. Most return immediately because no bytes are ready. That is demand created by the reader itself. A library translates a call into the platform’s kernel interface. A blocking read can put the caller to sleep until bytes are available. Event loop in context A nonblocking read can return EAGAIN instead. The caller must decide when to try again. A readiness interface lets a thread wait on many descriptors and make progress on the ones with work. A short syscall trace can distinguish an immediate error from an operation that blocked. Compare counts, elapsed times and the specific worker involved before drawing conclusions. A blocking call may sleep awaiting progress. Nonblocking mode reports when it cannot progress now. A partial successful return still requires the caller to handle remaining bytes. The vDSO maps kernel-supplied routines into userspace. Supported clock queries can read shared timekeeping data there and avoid a full kernel transition. A readiness notification tells a consumer that a read might make progress. Two workers can observe the same readiness event, and the first worker can drain the socket before the second runs. A correctly written nonblocking reader must therefore handle a temporary empty result even after a notification. Follow a read with no data yet A nonblocking read can return the would-block result instead. A blocking caller can sleep until a byte is available. The core can run a different thread while this one waits. The nonblocking caller gets an immediate result. Repeating the same call immediately repeats the work of entering and leaving the kernel. The event loop registers interest, waits for a notification and tries the read on the signaled socket. A protocol message is eight bytes long. A successful first read returns three bytes. An empty second attempt means no more bytes are available yet. A later readiness event brings the remaining five. The application needs to remember the partial message across that gap. Treating every successful call as exactly one message would lose framing even after the busy loop was fixed. Read the measurements Compare a worker that repeatedly polls the same empty socket with one that registers its interest and lets the scheduler run another task. Both eventually receive identical message bytes. Count empty attempts between completions and inspect their timing. Repeated immediate returns indicate a loop; one long wait can mean the worker slept efficiently. Write one line for each attempt with its result category: delivered data, temporarily unavailable, end of stream or persistent failure. Divide by successfully completed messages in the identical interval. Zero completions makes that ratio undefined. Report the underlying counts in that case rather than a misleading infinite or zero rate. Predict the second readiness check The readiness notification arrives. Is a subsequent read guaranteed to produce a message? Another reader may consume the bytes first. Treat readiness as an invitation to try and handle a second would-block result. A successful read can also return fewer bytes than the application message requires. A long blocking read with no data suggests the producer or the path to it. Repeated immediate returns suggest a busy consumer. Check the competing explanation Open returns a descriptor, read and write transfer up to the requested count, and close releases a reference. A file mapping can remain valid after the original descriptor is closed. A seccomp filter restricts the syscalls a process may make. When a deployment unexpectedly loses an operation, compare the workload’s documented requirements with its active confinement policy. After an event-loop change a service burns one core even while receiving few messages. Trace a short interval on one representative worker. Repeated immediate EAGAIN results place the time in a busy loop. A single long read would support a different diagnosis. Bound the observation window because tracing itself can change timing. Return the worker to useful work After restoring the readiness wait, the example needs two attempts per delivered message. A wrapper arranges a call number and arguments according to an architecture-specific ABI. The kernel validates arguments, performs the operation and reports a result or error. Pia checks completed messages and idle CPU together. Fast individual calls can still add up to a busy, unproductive loop. Apply the diagnosis At end of stream, a successful byte-stream read returning zero has a different meaning from a temporary unavailable result. A persistent error is another branch. Ask which branch the application takes after each outcome. Checking only the number of calls would miss a loop that continues forever after a peer has closed.