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
impl RenderMemo
Sourcepub fn new(feature_cap: usize, audio_cap: usize) -> Self
pub fn new(feature_cap: usize, audio_cap: usize) -> Self
A memo holding feature_cap φ entries and audio_cap audition
buffers, both LRU.
Sourcepub fn disabled() -> Self
pub fn disabled() -> Self
A memo that stores nothing — the null object for callers that want the unmemoized path without a second code path.
Sourcepub fn get(&self, key: &str) -> Option<CachedFeatures>
pub fn get(&self, key: &str) -> Option<CachedFeatures>
Features for key, if resident. Counts as a use for LRU purposes.
Sourcepub fn get_audio(&self, key: &str) -> Option<Arc<Audition>>
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.
Trait Implementations§
Source§impl Clone for RenderMemo
impl Clone for RenderMemo
Source§fn clone(&self) -> RenderMemo
fn clone(&self) -> RenderMemo
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more