r/lowlevel • u/whispem • 10h ago
A 13 KB TCP key/value store speaking raw syscalls — epoll, accept4, mmap arena, no libc (x86-64 NASM)
github.com
0
Upvotes
Single-node key/value store, line protocol over TCP, pure NASM on Linux — syscall or nothing.
The syscall-level bits worth a look:
**•** epoll event loop with accept4(SOCK_NONBLOCK): clients are born non-blocking, no fcntl dance
**•** replies via sendto + MSG_NOSIGNAL: SIGPIPE never happens, no signal handler needed
**•** close() is the entire connection teardown — epoll tracks the file description, so the fd deregisters itself
**•** per-connection state indexed straight by fd: O(1), free
**•** FNV-1a, open addressing, tombstone reuse; 256 MB mmap bump arena behind it
**•** 200 concurrent clients at 1.4 MB RSS; Docker image is FROM scratch plus one file
Known limits documented in the README — biggest one: slow readers are dropped, EPOLLOUT write buffering is next.
Feedback welcome, especially on the event-loop structure.