pub struct CompileCache { /* private fields */ }Expand description
Content-addressed cache of JIT-compiled functions.
See the module documentation for full details.
Implementations§
Source§impl CompileCache
impl CompileCache
Sourcepub fn compile(
&mut self,
expr: ExprId,
inputs: &[ExprId],
pool: &ExprPool,
) -> Result<Arc<CompiledFn>, JitError>
pub fn compile( &mut self, expr: ExprId, inputs: &[ExprId], pool: &ExprPool, ) -> Result<Arc<CompiledFn>, JitError>
Compile expr with the given inputs, returning a cached Arc<CompiledFn>.
§Cache behaviour
- Miss: the expression is compiled via
jit::compileand the result is stored. Subsequent calls with the same(expr, inputs)pair return the cached value immediately. - Hit: returns
Arc::cloneof the cached value — O(1), no recompilation.
§Errors
Returns Err(JitError) only on a cache miss where compilation fails.
Cache hits never fail.
Sourcepub fn compile_with(
&mut self,
expr: ExprId,
inputs: &[ExprId],
pool: &ExprPool,
config: CompileConfig,
) -> Result<Arc<CompiledFn>, JitError>
pub fn compile_with( &mut self, expr: ExprId, inputs: &[ExprId], pool: &ExprPool, config: CompileConfig, ) -> Result<Arc<CompiledFn>, JitError>
Like compile but passes CompileConfig to tier selection.
Use CompileConfig::for_batch when the cached function will drive a large
call_bulk / call_batch sweep so LLVM is selected when available.
Sourcepub fn contains(&self, expr: ExprId, inputs: &[ExprId]) -> bool
pub fn contains(&self, expr: ExprId, inputs: &[ExprId]) -> bool
Returns true if a compiled function for (expr, inputs) is cached.
Sourcepub fn contains_with(
&self,
expr: ExprId,
inputs: &[ExprId],
config: CompileConfig,
) -> bool
pub fn contains_with( &self, expr: ExprId, inputs: &[ExprId], config: CompileConfig, ) -> bool
Returns true if (expr, inputs, config) is cached.
Sourcepub fn compile_count(&self) -> u64
pub fn compile_count(&self) -> u64
Total number of compilations performed (cache misses that succeeded).
Sourcepub fn hit_rate(&self) -> f64
pub fn hit_rate(&self) -> f64
Cache hit rate in [0.0, 1.0]; 0.0 when no lookups have been made.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Evict all cached functions, freeing compiled code unless other Arcs
keep them alive.
Sourcepub fn evict(
&mut self,
expr: ExprId,
inputs: &[ExprId],
) -> Option<Arc<CompiledFn>>
pub fn evict( &mut self, expr: ExprId, inputs: &[ExprId], ) -> Option<Arc<CompiledFn>>
Evict a single entry. Returns the cached function if it was present.
Sourcepub fn evict_with(
&mut self,
expr: ExprId,
inputs: &[ExprId],
config: CompileConfig,
) -> Option<Arc<CompiledFn>>
pub fn evict_with( &mut self, expr: ExprId, inputs: &[ExprId], config: CompileConfig, ) -> Option<Arc<CompiledFn>>
Evict a single entry for the given compile configuration.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for CompileCache
impl !UnwindSafe for CompileCache
impl Freeze for CompileCache
impl Send for CompileCache
impl Sync for CompileCache
impl Unpin for CompileCache
impl UnsafeUnpin for CompileCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more