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§
- Decay
Counter - An evaporating access tally — a counter that is added to on access and decays geometrically over time.
- Layout
Advisor - Read-only layout advisor: turns the live access counters a component has accumulated into an actionable layout suggestion, without ever repacking.
- Sliding
Window Ucb1 - A sliding-window UCB1 bandit for non-stationary rewards.
- Ucb1
- A deterministic UCB1 multi-armed bandit.
Enums§
- Layout
Recommendation - A layout the
LayoutAdvisorcan 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
hysteresismargin it must clear:challenger > incumbent + hysteresis.