Skip to content
Opensource internals
  • Posts

Rust

Thirteen Elements, Forty-Five Comparisons: The Sorting Network in Rust's sort

Oct 21, 2026 4 min read Jay Hubbert

For small slices Rust sorts with a fixed branchless sorting network - Dobbelaere’s optimal 13-element network - because mispredicted branches cost more than the extra comparisons.

RustInternalsStdPerformanceSorting

Read more →

SipHash's Field Order Is a SIMD Hint: How Rust's Default Hasher Vectorises Itself

Oct 21, 2026 4 min read Jay Hubbert

Rust’s SipHash-1-3 stores its four state words as v0, v2, v1, v3 - a field order chosen so the compiler can auto-vectorise the ARX round into two SIMD lanes.

RustInternalsStdPerformanceHashingSimd

Read more →

Sixteen Buckets at a Time: The SwissTable in Rust's HashMap

Oct 21, 2026 8 min read Jay Hubbert

Rust’s HashMap uses a SwissTable with SSE2 group scanning: one movemask compares 16 control bytes at once, and the top 7 bits of the hash act as a filter before any key comparison.

RustInternalsStdPerformanceHashmapSimd

Read more →

collect() Reuses Your Allocation: Rust's In-Place Collection

Oct 21, 2026 5 min read Jay Hubbert

Rust’s in-place collect reuses the source Vec’s allocation when the iterator and element sizes allow it, turning map+collect into a loop with no allocation.

RustInternalsStdPerformanceIterators

Read more →

Vec's Capacity Lives in a Niche: How Rust's RawVec Got One Word Smaller

Oct 21, 2026 6 min read Jay Hubbert

Rust’s RawVec keeps its capacity in a niche-typed UsizeNoHighBit, making Vec three words, with a growth policy of max(2*cap, required) and a tiny-vector minimum of 8 bytes for u8.

RustInternalsStdPerformanceData structures

Read more →

← Newer Page 3 of 8 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·