Skip to content
Design8 min readUpdated 27 Oct 2026

11. The kernel: a data-oriented realization

The C-set presentation of Section 5 is a database schema, and the kernel stores it as one. Each sort is a table, each structural arrow a column of foreign keys, and each facet a sparse set of typed columns (Figure 19). The design follows data-oriented practice in game engines [130, 157]: lay data out by access pattern, process it in batches, and keep identity separate from location.

11.1 Tables, rows and bytes#

Table 12 gives the tables and the width of each column. Two choices dominate the layout.

  • Hot and cold columns. A traversal reads only small integer columns: the 11-byte incidence row, the offset arrays and the family and role codes. Identifiers, names, contracts and attributes live in cold columns that a traversal never touches. Each cache line then carries useful data, and a scan of all incidences reads about 11 bytes per incidence.

  • Codes, not strings. Kinds, families, roles and facets are small integer codes from the signature, and strings are interned once. Comparing a role is one byte compare, and a selector is a set of codes.

Table 12. Kernel tables and column widths. Hot columns are what traversals read; cold columns hold identity, names and attributes.
Table Hot columns (bytes) Cold columns (bytes) Hot bytes per row
Node kind (2), parent (4), pre-order index (4), subtree size (4), facet mask (8) identifier (16), name (4) 22
Port owner (4), family (1), role (1), ownership (1), QoS (4) identifier (16), contract (4), name (4) 11
Hyperedge family (1), scope (4), attribute offset (4) identifier (16) 9
Incidence edge (4), end (4), role (1), position (2) – 11
Indexes hyperedge offsets (4 per hyperedge); port to incidence (4 per port); ports and children per owner (4 per node) element to incidences, for assertions (4 per incidence) –

What fits where#

The platform graph of Figure 2 has 226 elements, 198 ports, 100 connections with 205 incidences and 68 assertions. Its hot columns, indexes included, take about 15 KB, which fits in a first-level data cache. The 140 design graphs of the corpus take about 55 KB together. A system graph with a million nodes and ports and two million incidences needs about 50 MB of hot columns, and a scan over all its incidences reads about 22 MB, a few milliseconds at memory bandwidth. Most traversals touch a selected family or scope, which is far less.

11.2 Layout and indexes#

Layout#

Inside a process, elements are addressed by dense slots with generation counters. A handle is (slot, generation), so a stale handle cannot alias a reused slot. Handles never leave the process: at boundaries, in persistence, in deep links and on the wire, elements are named by stable identifiers. Incidences are stored sorted by hyperedge, with a compressed-sparse-row (CSR) index from each hyperedge to its incidences and an inverse index from each element to its incidences. These are incidence matrices in the layout used by sparse linear algebra [194]. Ports are stored contiguously per owner, and children per parent. Facet attributes are sparse sets keyed by slot, which avoids one archetype table for every combination of overlays. Strings are interned and contracts live in a fingerprint table. On the JVM and Native the columns are primitive arrays. In Kotlin/JS, under V8 or Hermes, they are typed arrays, so a pushed region carries the same representation.

Containment as intervals#

Each node stores its pre-order index and the size of its subtree, so “n lies in the subtree of s” is two integer comparisons. Rule W7 (boundaries) and scope selectors become interval tests, and a scope’s elements are one contiguous range when nodes are stored in pre-order.

Nets as an array#

Because a port is incident to at most one connection (W4), the index from ports to incidences is not a CSR structure but a single integer per port. Finding the connection behind a port is one load. Assertions may attach to any element many times, so their inverse index stays a CSR structure. Figure 18 shows the tables of a small graph.

Figure 18

Figure 18. A call with an interceptor and one Bind, as the kernel stores them. Incidences are sorted by hyperedge, and edgeStart is the CSR index into them. Ports are contiguous per owner, found through portStart. Because every port is in at most one connection (W4), incOfPort (shaded) is a plain array. The pre-order index and subtree size make subtree tests two comparisons. Role codes: client, server, consumer, interceptor, provider; families: Session, Bind.

Traversal loops#

A selector compiles to sets of family and role codes and, for scopes, to pre-order intervals. Message passing is then a loop over CSR segments that reads two or three arrays in order. Listing 11 shows two loops: the server behind each call, and the worst-case latency of call chains in the max-plus semiring, evaluated in one pass that visits callees before callers. Neither loop allocates, and both read only hot columns. Lattice values are encoded as integers or doubles in parallel arrays, so a pass over a partition can run on its own thread and be merged by the lattice join (Theorem 6). Bitsets hold worklists and visited sets. On the JVM the inner loops are candidates for automatic vectorization.

class Columns(
    val portOwner: IntArray, val portFamily: ByteArray, val portRole: ByteArray,
    val portStart: IntArray, val edgeFamily: ByteArray, val edgeStart: IntArray,
    val incEnd: IntArray, val incRole: ByteArray, val incOfPort: IntArray, val incEdge: IntArray,
)

