---
title: "A Programmer-Friendly I/O Abstraction Over io_uring and kqueue"
description: "TigerBeetle's I/O layer wraps io_uring on Linux and kqueue on macOS behind a single callback-based, completion-oriented API, so business logic can schedule reads and writes anywhere instead of in one giant switch loop."
url: "https://swe.quest/articles/a-programmer-friendly-i-o-abstraction-over-io-uring-and-kqueue-bad0e5e3b22be88a"
canonical: "https://tigerbeetle.com/blog/2022-11-23-a-friendly-abstraction-over-iouring-and-kqueue"
source: "TigerBeetle"
published: "2022-11-23"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 9
tags: ["linux","concurrency","zig","performance","networking"]
---

# A Programmer-Friendly I/O Abstraction Over io\_uring and kqueue

A post on [TigerBeetle](https://swe.quest/sources/tigerbeetle.md), published 2022-11-23, 9 min read, Deep dive. Original: [https://tigerbeetle.com/blog/2022-11-23-a-friendly-abstraction-over-iouring-and-kqueue](https://tigerbeetle.com/blog/2022-11-23-a-friendly-abstraction-over-iouring-and-kqueue)

## Summary

TigerBeetle's I/O layer wraps io\_uring on Linux and kqueue on macOS behind a single callback-based, completion-oriented API, so business logic can schedule reads and writes anywhere instead of in one giant switch loop. Callbacks travel through the kernel's opaque user\_data field. A flush/run\_for\_ns pair submits batches and polls completions. An intrusive-linked-list overflow queue holds requests when the fixed-size ring is full. On io\_uring the kernel performs the actual send/recv, while the kqueue backend waits for readiness and then makes the syscall in userland. The design is a single-threaded event loop similar to libuv, chosen for simplicity and for the determinism needed by Deterministic Simulation Testing; per-thread queues and shared-queue worker pools are discussed as alternatives for parallel workloads.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [Linux](https://swe.quest/tags/linux.md) (Infrastructure)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Zig](https://swe.quest/tags/zig.md) (Languages)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Networking](https://swe.quest/tags/networking.md) (Infrastructure)

## Prerequisites

- system calls and file descriptors
- non-blocking I/O
- TCP sockets ([easy posts on Networking](https://swe.quest/tags/networking.md?difficulty=easy))
- event loops

## Keywords

io\_uring, kqueue, TigerBeetle, Zig, libuv, IOCP, Bun, Deterministic Simulation Testing

## Related posts

- [Async Rust](https://swe.quest/articles/async-rust-c6376cf98e387782.md): Zed · 2024-04-09 · Medium · 11 min read · Rust, Concurrency, Runtimes & VMs, Developer tools, Performance engineering
  Zed's GPUI framework runs async Rust without tokio or smol: it uses async\_task for tasks and thin wrappers around macOS Grand Central Dispatch as the executor, dispatching Runnables via dispatch\_async\_f onto the main queue or a high-priority global queue through a trampoline function.
- [Writing High-Performance Clients for Tigerbeetle](https://swe.quest/articles/writing-high-performance-clients-for-tigerbeetle-359130491cf9dbd8.md): TigerBeetle · 2023-02-21 · Medium · 6 min read · Zig, API design, Performance engineering, Java & JVM, Memory management
  TigerBeetle builds every language client as a thin wrapper over a single Zig client library, tb\_client, exposed through FFI.
- [Announcing Silk: a silky smooth fiber runtime for ClickHouse](https://swe.quest/articles/announcing-silk-a-silky-smooth-fiber-runtime-for-clickhouse-bd3ca633b291b6b6.md): ClickHouse · 2026-06-25 · Hard · 11 min read · Concurrency, Runtimes & VMs, C & C++, Performance engineering, Linux
  Silk is a C++ stackful-fiber runtime for ClickHouse. It pins one scheduler thread per CPU, uses io\_uring as its I/O foundation, steals work in order of CPU topology cost (hyperthread sibling, then same socket, then cross-socket), and does zero heap allocation in the steady-state hot path through mmap'd stack pools, stack-resident futures and intrusive containers.
- [Hardening eBPF for runtime security: Lessons from Datadog Workload Protection](https://swe.quest/articles/hardening-ebpf-for-runtime-security-lessons-from-datadog-workload-protection-d7f876ff0025b179.md): Datadog Engineering · 2026-01-07 · Hard · 34 min read · Linux, Threat detection, Security, Operating systems, Performance engineering
  Five years of running Datadog Workload Protection, an eBPF-based runtime security agent supporting kernels from 4.15 to 6.18, distilled into six production lessons.
- [The Adventures of Rendezvous in Heroku’s New Architecture](https://swe.quest/articles/the-adventures-of-rendezvous-in-heroku-s-new-architecture-fa7c708c1d11ea33.md): Heroku Engineering · 2022-01-19 · Medium · 9 min read · Incidents & postmortems, Debugging, Ruby, Networking, Load balancing
  Moving Heroku's Rendezvous proxy, which splices CLI and one-off dyno connections across NATs, from EC2 Classic to VPC behind AWS Network Load Balancers with TLS termination broke one customer's request-scoped one-off dyno workflow with H12 router timeouts.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
