Cacheline Notes   Benchmarks   GitHub

Sub-Microsecond Insect Agency in 92 KB of Cache

Simulating honeybee spatial learning, obstacle avoidance, and path integration in pure Rust without heap allocations.

November 2026. Isaac Sollecito.

Arena simulation: agent, obstacles and foraging targets

2D headless arena simulation over 500,000 steps. Early exploratory random walk transitions into direct foraging vectors and path-integrated homing runs, reducing obstacle collisions by 98.5%.

Benchmarks

MetricResult
Throughput146,000 steps/sec (1 thread, commodity CPU)
Live memory92.4 KB (Agent 94,416 B, Sim 168 B)
Dynamic allocations0 in the simulation loop
Trajectory convergence758 steps/delivery (naive), 365 steps/delivery (converged)
Collision rate8,486 bumps/window (early), under 130 bumps/window (late)

Architecture

Central Complex

Heading is held by a 32-unit continuous ring-attractor compass. Unit activity rir_i, with preferred angle θi=2πi/32\theta_i = 2\pi i / 32, evolves as

τdridt=−ri+ϕ ⁣(∑jWij rj+Ii),Wij=w0cos⁡(θi−θj)−w1,\tau \frac{dr_i}{dt} = -r_i + \phi\!\left(\sum_{j} W_{ij}\, r_j + I_i\right), \qquad W_{ij} = w_0 \cos(\theta_i - \theta_j) - w_1 ,

which sustains one activity bump whose position encodes heading. Rotation shifts the bump by a fractional circular interpolation between neighboring units, so turns smaller than one unit do not quantize away:

ri′=(1−f) ri−s+f ri−s−1,s=⌊ω Δt/Δθ⌋,f=ω Δt/Δθ−s.r_i' = (1-f)\, r_{i-s} + f\, r_{i-s-1}, \qquad s = \lfloor \omega\,\Delta t / \Delta\theta \rfloor, \quad f = \omega\,\Delta t / \Delta\theta - s .

Position is tracked by 2D dead reckoning. With decoded heading θ^\hat\theta and speed vv, the home vector is

ht+1=ht+vt(cos⁡θ^tsin⁡θ^t),\mathbf{h}_{t+1} = \mathbf{h}_t + v_t \begin{pmatrix}\cos\hat\theta_t \\ \sin\hat\theta_t\end{pmatrix},

and homing steers along −h-\mathbf{h}.

Mushroom Body

Sensory input is expanded by a sparse random projection onto 16,384 Kenyon cells. A 1.5% winner-take-all stage keeps about 246 of them, and the result is stored as a bitmask packed into [u64; 256] (2 KB), so later steps visit only active indices.

Learning is a local three-factor rule applied in place to weights from active cells kk onto output unit oo:

Δwk,o=η Rt ak eo,\Delta w_{k,o} = \eta \, R_t \, a_k \, e_o ,

where aka_k is presynaptic activity, eoe_o is an eligibility trace and RtR_t is a scalar reward. Only active cells are updated, with no gradients and no stored history beyond eoe_o.

Multi-Rate Execution

Compass integration, path integration and reflexes (obstacle avoidance) run every tick. The mushroom body’s associative evaluation runs every 8 ticks, and its output is held as a bias on the fast loop in between. Reflex latency therefore does not depend on the cost of the associative step, which is amortized over 8 steps.