Skip to content
Opensource internals
  • Posts

Std

Sixteen Bytes at a Time: How Rust Validates UTF-8

Oct 21, 2026 4 min read Jay Hubbert

Rust’s str validation is word-at-a-time: it reads two usize at a time looking for high bits, so pure-ASCII strings are validated at 16 bytes per iteration instead of one.

RustInternalsStdPerformanceUnicodeSimd

Read more →

One XOR and One CLZ: How Rust's Stable Sort Decides Which Runs to Merge

Oct 21, 2026 4 min read Jay Hubbert

Rust’s stable sort implements the powersort merge-tree heuristic from Munro and Wild, with the depth of each merge node computed as the leading zeros of an XOR of scaled midpoints.

RustInternalsStdPerformanceSortingAlgorithms

Read more →

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 →

← Newer Page 1 of 2 Older →

© 2026 Jay Hubbert · Built with Hugo 0.168.0

RSS ·