Skip to content

Commit

Permalink
lib.ctable/lib.hash.siphash: optimize traces
Browse files Browse the repository at this point in the history
Remove some redundant casts that were introducing unsunk cnewi.

Reformulate make_multi_hash optimal path to reduce side trace generation.
  • Loading branch information
eugeneia committed Oct 12, 2022
1 parent 5fe89b5 commit 4706127
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/lib/ctable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,6 @@ end
function LookupStreamer:stream()
local width = self.width
local entries = self.entries
local keys = self.keys
local pointers = self.pointers
local stream_entries = self.stream_entries
local entries_per_lookup = self.entries_per_lookup
Expand Down
14 changes: 2 additions & 12 deletions src/lib/hash/siphash.dasl
Original file line number Diff line number Diff line change
Expand Up @@ -576,8 +576,6 @@ local function make_hash2(opts)
local hash = make_hash1(opts)
local stride = opts.stride or opts.size
return function(ptr, result)
ptr = ffi.cast('uint8_t*', ptr)
result = ffi.cast('uint32_t*', result)
result[0] = hash(ptr)
result[1] = hash(ptr + stride)
end
Expand All @@ -587,8 +585,6 @@ local function make_hash4(opts)
local hash = make_hash2(opts)
local stride = opts.stride or opts.size
return function(ptr, result)
ptr = ffi.cast('uint8_t*', ptr)
result = ffi.cast('uint32_t*', result)
hash(ptr, result)
hash(ptr + stride*2, result + 2)
end
Expand All @@ -612,19 +608,13 @@ function make_multi_hash(opts)

if width % 4 == 0 then
return function(input, output)
input = ffi.cast('uint8_t*', input)
output = ffi.cast('uint32_t*', output)
for i=1,width,4 do
hash4(input, output)
input = input + stride*4
output = output + 4
for i=0,width-1,4 do
hash4(input + stride*i, output + i)
end
end
end

return function(input, output)
input = ffi.cast('uint8_t*', input)
output = ffi.cast('uint32_t*', output)
for i=1,bit.rshift(width, 2) do
hash4(input, output)
input = input + stride*4
Expand Down

0 comments on commit 4706127

Please sign in to comment.