Struct egg::BackoffScheduler
source · pub struct BackoffScheduler { /* private fields */ }
Expand description
A RewriteScheduler
that implements exponentional rule backoff.
For each rewrite, there exists a configurable initial match limit. If a rewrite search yield more than this limit, then we ban this rule for number of iterations, double its limit, and double the time it will be banned next time.
This seems effective at preventing explosive rules like associativity from taking an unfair amount of resources.
BackoffScheduler
is configurable in the builder-pattern style.
Implementations§
source§impl BackoffScheduler
impl BackoffScheduler
sourcepub fn with_initial_match_limit(self, limit: usize) -> Self
pub fn with_initial_match_limit(self, limit: usize) -> Self
Set the initial match limit after which a rule will be banned. Default: 1,000
sourcepub fn with_ban_length(self, ban_length: usize) -> Self
pub fn with_ban_length(self, ban_length: usize) -> Self
Set the initial ban length. Default: 5 iterations
sourcepub fn do_not_ban(self, name: impl Into<Symbol>) -> Self
pub fn do_not_ban(self, name: impl Into<Symbol>) -> Self
Never ban a particular rule.
sourcepub fn rule_match_limit(self, name: impl Into<Symbol>, limit: usize) -> Self
pub fn rule_match_limit(self, name: impl Into<Symbol>, limit: usize) -> Self
Set the initial match limit for a rule.
sourcepub fn rule_ban_length(self, name: impl Into<Symbol>, length: usize) -> Self
pub fn rule_ban_length(self, name: impl Into<Symbol>, length: usize) -> Self
Set the initial ban length for a rule.
Trait Implementations§
source§impl Debug for BackoffScheduler
impl Debug for BackoffScheduler
source§impl Default for BackoffScheduler
impl Default for BackoffScheduler
source§impl<L, N> RewriteScheduler<L, N> for BackoffScheduler
impl<L, N> RewriteScheduler<L, N> for BackoffScheduler
source§fn search_rewrite<'a>(
&mut self,
iteration: usize,
egraph: &EGraph<L, N>,
rewrite: &'a Rewrite<L, N>
) -> Vec<SearchMatches<'a, L>>
fn search_rewrite<'a>( &mut self, iteration: usize, egraph: &EGraph<L, N>, rewrite: &'a Rewrite<L, N> ) -> Vec<SearchMatches<'a, L>>
A hook allowing you to customize rewrite searching behavior.
Useful to implement rule management. Read more
source§fn search_rewrites<'a>(
&mut self,
iteration: usize,
egraph: &EGraph<L, N>,
rewrites: &[&'a Rewrite<L, N>],
limits: &RunnerLimits
) -> RunnerResult<Vec<Vec<SearchMatches<'a, L>>>>
fn search_rewrites<'a>( &mut self, iteration: usize, egraph: &EGraph<L, N>, rewrites: &[&'a Rewrite<L, N>], limits: &RunnerLimits ) -> RunnerResult<Vec<Vec<SearchMatches<'a, L>>>>
A hook allowing you to customize rewrite searching behavior
across rewrites. Read more
source§fn apply_rewrite(
&mut self,
iteration: usize,
egraph: &mut EGraph<L, N>,
rewrite: &Rewrite<L, N>,
matches: Vec<SearchMatches<'_, L>>
) -> usize
fn apply_rewrite( &mut self, iteration: usize, egraph: &mut EGraph<L, N>, rewrite: &Rewrite<L, N>, matches: Vec<SearchMatches<'_, L>> ) -> usize
A hook allowing you to customize rewrite application behavior.
Useful to implement rule management. Read more
Auto Trait Implementations§
impl Freeze for BackoffScheduler
impl RefUnwindSafe for BackoffScheduler
impl Send for BackoffScheduler
impl Sync for BackoffScheduler
impl Unpin for BackoffScheduler
impl UnwindSafe for BackoffScheduler
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more