Skip to main content
SUNDAY SYSTEMS DIGEST · ONE MEASURED ESSAY EVERY WEEKREAD · BENCHMARK · REFLECTZERO TRACKING PIXELS · FULL RSS & MARKDOWN ARCHIVENEW BENCHMARK: DETERMINISTIC RAFT LEASE QUORUMS
KERN.

Search Archive

Recent & Most Read Essays (8)

Sub-1% Overhead Tail-Latency Histograms With Per-CPU eBPF Maps

Why user-space OpenTelemetry spans miss kernel socket-buffer queueing delays, and how log-linear BPF per-CPU arrays capture every microsecond stall at 420,000 requests per second.

Henrik Lindqvist
Henrik Lindqvist

Principal Systems Architect · Stockholm

Aug 23, 202610 min read173 words
Sub-1% Overhead Tail-Latency Histograms With Per-CPU eBPF Maps

Application-level HTTP timers start ticking only after your runtime's event loop calls accept4 or epoll_wait and reads bytes out of the socket receive buffer. If a garbage-collection pause or thread-pool saturation leaves packets sitting in sk_receive_queue for 38 ms, your user-space dashboard cheerfully reports 1.2 ms handler latency while upstream callers time out.

Timestamping tcp_v4_do_rcv to Socket Drain

Attaching a lightweight BPF tracepoint at sock:inet_sock_set_state and skb:consume_skb lets us measure true kernel-to-application residency without modifying service binaries or allocating heap objects per span.

c
struct {
    __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
    __uint(max_entries, 64);
    __type(key, __u32);
    __type(value, __u64);
} queue_hist SEC(".maps");

static __always_inline __u32 log2_bucket(__u64 delta_us) {
    __u32 b = 63 - __builtin_clzll(delta_us | 1);
    return b < 64 ? b : 63;
}

Using BPF_MAP_TYPE_PERCPU_ARRAY avoids cross-core cacheline bouncing (lock xadd contention) on 128-thread machines. A user-space collector sums the 64 buckets every five seconds over netlink in less than 0.3 ms CPU time.

Catching Scheduler Preemptions Before Incidents Escalate

When we deployed this probe alongside our RPC proxy described in Registered Buffer Rings in io_uring for High-Fanout RPC Gateways, we immediately spotted 14 ms p99.9 spikes every ten minutes caused by a noisy cron log-compression job sharing NUMA node 0. Pinning housekeeping jobs to housekeeping cores flattened the histogram overnight and stabilized the consensus leases analyzed in Deterministic Raft Lease Quorums Under Asymmetric Cross-AZ Jitter.

Connected Architecture Notes

Henrik Lindqvist

Henrik Lindqvist

Stockholm · UTC+1

Principal distributed systems architect writing weekly benchmarks on consensus protocols, storage engines, WebAssembly isolates, and tactile web accessibility.

Reader Field Notes

0 verified notes

No published field notes yet on this essay. Share a production observation or benchmark note below.

Contribute a Technical Note

Moderated manually for signal-to-noise. Your email is never stored in public comment properties.

Enter your display name.
Enter a valid email or leave blank.
Please write at least 8 characters.
Please confirm publication consent.

Continue Reading

All essays →

Get next Sunday’s benchmark by email

Full essay in plain HTML, zero tracking pixels, one-click unsubscribe.

Enter a valid email address (for example, name@domain.com).