---
title: "Enum of Arrays"
description: "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."
url: "https://swe.quest/articles/enum-of-arrays-39cf1c2fe738e424"
canonical: "https://tigerbeetle.com/blog/2024-12-19-enum-of-arrays"
source: "TigerBeetle"
published: "2024-12-19"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 3
tags: ["performance","data-structures","zig","hardware"]
---

# Enum of Arrays

A post on [TigerBeetle](https://swe.quest/sources/tigerbeetle.md), published 2024-12-19, 3 min read, Deep dive. Original: [https://tigerbeetle.com/blog/2024-12-19-enum-of-arrays](https://tigerbeetle.com/blog/2024-12-19-enum-of-arrays)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [Data structures](https://swe.quest/tags/data-structures.md) (Architecture & design)
- [Zig](https://swe.quest/tags/zig.md) (Languages)
- [Hardware](https://swe.quest/tags/hardware.md) (Infrastructure)

## Prerequisites

- struct memory layout and padding
- tagged unions
- SIMD basics
- branch prediction

## Keywords

TigerBeetle, Zig, Struct of Arrays, Enum of Arrays, SIMD, data-oriented design

## Related posts

- [Swarm Testing Data Structures](https://swe.quest/articles/swarm-testing-data-structures-dcd11950dc8316b7.md): TigerBeetle · 2025-04-23 · Medium · 5 min read · Testing, Zig, 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.
- [Writing High-Performance Clients for Tigerbeetle](https://swe.quest/articles/writing-high-performance-clients-for-tigerbeetle-359130491cf9dbd8.md): TigerBeetle · 2023-02-21 · Medium · 6 min read · Zig, API design, Performance engineering, Java & JVM, Memory management
  TigerBeetle builds every language client as a thin wrapper over a single Zig client library, tb\_client, exposed through FFI.
- [Arch-specific SIMD in Go](https://swe.quest/articles/arch-specific-simd-in-go-2992a831c4663686.md): The Go Blog · 2026-10-02 · Hard · 11 min read · Go, Performance engineering, Compilers, Hardware, WebAssembly
  Go 1.27 extends the experimental architecture-specific SIMD API (simd/archsimd, enabled with GOEXPERIMENT=simd) from amd64 to arm64 NEON and wasm 128-bit SIMD.
- [Index, Count, Offset, Size](https://swe.quest/articles/index-count-offset-size-8c9106813a691acc.md): TigerBeetle · 2026-02-16 · Medium · 3 min read · Zig, Debugging, Type systems
  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\`.
- [Shipping a Trillion Parameters With a Hub Bucket: Delta Weight Sync in TRL](https://swe.quest/articles/shipping-a-trillion-parameters-with-a-hub-bucket-delta-weight-sync-in-trl-5d3970ad53bc1dc5.md): Hugging Face · 2026-05-27 · Hard · 17 min read · Model training, Inference & serving, Distributed systems, Storage systems
  Between consecutive RL optimizer steps, about 99% of bf16 weights stay bit-identical because Adam updates at RL learning rates fall below bf16's rounding threshold (|Δw| \< |w|/256).

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
