pub struct MatchPool<Cfg: EGraphConfig> { /* private fields */ }Expand description
A reusable buffer of matches.
run_query emits one Match per solution, and each Match owns nine
Vecs. Freshly allocating them per match cost about nine allocations per
emitted match, and freeing them at the end of the round cost as many again —
on the plain7 workload that is the single largest source of allocator
traffic in saturation.
A pool stores each query’s solutions in one flat, stride-packed MatchSet.
Clearing or reshaping resets the vector lengths while retaining their
allocations; pushing appends bindings and rest data into those warm vectors.
Because a saturation round runs many queries of similar shapes and sizes,
the vectors reach their high-water capacities early and then allocate
little or nothing.
The two scratch free-lists (Self::take_id_buf and
friends) are deliberately not touched by Self::clear. They hold no
query state — every borrower fills them from scratch before reading, since
seq_children/set_children/mset_children all begin with buf.clear() —
so surviving a clear is the whole point of them.
Implementations§
Source§impl<Cfg: EGraphConfig> MatchPool<Cfg>
impl<Cfg: EGraphConfig> MatchPool<Cfg>
pub fn new() -> Self
Sourcepub fn reshape(&mut self, shape: &MatchShape)
pub fn reshape(&mut self, shape: &MatchShape)
Adopt a query’s shape, dropping stored matches and keeping every flat allocation warm.
Sourcepub fn clone_match(&self, j: usize) -> Match<Cfg>
pub fn clone_match(&self, j: usize) -> Match<Cfg>
Reconstruct row j as an owned Match (tests and diagnostics; this
allocates and the hot paths never call it).