Skip to main content

Module layout

Module layout 

Source
Expand description

Adaptive-layout learner — the decision core of online memory-layout adaptation.

Choosing the best physical layout for a component (Soa vs an AoSoA tiling, …) can’t be known a priori: it depends on the access pattern and the hardware. So the engine treats it as an explore/exploit problem and learns it on the machine it actually runs on — one Ucb1 bandit per component, arms = candidate layouts, reward = measured iteration throughput. UCB1 is deterministic (no RNG), which keeps decisions reproducible.

This module is the learner only. Wiring it to a physical repack the query path consumes requires CRPECS storage and WorldQuery::fetch to become layout-polymorphic (the column is a type-erased Vec<T> today, which only the Soa layout fits) — a larger, hot-path change tracked separately. The learner is built and tested now so that work has its decision core ready.

Beyond the textbook Ucb1, this module carries the refinements a game workload needs (all deterministic, so decisions stay reproducible): SlidingWindowUcb1 for the non-stationary reward a session produces (the best layout in a menu is not the best in a firefight), the net_reward/should_switch helpers that fold the repack cost into the decision so a learner doesn’t thrash between layouts, a DecayCounter (an evaporating access tally — recency-weighting for free), and the read-only LayoutAdvisor that turns live access counters into actionable layout advice without ever repacking.

Structs§

DecayCounter
An evaporating access tally — a counter that is added to on access and decays geometrically over time.
LayoutAdvisor
Read-only layout advisor: turns the live access counters a component has accumulated into an actionable layout suggestion, without ever repacking.
SlidingWindowUcb1
A sliding-window UCB1 bandit for non-stationary rewards.
Ucb1
A deterministic UCB1 multi-armed bandit.

Enums§

LayoutRecommendation
A layout the LayoutAdvisor can recommend for a component.

Functions§

net_reward
Net reward of running under a layout once the cost of getting there is charged against it: benefit − migration_cost.
should_switch
Whether a challenger layout should displace the incumbent, given a hysteresis margin it must clear: challenger > incumbent + hysteresis.