rust-hot-pathlisted
Install: claude install-skill po4yka/rust-skills
# Rust hot path
## Purpose
What to change in the code after a profile names the hot spot. The `rust-performance` skill
produces the profile; this skill turns it into a diff.
Every rule here has a cost. Apply one when a measurement points at it, and never as a
style preference. Optimized code is harder to read, so each change must pay for the
readability it spends.
The numbers in this skill were measured on rustc 1.97.0, aarch64 and x86_64. Std growth
policy and layout are unspecified implementation details. Re-measure them on your toolchain
before you depend on an exact figure.
## Route the profile to a section
| The profile shows | Change | Section |
| --- | --- | --- |
| `malloc`, `free`, `__rust_alloc` hot | Allocation rate | [Allocation rate](#allocation-rate) |
| `memcpy` hot with no obvious copy | A type crossed the inline-copy boundary | [Type size](#type-size) |
| `SipHasher`, `hashbrown` hot | Hasher choice | [Lookups](#lookups) |
| `core::panicking::panic_bounds_check` in the disassembly | Bounds checks the compiler could not remove | [Bounds checks](#bounds-checks) |
| `write`, `read` syscalls dominate | Missing buffering | [I/O](#io) |
| Function entry and exit costs, many small calls | Inlining | [Inlining](#inlining) |
| Nothing stands out, the work itself is the cost | Algorithm or data structure. Stop here | — |
The last row is the common one. A better algorithm beats every rule below. Reach for this
skill after you accept the algorithm.
## Allocation