cespare / xxhash

A Go implementation of the 64-bit xxHash algorithm (XXH64)
MIT License
1.79k stars 123 forks source link

Mark []byte passed to Sum64 as noescape #2

Closed davecheney closed 8 years ago

davecheney commented 8 years ago

The compiler cannot tell if arguments passed to an asm function escape so it assumes that they always do. Mark arguments passed to Sum64 as noescape so any temporary created from a []byte(string) conversion does not escape.

% benchstat {old,new}.txt
name          old time/op    new time/op    delta
StringHash-4    80.8ns ± 4%    20.8ns ± 0%   -74.25%   (p=0.000 n=10+9)

name          old alloc/op   new alloc/op   delta
StringHash-4     16.0B ± 0%     0.0B ±NaN%  -100.00%  (p=0.000 n=10+10)

name          old allocs/op  new allocs/op  delta
StringHash-4      1.00 ± 0%     0.00 ±NaN%  -100.00%  (p=0.000 n=10+10)
cespare commented 8 years ago

Thanks Dave!