Lumentrace is an eBPF-powered, function-level profiler and regression detector. It attaches to an unmodified binary (currently Rust), measures every call to the binary's own functions, streams a live call graph to a browser UI, and flags functions whose latency drifts away from their baseline — tagged with the commit that produced the binary.
target binary ──uprobes──▶ agent (Rust/aya) ──gRPC :50051──▶ backend (Go) ──WebSocket :8080──▶ UI (React/D3)
Screen.Recording.2026-11-15.at.5.35.26.PM.mov
- Scan — the agent (
agent/adapter) reads the target's ELF symbol table, demangles the names, and keeps only the functions that belong to the target crate (e.g.orders::). - Attach — it loads
agent/bpf/profiler.bpf.oand attaches a uprobe (function entry) and a uretprobe (function exit) to each of those functions. Every probe carries a cookie: the function's index in the agent's table. - Capture (kernel) — on every entry/exit, the BPF program writes a
25-byte event
{type, pid/tid, cookie, timestamp_ns}to a ring buffer. No logic runs in the kernel; it only records. - Reconstruct (agent) —
agent/profiler-core/src/callstack.rskeeps one call stack per thread. An entry pushes a frame and emits acaller → calleeedge; an exit pops it and computes total time and self time (total minus time spent in children). Each root call gets its own trace id. Events are streamed to the backend over gRPC (proto/). - Detect (backend) —
backend/collectorkeeps the last 20 durations of each function and computes their p95. The first value becomes the baseline; a drift of more than 20% is reported as aregression. Every event is stored in SQLite with the commit hash. - Visualize — the React app receives live events over
ws://<host>:8080/ws, draws the call graph with D3, and queries/history/{function}for past runs.
A second, independent probe — agent/bpf/monitor.bpf.c — hooks
sys_enter_execve to capture process creation (pid, ppid, process name).
It isn't wired into the profiler pipeline above.
- eBPF — small programs that run inside the Linux kernel, triggered by
events, without recompiling the kernel or loading a module. Here:
trace_enterandtrace_exitinprofiler.bpf.c. - uprobe / uretprobe — the "u" means the observed function lives in user space; the BPF code itself always runs in the kernel. A uprobe replaces the function's first instruction with a breakpoint (entry). A uretprobe swaps the return address on the stack for a kernel trampoline (exit).
- Verifier — checks every BPF program before it loads (bounded loops,
safe memory access). That's why
bpf_ringbuf_reserveresults are null-checked. - Maps / ring buffer — memory shared between kernel and user space. The
profiler uses a 16 MB
BPF_MAP_TYPE_RINGBUF; the agentpoll()s it. - Attach cookie — one BPF program serves every function, so each attach
passes an index that the program reads back with
bpf_get_attach_cookie(). Cheaper than sending names from the kernel. pid_tgid—bpf_get_current_pid_tgid()returns the process id (upper 32 bits) and thread id (lower 32 bits); call stacks are keyed by that pair, which makes recursion and multi-threading work.bpf_ktime_get_ns()— monotonic nanoseconds since boot; used for durations, not wall-clock dates.- Logic in user space — the kernel side only timestamps; pairing, self time and detection live in testable user-space code that can be reused across language adapters.
agent/— Rust workspace (uses aya)bpf/— kernel-side C programs:profiler.bpf.c,monitor.bpf.c, shared structs/maps inebpf_structures.h,Makefilesrc/main.rs— agent binary: wires adapter → call stack → gRPCadapter/— language adapter (symbol scan, attach, ring buffer reader)profiler-core/— language-agnostic call stack reconstruction
proto/— gRPC contract between agent and backendbackend/— Go servercmd/— entry point: WebSocket/HTTP on:8080, gRPC on:50051collector/— receives agent events, p95 baselines, regression statusstats/— sliding window and p95database/— SQLite storage and the/history/{name}handlerbroadcast/— WebSocket fan-out to connected clientspb/— generated gRPC code
frontend/ebpf-project/— React + Vite + D3 dashboardtest/— targets to profilerust_target/src/main.rs— minimalmain → func1 → func2 → func3chainrust_target/src/bin/orders.rs— multi-threaded order pipeline with recursion, a shared callee, and aSLOW_LOOKUPregression toggletestapp,target_service/— older Go targets
Requires Linux with BTF support, clang, Rust, Go and Node. The BPF
Makefile targets arm64; change -D__TARGET_ARCH_arm64 for x86.
Build the target on Linux — uprobes need an ELF binary.
-
Build the eBPF object and the agent
cd agent/bpf && make cd .. && cargo build -
Build a target. Functions you want as separate frames need
#[inline(never)].cd test/rust_target && cargo build --bin orders -
Start the backend with the commit hash of the target:
cd backend && go run ./cmd $(git rev-parse HEAD) -
Start the agent (root is needed to load eBPF):
sudo ./agent/target/debug/agent \ "$PWD/test/rust_target/target/debug/orders" \ agent/bpf/profiler.bpf.o \ orders:: \ [collector-addr, default http://127.0.0.1:50051] -
Run the target —
./test/rust_target/target/debug/orders -
Start the frontend
cd frontend/ebpf-project && npm install && npm run dev
Set SLOW_LOOKUP = true in test/rust_target/src/bin/orders.rs, commit,
rebuild, then restart both the backend (new commit hash) and the agent
(probes are bound to the old binary file) and run orders again.
find_customer should be flagged as a regression.
Work in progress. Known limitations:
- Baselines are in memory only — they reset when the backend restarts, so comparisons across commits are not persisted yet.
- Overhead — each probe costs roughly 1–2 µs, which distorts very small, hot functions.
- async code — with futures, entry/exit marks a
poll, not a logical call, so durations and call edges aren't meaningful yet. - Rebuilds — probes attach to the binary's inode; restart the agent after rebuilding the target.
- Attaching mid-run — calls already in progress are skipped (orphan exits are ignored).
- Ring buffer full — events are dropped silently.
- The frontend's history URL is hardcoded in
frontend/ebpf-project/src/components/Dashboard.tsx.