Skip to main content

RenderMemo

Struct RenderMemo 

Source
pub struct RenderMemo(/* private fields */);
Expand description

A bounded, content-addressed featurization memo.

Cheap to clone (shared interior) and guarded by a Mutex, and every access here is uncontended.

This used to say the Send + Sync shape was for fugue_evo::Fitness, “if the parallel feature were ever enabled”. Enabling it would do nothing: every rayon use in fugue-evo is under #[cfg(feature = "classic")] — the classic EC layer’s algorithms/, population/ and fitness/ — and the workspace takes fugue-evo with ["std", "ppl"], driving refinement itself through inference::mh::EvolutionChain. The flag would compile rayon in and change no code path this crate reaches.

Parallelising refinement is still possible, just Auracle-side and worth less than it looks: search_health and the refinement_improves_pool floor already spawn a thread per seed and saturate the cores, so a measurement would not get faster. What it would buy is latency on a single refinement — the app’s ⚡ button — which is a UX win rather than a harness one, and this type is shaped for it either way.

Two tiers, both LRU, because they cost three orders of magnitude apart: ~1 KB of φ against ~565 KB of audio. Keeping thousands of the former and a dozen of the latter is what lets a whole refinement generation stay resident while audition memory stays flat.

Implementations§

Source§

impl RenderMemo

Source

pub fn new(feature_cap: usize, audio_cap: usize) -> Self

A memo holding feature_cap φ entries and audio_cap audition buffers, both LRU.

Source

pub fn disabled() -> Self

A memo that stores nothing — the null object for callers that want the unmemoized path without a second code path.

Source

pub fn get(&self, key: &str) -> Option<CachedFeatures>

Features for key, if resident. Counts as a use for LRU purposes.

Source

pub fn get_audio(&self, key: &str) -> Option<Arc<Audition>>

Audition buffer for key, if resident. Counts as a use.

Shared, not copied: a ~565 KB buffer is handed out as an Arc so that looking one up costs a refcount bump rather than a half-megabyte memcpy. Callers that need to own samples clone the inner value explicitly, which makes every deep copy of an audition visible at its call site.

Source

pub fn put(&self, entry: CachedFeatures, audio: Option<Arc<Audition>>)

Store a featurization, optionally with its audition buffer.

Source

pub fn stats(&self) -> MemoStats

Occupancy and hit accounting.

Source

pub fn clear(&self)

Drop everything. Used when the phrase spec changes under a live engine, which would otherwise leave keys from two stimuli in one map.

Trait Implementations§

Source§

impl Clone for RenderMemo

Source§

fn clone(&self) -> RenderMemo

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RenderMemo

Source§

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

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

impl Default for RenderMemo

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,