Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

TigerBeetle 5 min read How-to mediumAdept

Swarm Testing Data Structures

Zig'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.

Related posts

  • Random Fuzzy Thoughts

    TigerBeetle mediumAdept

    Treating a fuzzer's byte slice as a finite PRNG unifies coverage-guided fuzzing with structured property-based testing: the entropy length measures input complexity, gives test-case minimization almost for free, and tells interactive simulations when to stop injecting faults. A seed reproduces a failure only at a specific commit, so robust regression tests should persist the generated structured data (e.g. a .wasm module) rather than the seed, using a separate generate/build/process pipeline that also supports hand-written inputs. For interactive distributed-system tests, a livelock in TigerBeetle was reproduced by running the VOPR simulator with a perfect network and steering it with predicates over system state, suggesting regression suites made of predicate 'key frames' that random traces must hit.

  • Index, Count, Offset, Size

    TigerBeetle mediumAdept

    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.

  • Enum of Arrays

    TigerBeetle mediumAdept

    Struct-of-Arrays has a dual for tagged unions: an Enum of Arrays, where one tag covers a whole batch of homogeneous payloads instead of each element carrying its own tag. Amortizing the tag saves memory, avoids padding waste between differently sized variants, and replaces per-item unpredictable branches with a single branch per batch, which also opens the loop to SIMD. TigerBeetle applies this by processing homogeneous batches of about 8k accounts or 8k transfers rather than mixed operations, mirroring a control plane/data plane split.

  • A Descent Into the Vörtex

    TigerBeetle mediumAdept

    TigerBeetle has added Vortex, a non-deterministic, generative full-system test harness that complements its Deterministic Simulation Testing by exercising real production binaries and client libraries from the outside in. A supervisor coordinates a cluster of stock replicas, a workload that checks safety properties, and language-specific client drivers (Zig and Java so far). It injects network faults through a TCP proxy, kills or pauses processes, and runs liveness checks. In four months it found two bugs: incorrect request batching in tb_client and double connection termination. Planned work includes continuous runs, upgrade testing, network partitions and storage faults.

  • What the interns have wrought, 2022 edition

    Jane Street Tech Blog mediumAdept

    Three Jane Street intern projects from 2022 show substantial tooling work in OCaml. magic-trace gained a sampling mode that can cover 20 seconds to 20 minutes on Intel or AMD hardware, plus multi-process tracing, CPU-frequency transition reporting and a perf dlfilter backend that speeds trace decoding by 10–50%. Datafetcher jobs can now be compiled into Incremental computations, using a Response_or_waiting type to represent async state and mandatory memoization of fetch nodes. Quickcheck gained a [@@contract] syntax for deriving property tests from interface signatures, along with early support for bisimulation testing of two implementations of the same API.

The quest for software engineering knowledge.

Look:
Layout: