pub struct IndexScratch<Cfg: EGraphConfig> { /* private fields */ }Expand description
The (key, value) streams the four families are built from, kept alive
across rounds.
A round builds a full index and, under semi-naive evaluation, a delta index;
both are dropped at the end of the round. The streams are proportional to the
node count and to the total arity, so allocating them per build would mean
faulting in tens of megabytes eleven times over a saturation of
math-microbenchmark. One scratch threaded through the round loop keeps the
pages resident and the capacity at the high-water mark.
The stream buffers hold no state between builds: IndexStore::build_with
clears them on entry, and the built DenseSpanMaps own copies of what they
held. The span arenas are the opposite: they are kept precisely so their
allocation and their generation stamp survive, and their leftover content is
what the stamp invalidates.
Two index stores are alive at once under semi-naive evaluation (the full index and the round’s delta), so the arenas are kept in two sets of four rather than one: a family’s key space is stable across rounds, so pairing each family with its own arena keeps the table at the size that family needs instead of thrashing it between a 2 M-key and a 100-key build.
An arena is handed out by IndexStore::build_from and comes back through
IndexStore::recycle_into. A caller that forgets to recycle loses only the
reuse: the next build allocates a fresh arena and is correct, just slower.
Implementations§
Source§impl<Cfg: EGraphConfig> IndexScratch<Cfg>
impl<Cfg: EGraphConfig> IndexScratch<Cfg>
pub fn new() -> Self
Sourcepub fn arena_capacity(&self) -> usize
pub fn arena_capacity(&self) -> usize
Total span-table capacity held across all eight arenas, in entries.
Read by phase_timing so the memory the reuse keeps resident is
reported rather than assumed; a recycled table is held for the whole run
where a per-build table was freed each round.