pub enum Profiler {
Active {
start: Instant,
interval: Duration,
embed: Mutex<EmbedState>,
chunk_counts: Mutex<Vec<usize>>,
on_progress: Option<Box<dyn Fn(&str) + Send + Sync>>,
on_embed_tick: Option<Box<dyn Fn(&EmbedProgress) + Send + Sync>>,
},
Noop,
}Variants§
Active
Actively collects timing and prints to stderr.
Fields
Noop
No-op profiler. All methods are empty.
Implementations§
Source§impl Profiler
impl Profiler
Sourcepub fn new(enabled: bool, interval: Duration) -> Self
pub fn new(enabled: bool, interval: Duration) -> Self
Create a new profiler. If enabled is false, returns Noop.
Sourcepub fn with_callback(
interval: Duration,
cb: impl Fn(&str) + Send + Sync + 'static,
) -> Self
pub fn with_callback( interval: Duration, cb: impl Fn(&str) + Send + Sync + 'static, ) -> Self
Create an active profiler that drives a progress callback instead of printing to stderr. The callback receives formatted status messages at each pipeline phase transition and embed progress tick.
Sourcepub fn with_embed_tick(
self,
cb: impl Fn(&EmbedProgress) + Send + Sync + 'static,
) -> Self
pub fn with_embed_tick( self, cb: impl Fn(&EmbedProgress) + Send + Sync + 'static, ) -> Self
Set a callback that fires on every embed chunk completion with (done, total).
Unlike the throttled on_progress callback, this fires for every chunk
so progress bars can update smoothly (indicatif handles display rate).
Sourcepub fn header(
&self,
version: &str,
model_repo: &str,
threads: usize,
cores: usize,
)
pub fn header( &self, version: &str, model_repo: &str, threads: usize, cores: usize, )
Print the system info header line.
Sourcepub fn phase(&self, name: &'static str) -> PhaseGuard<'_>
pub fn phase(&self, name: &'static str) -> PhaseGuard<'_>
Start timing a named phase. Returns a guard that prints on drop.
Sourcepub fn chunk_thread_report(&self, n: usize)
pub fn chunk_thread_report(&self, n: usize)
Record that a rayon thread produced n chunks during the chunk phase.
Sourcepub fn chunk_summary(
&self,
total_chunks: usize,
total_files: usize,
elapsed: Duration,
)
pub fn chunk_summary( &self, total_chunks: usize, total_files: usize, elapsed: Duration, )
Print the chunk phase summary with thread utilization stats.
Sourcepub fn embed_begin(&self, total: usize)
pub fn embed_begin(&self, total: usize)
Begin the embed phase. Call before the embedding loop.
Sourcepub fn embed_begin_update_total(&self, total: usize)
pub fn embed_begin_update_total(&self, total: usize)
Update the total chunk count for the embed phase.
Used by the streaming pipeline where the total isn’t known at
[embed_begin] time. Only updates if the new total is larger
than the current one (monotonic).
Sourcepub fn embed_tick(&self, done: usize)
pub fn embed_tick(&self, done: usize)
Called after each chunk is embedded. Prints periodic progress.
Sourcepub fn embed_tick_bytes(
&self,
done_chunks: usize,
bytes_processed: u64,
total_bytes: u64,
)
pub fn embed_tick_bytes( &self, done_chunks: usize, bytes_processed: u64, total_bytes: u64, )
Byte-based progress for streaming mode.
Shows processed_bytes/total_bytes as MB with chunk rate. The total is
known from the walk phase (file sizes), so the denominator is stable.
Sourcepub fn embed_lock_wait(&self, duration: Duration)
pub fn embed_lock_wait(&self, duration: Duration)
Accumulate time spent waiting for the model mutex lock.
Sourcepub fn embed_inference(&self, duration: Duration)
pub fn embed_inference(&self, duration: Duration)
Accumulate time spent in ONNX inference.
Sourcepub fn embed_done(&self)
pub fn embed_done(&self)
Print the final embed phase summary.
Auto Trait Implementations§
impl !Freeze for Profiler
impl !RefUnwindSafe for Profiler
impl Send for Profiler
impl Sync for Profiler
impl Unpin for Profiler
impl UnsafeUnpin for Profiler
impl !UnwindSafe for Profiler
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.