Skip to content
rusthacks.dev
Topic

Performance

Profilers, flamegraphs, benchmarks and caches: find the slow part first, then fix only that.

Flat illustration for the post “Stale While Revalidate Caching in Rust Services Explained”, composed around perf.
Performance

Stale While Revalidate Caching in Rust Services Explained

Serve the cached value immediately, even if slightly old, and refresh it in the background. Learn the idea, the HTTP Cache-Control directives and an in-process implementation with a freshness window and a grace window.

4 min read
Flat illustration for the post “Measuring Memory Use of a Rust Program With Heaptrack”, composed around perf.
Systems

Measuring Memory Use of a Rust Program With Heaptrack

Find where a Rust program allocates and how much it holds. Use /usr/bin/time for peak RSS, heaptrack for Linux allocation timelines, the dhat crate for portable heap profiles and a counting allocator for tests.

4 min read
Flat illustration for the post “Regex Performance in Rust and Avoiding Catastrophic Cases”, composed around cargo.
CLI

Regex Performance in Rust and Avoiding Catastrophic Cases

Rust's regex crate guarantees linear-time matching, so there is no catastrophic backtracking. The real costs are compiling in a loop, unanchored scans and capture groups. Learn what to cache and when to use regex-lite.

4 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.