| author | |
| committer | |
| log | 16fa255f48ae2d290bc26ceb41489f2c3e21b96d |
| tree | 5dfc6107bf79fb8e79ab3e58143de3a2ad74add8 |
| parent | 7854a52a6b8ba541e302c5466f61e0970e5d6062 |
This gives moderate speed improvements when hashing small keys.
The crc/adler/fnv inlining did not provide enough speed up to warrant
the change.
OLD:
wyhash
small keys: 2277 MiB/s [c14617a1e3800000]
siphash(1,3)
small keys: 937 MiB/s [b2919222ed400000]
siphash(2,4)
small keys: 722 MiB/s [3c3d974cc2800000]
fnv1a
small keys: 1580 MiB/s [70155e1cb7000000]
adler32
small keys: 1898 MiB/s [00013883ef800000]
crc32-slicing-by-8
small keys: 2323 MiB/s [0035bf3dcac00000]
crc32-half-byte-lookup
small keys: 218 MiB/s [0035bf3dcac00000]
NEW:
wyhash
small keys: 2775 MiB/s [c14617a1e3800000]
siphash(1,3)
small keys: 1086 MiB/s [b2919222ed400000]
siphash(2,4)
small keys: 789 MiB/s [3c3d974cc2800000]
fnv1a
small keys: 1604 MiB/s [70155e1cb7000000]
adler32
small keys: 1856 MiB/s [00013883ef800000]
crc32-slicing-by-8
small keys: 2336 MiB/s [0035bf3dcac00000]
crc32-half-byte-lookup
small keys: 218 MiB/s [0035bf3dcac00000]2 files changed, 4 insertions(+), 4 deletions(-)
std/hash/siphash.zig+2-2| ... | @@ -152,8 +152,8 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize) | ... | @@ -152,8 +152,8 @@ fn SipHash(comptime T: type, comptime c_rounds: usize, comptime d_rounds: usize) |
| 152 | 152 | ||
| 153 | pub fn hash(key: []const u8, input: []const u8) T { | 153 | pub fn hash(key: []const u8, input: []const u8) T { |
| 154 | var c = Self.init(key); | 154 | var c = Self.init(key); |
| 155 | c.update(input); | 155 | @inlineCall(c.update, input); |
| 156 | return c.final(); | 156 | return @inlineCall(c.final); |
| 157 | } | 157 | } |
| 158 | }; | 158 | }; |
| 159 | } | 159 | } |
std/hash/wyhash.zig+2-2| ... | @@ -116,8 +116,8 @@ pub const Wyhash = struct { | ... | @@ -116,8 +116,8 @@ pub const Wyhash = struct { |
| 116 | 116 | ||
| 117 | pub fn hash(seed: u64, input: []const u8) u64 { | 117 | pub fn hash(seed: u64, input: []const u8) u64 { |
| 118 | var c = Wyhash.init(seed); | 118 | var c = Wyhash.init(seed); |
| 119 | c.update(input); | 119 | @inlineCall(c.update, input); |
| 120 | return c.final(); | 120 | return @inlineCall(c.final); |
| 121 | } | 121 | } |
| 122 | }; | 122 | }; |
| 123 | 123 |