perf(game): eliminate per-event allocations via ScratchArena
Game::likelihoods previously allocated four Vecs (teams, diffs, ties, margins) on every call. Batch now owns one ScratchArena reused across all Game::new calls in the iteration loop; likelihoods() clears and extends the arena buffers instead of allocating fresh. For log_evidence (called infrequently), a local ScratchArena is created per invocation so the method signature stays &self. Also: add #[derive(Debug)] to TeamMessage and DiffMessage (required by ScratchArena's own Debug derive). Part of T0 engine redesign.
This commit is contained in:
@@ -436,7 +436,10 @@ mod tests {
|
||||
use approx::assert_ulps_eq;
|
||||
|
||||
use super::*;
|
||||
use crate::{ConstantDrift, EPSILON, Game, Gaussian, ITERATIONS, IndexMap, P_DRAW, Player};
|
||||
use crate::{
|
||||
ConstantDrift, EPSILON, Game, Gaussian, ITERATIONS, IndexMap, P_DRAW, Player,
|
||||
arena::ScratchArena,
|
||||
};
|
||||
|
||||
#[test]
|
||||
fn test_init() {
|
||||
@@ -500,6 +503,7 @@ mod tests {
|
||||
&[0.0, 1.0],
|
||||
&w,
|
||||
P_DRAW,
|
||||
&mut ScratchArena::new(),
|
||||
)
|
||||
.posteriors();
|
||||
let expected = p[0][0];
|
||||
|
||||
Reference in New Issue
Block a user