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

source

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

source

pub fn with_ban_length(self, ban_length: usize) -> Self

Set the initial ban length. Default: 5 iterations

source

pub fn do_not_ban(self, name: impl Into<Symbol>) -> Self

Never ban a particular rule.

source

pub fn rule_match_limit(self, name: impl Into<Symbol>, limit: usize) -> Self

Set the initial match limit for a rule.

source

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

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for BackoffScheduler

source§

fn default() -> Self

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

impl<L, N> RewriteScheduler<L, N> for BackoffSchedulerwhere L: Language, N: Analysis<L>,

source§

fn can_stop(&mut self, iteration: usize) -> bool

Whether or not the Runner is allowed to say it has saturated. Read more
source§

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

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.