Fast memcpy, memmove, and memset for Zig.
Zig code gets these operations from compiler-rt. compiler-rt's memset is a byte loop, and its memcpy and memmove are slower than glibc on most CPUs. fastmem replaces them with kernels that are tuned per CPU model and measured against glibc and compiler-rt on seven EC2 targets. It imports only std and has no libc dependency.
- Kernels: AVX-512 and AVX2 kernels with per-model tuning, Arm Optimized Routines on aarch64, and a generic fallback.
- Runtime dispatch: one x86_64 Linux baseline binary selects AVX-512, AVX2, or generic kernels from CPUID.
- Correctness: the guard-page suite, the per-model codegen gates, and the export-layer binary checks.
- Performance: the scorecard against glibc and compiler-rt on all seven targets.
- Limits: the export layer is ELF only and needs the LLVM backend; other targets get the generic vector fallback.
zig fetch --save https://baskingspot.dev/fastmem/v0.3.0.tar.gzAdd the module in build.zig:
const fastmem = b.dependency("fastmem", .{ .target = target, .optimize = optimize });
exe.root_module.addImport("fastmem", fastmem.module("fastmem"));fastmem builds with Zig 0.17.
- The guide covers the kernels, runtime dispatch, correctness, and the measured results.
- The API reference documents every public symbol.
AGENTS.mdhas the working notes for the repository.
just cinix develop provides the toolchain. just --list shows the recipes. just ci runs what CI runs. just test-guard runs the full correctness matrix on this host. The benchmark fleet and its harness live in baskingspot/infra; this repository keeps the fastmem adapter.
MIT. See LICENSE. The aarch64 kernels are ports of Arm Optimized Routines; THIRD_PARTY.md lists every port and its terms. The logo files in docs/static/ are baskingspot marks and are not covered by it. See docs/static/LICENSE.
Built with LLM assistance. How, in detail.