pub struct SiteAddrs { /* private fields */ }Expand description
The MCMC site addresses of one taste program, built once.
Single-site MH re-executes the whole program on every step, so every
sample() node — d·K + S + (n_stars − 1) + K·G of them, 206 as
shipped (K = 5, d = 40, one session, and no fused group, since the fused
prior defaults to off; a group would add K) — is reconstructed
26 000 times per fit. Building each address inline
(addr!(format!("theta{k}"), i)) therefore cost a format! into a
String, a re-allocation into Arc<str> and a SipHash of that string,
per site per step: ~3.7 M allocations per mature fit, and measurably the
bulk of the fit’s wall time (see examples/fit_bench.rs — the fit is
steps × sites-shaped, and the likelihood is ~20 % of it even at
n_obs = 100).
The addresses are a pure function of (k_styles, n_features, n_stars, n_sessions), none of which move during a fit, so they are built once and
[Address] is cloned into each node — an Arc refcount bump plus a copy
of the cached hash, no allocation and no hashing.
The strings are produced by the same addr! invocations as before
(theta<k>#i, tau#s, cut#j), so traces, serialized posteriors and any
warm-start path see byte-identical addresses.
Implementations§
Source§impl SiteAddrs
impl SiteAddrs
Sourcepub fn site_count(&self) -> usize
pub fn site_count(&self) -> usize
Total sample() nodes in the program — what single-site MH divides its
step budget across, and the number the fit’s cost is linear in.
d·K + S + (n_stars − 1) + K·G, where G is the number of fused
groups. At K = 5, d = 40, S = 1 and one brightness group that is
200 + 1 + 5 + 5 = 211; without the group it is the 206 the module
doc quotes.
Sourcepub fn new(cfg: &TasteConfig, n_sessions: usize) -> Self
pub fn new(cfg: &TasteConfig, n_sessions: usize) -> Self
Build the address table for cfg over a log spanning n_sessions.