Index, Count, Offset, Size
TigerBeetle uses a strict naming convention to catch off-by-one and index-space bugs that types don't easily prevent: `count` is a number of items, `index` points at an item (invariant `index < count`), `size` is a byte count (`size = @sizeOf(T) * count`), and `offset` is the bytewise counterpart of index. `length` is banned because it is ambiguous, for example Rust's byte-size `str::len` versus Python's code-point `len`. Zig examples from NodePool and an EWAH decoder show wrong combinations becoming visible from names alone. The convention works together with big-endian naming (qualifiers as suffixes) and equal-length dual names like source/target, which line code up so mistakes stand out.
Related posts
- Swarm Testing Data Structures
TigerBeetle mediumAdeptZig's comptime reflection (std.meta.DeclEnum) can turn a data structure's public API into an enum that drives a model-based property test, so adding a new public method triggers a compile error from the non-exhaustive switch until the test covers it. TigerBeetle tests its intrusive queue against a ring-buffer model and adds swarm testing: rather than picking operations uniformly, each run randomly chooses a subset of operations and random weights for them, so runs reach states like long queues that uniform push/pop never produces. Code is included for weighted enum sampling, random weight generation and an allocation-free k-combination helper.
- Synadia and TigerBeetle Pledge $512,000 to the Zig Software Foundation
TigerBeetle easyNoviceSynadia and TigerBeetle are jointly donating $512,000 to the Zig Software Foundation over two years, with no strings attached. The post explains why TigerBeetle chose Zig over Rust and C in 2020. TigerBeetle uses static allocation per NASA's Power of Ten rules and runs single-threaded because transaction contention defeats partitioning, so Rust's borrow checker mattered less than Zig's bounds checking, checked arithmetic by default and absence of hidden allocations or control flow. Three bugs the borrow checker would have prevented were caught by fuzzing on 1,000 dedicated cores, and the upgrade to Zig 0.15.2 made debug builds 2x faster and LLVM release builds 1.6x faster.
- Bun v1.1.7
Bun mediumAdept
Bun v1.1.7 fixes 28 bugs and adds glob patterns in package.json workspaces (via Bun.Glob), asymmetric matcher support in expect.extend's this.equals, and a working bunx --version. Several fixes come with root causes: a SIMD invalid memory access in Zig's std.mem.indexOfScalarPos crashing Windows startup, a misassumed 8-byte alignment of FILE_DIRECTORY_INFORMATION, threadlocal destructors running during std::quick_exit with live Workers, an uninitialized C++ integer corrupting stacktrace line numbers, and a memory leak from unread Bun.serve() request bodies since v1.0.30. Smaller changes include WebSocket close code 1015 on TLS failures, a ServerWebSocket shrink from 32 to 24 bytes, and adding clang-analyzer to CI.
- Copy Hunting
TigerBeetle mediumAdeptReading Zig's emitted LLVM IR as plain text and grepping it is a practical substitute for staring at disassembly when chasing implicit memcopies and binary bloat. A small line-by-line tool, copyhound, flags large `llvm.memcpy` calls per function and also sums IR lines per generic function name to expose monomorphization blowup, the same idea as cargo-llvm-lines. In TigerBeetle it traced copies to `std.meta.eql`, which was replaced with a comptime-checked word-wise byte comparison. In the Zig compiler it found an inlined float-parsing slow path costing 10 KB of stack, fixed with `@setCold`. Making comptime parameters runtime in a version-printing function cut 300 bytes from the binary.
- Bun v1.2.1
Bun mediumAdept
Bun v1.2.1 fixes 32 bugs and adds S3 storage class support, X25519 key generation in crypto.generateKeyPair, Node's --zero-fill-buffers flag, indented inline snapshots in bun test, and a bunfig option to disable minification for HTML imports. The most technical change fixes GC memory accounting: WebKit reports a ref-counted string's cost as its byte length divided by its reference count, so Bun's Zig bindings, which briefly held an extra reference, under-reported string memory (a 64 KB file read reported as 32 KB). A new single-step createUTF8ForJS pattern avoids that extra reference. Other fixes cover fs.Stats and bigint fstat parity with Node, EINTR retries in fs reads and writes, a child_process spawn race, Worker reliability, and memory leaks in Bun.serve() and Bun.pathToFileURL caused by refcount mistakes.