Notes
Short write-ups of things I've been learning. Writing them down is how I find out whether I actually understand them.
How Envoy's xDS gets config to the data plane
May 2026 · networking
xDS is the set of APIs a control plane uses to push configuration to Envoy proxies. Envoy doesn't poll for config. It opens a long-lived gRPC stream to the management server, and updates arrive on that stream as they happen.
There are four main resource types: listeners (LDS), routes (RDS), clusters (CDS), and endpoints (EDS). They refer to each other in a chain: a listener names a route config, a route sends traffic to a cluster, and a cluster gets its endpoints from EDS. If updates arrive in the wrong order, Envoy can briefly hold a route that points at a cluster it hasn't heard of yet, and that traffic fails.
The Aggregated Discovery Service (ADS) puts every resource type on one stream, so the server controls the order. The usual rule is make before break: send new clusters and their endpoints before the routes that use them, and remove old clusters only after nothing refers to them. This is the problem service mesh control planes like Istio and Linkerd have to solve.
Taint tracking for LLM tool calls
April 2026 · security
Taint analysis is an old program analysis idea: track whether untrusted data can reach a sensitive operation without being checked. User input flows through the program, and the question is whether it reaches a SQL query or a shell command unsanitized.
Tool-using LLM agents fit the same pattern. The source is a document or tool output the agent read. The model reasons over it, and the sink is another tool call: writing a file, running code, or sending a message. Prompt injection is untrusted text reaching that sink.
Detecting injected instructions alone isn't enough, because a well-written attack looks like an ordinary document. In LLMFirewall I label every piece of content with where it came from, and content from an untrusted source can't authorize a write or send tool, however harmless it looks. The detectors still run, but the label decides.
ARIES recovery on one page
April 2026 · databases
ARIES is the write-ahead-logging recovery algorithm most production databases use some version of. It rests on one rule: the log record for a change must reach disk before the changed page does. On restart it runs three passes.
Analysis scans forward from the last checkpoint and rebuilds two tables: the dirty page table (pages changed in memory but maybe not on disk) and the transaction table (transactions still running at the crash).
Redo starts at the oldest change recorded in the dirty page table and reapplies every logged change, even ones from transactions that will be rolled back. After this pass the database is in exactly the state it was in at the crash.
Undo rolls back the transactions that never committed. Each undo step is logged as a compensation log record, so if the system crashes again during recovery, the next recovery doesn't undo the same work twice.
Compiling && and ||
March 2026 · compilers
The easy mistake is to compile a && b like any other binary operator: evaluate both sides into registers, then AND them. That's wrong whenever evaluating b has side effects or can fail. p != NULL && p->x > 0 will crash on exactly the input it was written to guard against.
The fix is to compile conditions as jumps instead of values. Pass each boolean expression two labels, where to go if it's true and where to go if it's false. For a && b, a jumps to the false label if it fails and otherwise falls through to b, and b gets the original two labels. || is the mirror image, and ! just swaps the labels. Nested conditions then compile by recursion, and you only produce a 0 or 1 in a register when the program actually stores the result.
I ran into this in CS 164. The textbook name is "jumping code", and backpatching is how a one-pass compiler fills in labels it doesn't know yet.
Why the SPSC ring buffer needs no lock
February 2026 · systems
A single-producer, single-consumer ring buffer is the standard lock-free queue between two threads. Only the producer ever writes head and only the consumer ever writes tail, so the threads never fight over a write. All they need is for each side's writes to become visible to the other in the right order.
The producer loads tail with acquire ordering and checks that head - tail < N, so the buffer isn't full. It then writes the item into buf[head % N] and stores head + 1 with release ordering. The consumer loads head with acquire ordering and checks that head != tail, so the buffer isn't empty. Only then does it read buf[tail % N], and it stores tail + 1 with release ordering.
The release store on one side pairs with the acquire load on the other. When the consumer sees the new head, it's guaranteed to see the item written before it. When the producer sees the new tail, it knows that slot has been read and can be reused. Putting head and tail on separate cache lines stops false sharing, so the two cores don't keep stealing one line from each other. In an order book this is how market data gets from the network thread to the matching thread without a lock on the hot path.