Grepedia
HO

hotpath-rs

A lightweight Rust profiling toolkit for tracking CPU, memory, async performance, and concurrency with support for static reports and live TUI dashboards.

Score0
About

Overview

hotpath-rs is an easy-to-configure performance profiling toolkit designed for Rust applications. Created by Paweł Urbanek, it provides developers with a comprehensive way to analyze how their code performs, helping to identify bottlenecks related to execution time, CPU usage, memory allocations, and async task scheduling. The library is designed to be feature-gated, ensuring that it introduces zero compile-time or runtime overhead unless explicitly enabled in the build.

The tool functions as a versatile profiling engine that offers both static reports and a real-time TUI dashboard. It enables precise instrumentation of Rust functions, code blocks, async futures, streams, and channels. By using macros, developers can attribute timing and allocation metrics to specific parts of their codebase, compare performance across different git commits for regression detection, and monitor runtime behavior with live dashboards or JSON-based reports.

Some of the key features are:

  • Time, CPU & memory profiling: Identifies expensive functions, allocation hotspots, and memory leaks.
  • Async observability: Provides deep insight into futures, channels, and streams behavior.
  • Concurrency metrics: Tracks Mutex and RwLock wait times and contention issues.
  • Tokio runtime monitoring: Monitors workers, task scheduling, and internal queues.
  • Live TUI dashboard: Allows for real-time performance monitoring and data flow visualization.
  • Static reports: Supports generation of timing and memory reports for one-off analysis.
  • CI regression detection: Facilitates automatic benchmarking of every pull request.
  • MCP server for AI agents: Allows AI agents to query profiling data in real time.

To use hotpath-rs, developers integrate it via their Cargo.toml with specific feature flags, such as hotpath, hotpath-cpu, or hotpath-alloc. Once integrated, core macros like #[hotpath::main] and #[hotpath::measure] are used to annotate the functions or code blocks that require profiling. The library operates by intercepting calls and processing them through a background handler, generating reports either upon program exit or displaying them continuously in an interactive terminal user interface. Because of its modular design, developers can toggle between lightweight timing analysis and more intensive CPU or allocation tracking depending on the current debugging needs.

Some common use cases include:

  • Performance regression testing: Tracking execution duration and memory usage across different git commits to catch performance regressions in CI.
  • Debugging async bottlenecks: Identifying slow consumers or queue buildup within channels and streams in complex asynchronous pipelines.
  • Optimizing CPU-bound functions: Using sampling-based CPU profiling to accurately attribute processor usage to specific code paths.
  • Runtime monitoring: Running a live TUI dashboard alongside production or staging services to diagnose real-time latency issues or resource usage spikes.