fun Columns.serverOf(edge: Int): Int {
    for (i in edgeStart[edge] until edgeStart[edge + 1]) {
        if (incRole[i] == SERVER) return portOwner[incEnd[i]]
    }
    return NONE
}

fun Columns.worstLatency(calleesFirst: IntArray, hop: DoubleArray, out: DoubleArray) {
    for (n in calleesFirst) {
        var worst = 0.0
        for (p in portStart[n] until portStart[n + 1]) {
            if (portFamily[p] != SESSION || portRole[p] != CLIENT) continue
            val e = incEdge[incOfPort[p]]
            worst = maxOf(worst, hop[e] + out[serverOf(e)])
        }
        out[n] = worst
    }
}

Listing 11.

Two kernel loops over the columns of Figure 18 (proposed implementation).

11.3 Revisions, persistence and runtimes#

Revisions#

Columns are divided into immutable chunks. A revision is a root that points to chunk versions, so a commit copies only the chunks it changes [101]. Taking a snapshot is O(1), and readers pin roots, which gives multiversion concurrency control [33]. Each commit also appends its delta to a change log as a Z-set of inserted and removed rows. The same delta feeds incremental traversals (Proposition 7), graph diffs and observers. Merkle digests are recomputed only along the containment paths that changed [240]. Named refs and proposals (Section 9) are kernel metadata over roots. Chunks hold 4,096 rows, so a row’s chunk is its index shifted right by twelve bits, and a patch that touches a few elements copies a few chunks. A revision’s root lists one chunk reference per column. Roots and chunks are reference-counted, and a chunk is freed when no pinned root reaches it. One writer per consistency domain commits; readers never lock, because what they read never changes.

Encoding and transport#

A revision persists as a column dump: a header and each column’s raw little-endian array, which can be memory-mapped and read without parsing. Messages that cross a boundary, such as patches, plans, findings, observations and FFI payloads, travel as FlexBuffers frames (Section 13.5). A receiver reads them in place from a JVM byte buffer, a JavaScript array buffer or C++ memory, so a pushed region, a Worker and a native host all decode the same bytes without copying.

Per runtime#

  • JVM and Android. Columns are primitive arrays, and handles are value classes over a 64-bit integer, so nothing is boxed. Snapshots may live off the heap in memory segments.

  • JavaScript, V8 and Hermes. Columns are typed arrays. Kotlin’s 64-bit integers are emulated in JavaScript, so hot loops never use them: identifiers are four 32-bit lanes, and handles are a slot and a generation in two 32-bit arrays. Hermes runs precompiled bytecode, mostly without a just-in-time compiler, which is why hypothesis H3 sets a lower throughput target there.

  • Native and C++. Columns are plain arrays that an FFI trunk can pin and hand to C++ as spans, so a native component reads the graph without a copy.

11.4 Plans and execution#

Plans off the hot path#

No call consults the graph. Activation compiles each consumer port into a direct reference (for Bind), a stub for its Session realization (local, FFI or RPC) or a channel endpoint. Interceptor chains are compiled into arrays. A local call through a Bind therefore costs one indirection and a check for interceptors. Observations name graph identifiers but never write to the graph. Because plans are compiled ahead of time, work already admitted continues through an outage of the control plane. Only operations that need a fresh grant, a reachable authority or a coordinated change stop.

Figure 19

Figure 19. The kernel stores the C-set presentation directly: one table per sort, foreign keys as columns, CSR indexes for incidence and containment, facets as sparse sets, and revisions as persistent roots over shared immutable chunks with a Z-set change log.

Table 13. Kernel operations. The middle column describes the current runtime’s object graph as surveyed for Section 2. The RG column gives design bounds; hypotheses H3 and H4 (Section 20.4) measure the first three.
Operation Current runtime (object graph) RG kernel (columnar; design bound)
Resolve a consumer’s provider search up to the root with hashing; order-dependent O(1) through the compiled plan; resolution itself is a monotone traversal
Enumerate the connections of one family full walk with allocation O(|Ik|) contiguous scan
Take a snapshot full walk on every navigation change O(1): pin a root
Diff two revisions not available O(|Δ|) from the log; O(n) by identifier merge
Canonical digest not available O(n) once; O(|Δ|⋅𝑑𝑒𝑝𝑡ℎ) thereafter
Validate a change not available (immediate mutation) O(|𝑝𝑎𝑡𝑐ℎ|+|𝑟𝑒𝑎𝑑𝑠𝑒𝑡|) (Proposition 9)
Mount a self-contained scope imperative construction pushout, O(|S|+|J|)
Find the connection behind a port search the owner’s relations one load (W4)
Test subtree membership walk up the parents two comparisons (pre-order interval)
Serialise reflection and JSON per object column dump, O(n)