Skip to main content

MatchPool

Struct MatchPool 

Source
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>

Source

pub fn new() -> Self

Source

pub fn reshape(&mut self, shape: &MatchShape)

Adopt a query’s shape, dropping stored matches and keeping every flat allocation warm.

Source

pub fn row(&self, j: usize) -> MatchRow<'_, Cfg>

One stored match, by row.

Source

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).

Source

pub fn clear(&mut self)

Drop the previous query’s results without releasing their storage.

Source

pub fn push(&mut self, env: &Match<Cfg>)

Append a copy of env into the flat store.

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl<Cfg: EGraphConfig> Default for MatchPool<Cfg>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<Cfg> Freeze for MatchPool<Cfg>
where MatchSet<Cfg>: Freeze, Vec<Vec<<Cfg as EGraphConfig>::G>>: Freeze, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: Freeze,

§

impl<Cfg> RefUnwindSafe for MatchPool<Cfg>
where MatchSet<Cfg>: RefUnwindSafe, Vec<Vec<<Cfg as EGraphConfig>::G>>: RefUnwindSafe, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: RefUnwindSafe,

§

impl<Cfg> Send for MatchPool<Cfg>
where MatchSet<Cfg>: Send, Vec<Vec<<Cfg as EGraphConfig>::G>>: Send, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: Send,

§

impl<Cfg> Sync for MatchPool<Cfg>
where MatchSet<Cfg>: Sync, Vec<Vec<<Cfg as EGraphConfig>::G>>: Sync, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: Sync,

§

impl<Cfg> Unpin for MatchPool<Cfg>
where MatchSet<Cfg>: Unpin, Vec<Vec<<Cfg as EGraphConfig>::G>>: Unpin, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: Unpin,

§

impl<Cfg> UnsafeUnpin for MatchPool<Cfg>
where MatchSet<Cfg>: UnsafeUnpin, Vec<Vec<<Cfg as EGraphConfig>::G>>: UnsafeUnpin, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: UnsafeUnpin,

§

impl<Cfg> UnwindSafe for MatchPool<Cfg>
where MatchSet<Cfg>: UnwindSafe, Vec<Vec<<Cfg as EGraphConfig>::G>>: UnwindSafe, Vec<Vec<(<Cfg as EGraphConfig>::G, <Cfg as EGraphConfig>::M)>>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.