github.com/aclements/go-misc@v0.0.0-20240129233631-2f6ede80790c/varint/README.md (about) 1 This directory contains experiments with varint decoding using 2 hand-coded assembly. 3 4 The simple assembly loop is 15–30% faster than the Go loop. The loop 5 is somewhat clever, but in principle the compiler could probably 6 produce this code. 7 8 Most of the code experiments with BMI2 instructions. This requires 9 Haswell or newer, which the benchmark will detect. This approach is 10 constant time up to 8 byte varints (56 bit values). It's 50% faster 11 than the Go code for 8 byte varints, but 80% slower for one byte 12 varints.