SMRTR ProgrammingAug 3, 2026lobste.rs

Branchless Rust: Making a Filter 4x Faster by Removing an if

SMRTR summary

Branch misprediction — not memory allocation — is why a simple filter runs slowest at 50% selectivity on random data. When data is unpredictable, the CPU's branch predictor fails half the time, costing 15–20 cycles per miss. Replacing the conditional write with unconditional writes and pointer arithmetic eliminates the branch entirely, making the worst case nearly 4x faster.

SMRTR provides this summary for quick context. The original article belongs to lobste.rs.

Read the original article
SMRTR Programming

Get the next batch of curated stories in your inbox.

This archive is built from SMRTR newsletter stories. Subscribe for hand-picked stories without the extra noise.

Related Stories

Browse Programming
ProgrammingAug 23, 2026

Rust Glancer

Rust-analyzer's memory bloat stems from treating all 6,666 dependencies equally — a tiered, IntelliJ-style backend could fix that.