← ClaudeAtlas

rust-hot-pathlisted

Use after a profiler names a hotspot, when you must decide what to change in the code rather than which tool to run. Covers allocation rate (Vec growth, with_capacity, reserve_exact, clone_from, workhorse buffers, format! in a loop), type size (print-type-sizes, the memcpy boundary, boxing a large enum variant, Box<[T]> and ThinVec, repr(C) padding), hasher choice with the HashDoS gate, iterators and size_hint, bounds check removal, inline attributes and cold paths, and buffered I/O. Also covers pinning the win with a const size assert and a dhat allocation test. Triggers on "reduce allocations", "too many allocations", "this type is too big", "large_enum_variant", "which hasher", "FxHashMap", "bounds check", "inline always", "cold path", "BufWriter", "clone_from", "SmallVec", "swap_remove", or any question about what to change once a hot path is known.
po4yka/rust-skills · ★ 2 · AI & Automation · score 76
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