Skip to main content

Ft-bzero Jun 2026

However, there is a catch. Compilers are smart. If you call ft_bzero on a buffer and then free it, the compiler might optimize away the bzero call because it seems "unnecessary" (dead store elimination).

The answer is a resounding .

It does not return a value (unlike memset , which returns a pointer to s ). Its behavior is simple, deterministic, and for decades, it was the idiomatic way to clear memory buffers before use. ft-bzero

| Implementation | Time for 1 GB (approx) | Observations | | :--- | :--- | :--- | | Naive ft_bzero (byte loop) | ~500 ms | Pinned at 2 GB/s; limited by store-forwarding stalls. | | Word-wise ft_bzero (8-byte) | ~80 ms | ~12 GB/s; memory bandwidth becomes the limit. | | memset (glibc with AVX2) | ~30 ms | ~33 GB/s; uses vector registers (ymm) for 32-byte writes. | | memset (libc with ERMSB) | ~25 ms | Uses rep stosb microcode optimizations. | However, there is a catch