Skip to main content

Crate hotpath

Crate hotpath 

Source
Expand description

hotpath-rs is a simple async Rust profiler. It instruments functions, channels, futures, and streams to quickly find bottlenecks and focus optimizations where they matter most. It can provide actionable insights into time, memory, and data flow with minimal setup.

§Setup & Usage

For a complete setup guide, examples, and advanced configuration, visit hotpath.rs.

Re-exports§

pub use json::Route;

Modules§

channels
Channel instrumentation module - tracks message flow, queue sizes, and channel state.
cpu_baseline
data_flow
Unified data flow module - provides shared counter and types for channels, streams, and futures.
debug
Debug subsystem - value logging, debug logging, and gauges.
functions
Function profiling module - measures execution time and memory allocations per function.
futures
Futures instrumentation module - tracks async Future lifecycle and poll statistics.
hotpath_guard
json
JSON serializable types for TUI and CLI consumers.
streams
Stream instrumentation module - tracks items yielded and stream lifecycle.
threads
This module provides real-time thread monitoring capabilities, collecting CPU usage statistics for all threads in the current process.

Macros§

channel
Instrument a channel creation to wrap it with debugging proxies.
dbg
Debug macro that tracks debug output in the profiler.
future
Instrument a future to inspect future’s lifecycle events.
gauge
Gauge macro for tracking numeric values with set/inc/dec operations.
measure_block
Measures the execution time or memory allocations of a code block.
stream
Instrument a stream to track its item yields.
tokio_runtime
val
Value tracking macro that logs key-value pairs to the profiler.

Structs§

FunctionLogsList
Response containing recent logs for a function
FunctionStats
HotpathGuard
RAII guard that owns the profiler lifetime.
HotpathGuardBuilder
Builder for HotpathGuard — a programmatic alternative to the #[hotpath::main] macro for configuring and initializing the profiler.
MeasurementGuard
MeasurementGuardWithLog

Enums§

Format
Output format for profiling reports.
MetricType
Represents different types of profiling metrics with their values.
OutputDestination
Destination for profiling report output.
ProfilingMode
Profiling mode indicating what type of measurements were collected.
Section

Constants§

MAX_RESULT_LEN

Traits§

IntoF64
MetricsProvider
Trait for accessing profiling metrics data.

Functions§

ceil_char_boundary
floor_char_boundary
format_bytes
Formats a byte count into a human-readable string (e.g., “1.5 MB”).
format_debug_truncated
format_duration
Formats a duration in nanoseconds into a human-readable string with appropriate units.
parse_bytes
Parses a human-readable byte string back to a byte count. Inverse of format_bytes.
parse_duration
Parses a human-readable duration string back to nanoseconds. Inverse of format_duration.
shorten_function_name

Type Aliases§

FunctionsData
Structured per-function profiling metrics data as an ordered list.

Attribute Macros§

future_fn
Instruments an async function to track its lifecycle as a Future.
main
Initializes the hotpath profiling system and generates a performance report on program exit.
measure
Instruments a function to measure execution time or memory allocations.
measure_all
Instruments all functions in a module or impl block with the measure profiling macro.
skip
Marks a function to be excluded from profiling when used with measure_all.