Hacker
Bikky Adhikari
@bikky
Elsewhere
Projects
libflagsmith-c — Lock-Free C11 Shared-Memory SDK & Sidecar Daemon for Flagsmith
Flagsmith Experimentation HackathonNov 2026
What I Built & The Problem It Solves: I built libflagsmith-c, a lock-free, zero-allocation C11 feature-flag SDK and sidecar daemon for self-hosted Flagsmith. Flagsmith offers official SDKs for Python, Go, Rust, Java, and .NET, but has no official C SDK. In latency-critical C workloads, performing blocking HTTPS requests and JSON parsing on the hot path adds millisecond latency, heap allocations, and network failure risk. Who Would Use It: Systems engineers, infrastructure developers, and embedded Linux teams writing high-frequency C/C++ services—such as edge proxies, network routers, game servers, telemetry pipelines, and trading/daemon workers—who want self-hosted Flagsmith feature flags and instant kill-switches without compromising nanosecond hot-path execution. How It Works: 1. Sidecar Sync Daemon (flagsmithd): Runs alongside the application, polls self-hosted Flagsmith's /api/v1/flags/ REST API in a background pthread via libcurl, and publishes flag states into a POSIX shared-memory segment (/dev/shm/flagsmith_flags) protected by a C11 atomic seqlock. 2. Single-Header C11 SDK (flagsmith.h): Client processes map /dev/shm read-only and evaluate flags via flagsmith_is_enabled() using C11 acquire-release atomic loads—with zero mutexes, zero malloc calls, and zero syscalls on the read path, achieving 9.96 ns/op (100.44 M ops/sec) in ./demo --bench. 3. Outage Survival & Local CLI: If the Flagsmith control plane becomes unreachable, client workers seamlessly continue reading cached last-known-good state from shared memory (link=CACHED) with zero downtime, while flagsmithd exposes an interactive CLI (list, off, on, reset, offline, online) for local debugging and incident simulation.