Notes/Precomputing

Precomputing Adds Windows and Fixes a Last-Bit Drift on ARM64

Precomputing does the counting while events come in, so the answer to a question is already there when someone asks. A short policy lists the incoming streams and the answers wanted from them, along with how long the detail behind each answer should be kept. The results live in an ordinary SQLite file, readable with any SQLite tool. The code went open source on 5 October as 0.1.1-alpha, under the Apache License 2.0, and 0.2.0 followed on 8 October.

Two Runtimes, One File

The repository holds two ways to run a policy. A compiler turns it into plain SQLite triggers, so SQLite itself keeps the answers current. The Engine executes that policy in Go instead, 12 to 17 times faster on the trading demo. Around them sit the Meter, Logs, Traces and an MCP server. The rule that holds it together is that both runtimes give the same answers, to the last bit.

The eight live demos run in the browser. In the MCP case study, an agent asks for a p99 and gets it in 179 tokens, where the raw data behind that number comes to 283,641.

The ARM64 Drift

0.2.0 brought binaries for five systems: Linux on x86-64 and ARM64, macOS on Apple silicon and Intel, and Windows. It also fixed a break in that last-bit rule. On ARM64, Go may combine a multiply and an add into one fused instruction that rounds once, and the code expected two roundings. So on ARM64 some sums in the Engine’s files came out one last bit away from the SQL runtime’s, and a recount of the trading demo’s 4,048,210 trades found 7,045 candles that differed. Now each product is rounded on its own before it’s added, in every part that does the sums, and both architectures produce identical values.

The same recount now guards every release. Each binary has to recount those 4,048,210 trades with zero differences before it ships, and the ARM64 Linux binary, which in 0.1.1-alpha was only built, now runs that check too. Releases build themselves once the tests pass on Linux and macOS, so nobody has to remember to run it.