C4 C 4 Punk Developers

Project

libttak

Deterministic systems runtime for C

Why libttak exists

C applications tend to fail at scale in a small number of predictable ways: the heap fragments, the allocator contends, the tail latency stops being stable, async coordination becomes difficult to follow, and resource ownership drifts between subsystems until nobody can say who frees what.

libttak treats those as one problem rather than five. Memory allocation, network scheduling and concurrency are unified under deterministic control, so the lifetime of a buffer, the point at which it is reclaimed, and the thread that will touch it next are all answerable from the code in front of you.

The memory model

Generational arenas batch allocations and reclaim them in bulk at a generation boundary you declare. Cleanup becomes an event you scheduled instead of a cost distributed across every free call.

Epoch reclamation handles the cross-thread case: a writer can retire a structure while readers are still inside it, without stopping the world to do so.

Detachable ownership makes the handover explicit. Memory moves between subsystems as a deliberate call, which is the difference between a lifetime bug you can find by reading and one you find in production.

Concurrency and scheduling

Thread pools take prioritised tasks and return futures. Underneath, a deterministic lattice scheduler orders work predictably rather than leaving it to whatever the OS decides this second. Zero-copy IO paths are aimed at lock-free ingress pipelines where an extra copy per packet is the whole budget.

What is built on it

libttak powers custom web frameworks, including CWIST, along with network routing layers, lock-free ingress pipelines, containerised services and experimental overlay networking. It is a library, not a framework: you call it from your own main.

arena.c
#include <ttak/mem/arena_helper.h>

ttak_arena_env_config_t cfg;
ttak_arena_env_config_init(&cfg);

ttak_arena_env_t env;
ttak_arena_env_init(&env, &cfg);

ttak_arena_generation_t gen;
ttak_arena_generation_begin(&env, &gen, 1);

void *buf = ttak_arena_generation_claim(&env, &gen, 4096);
/* ... use buf for the whole request ... */

ttak_arena_generation_retire(&env, &gen);
ttak_arena_env_destroy(&env);

At a glance

Deterministic runtime for C. Powers web frameworks, routing layers, lock-free ingress pipelines and containerised services. Documented at length in the companion libttak-books repository.

Licence
BSD 3-Clause
Standard
Runtime

Copyright 2026 Religiya Serdtsa. The attribution clause applies to binary redistribution as well as source.

Open the repository →

Capabilities

What is in the box

AR

Generational arenas

Batched allocation with timestamped generations and bulk reclamation, so cleanup happens at boundaries you chose rather than wherever the last free() landed.

EP

Epoch reclamation

Cross-thread memory reclamation without a global pause, for structures that readers touch while writers retire them.

OW

Detachable ownership

Memory can be handed between subsystems explicitly, which makes the lifetime question answerable by reading the call rather than the history.

TP

Thread pools and futures

Prioritised task submission that returns a future, with a deterministic lattice scheduler underneath for predictable ordering.

IO

Zero-copy IO

Ingress paths that avoid an intermediate copy, aimed at lock-free pipelines and routing layers.

DS

Container and math toolbox

Hash tables, pools, ring buffers, trees, B+ trees, priority queues, bigint, matrix and NTT, with optional CUDA, OpenCL and ROCm acceleration.