Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lwAFTR trace performance issues (for release Alpina) #1488

Merged
merged 2 commits into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/apps/lwaftr/binding_table.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,29 @@ psid_map_value_t = ffi.typeof[[

BTLookupQueue = {}

local BTLookupQueue_size = 128
assert(BTLookupQueue_size >= engine.pull_npackets)

-- BTLookupQueue needs a binding table to get softwires and PSID lookup.
function BTLookupQueue.new(binding_table)
local ret = {
binding_table = assert(binding_table),
}
ret.streamer = binding_table.softwires:make_lookup_streamer(32)
ret.packet_queue = ffi.new("struct packet * [32]")
ret.streamer = binding_table.softwires:make_lookup_streamer(BTLookupQueue_size)
ret.packet_queue = ffi.new("struct packet * [?]", BTLookupQueue_size)
ret.length = 0
return setmetatable(ret, {__index=BTLookupQueue})
end

function BTLookupQueue:enqueue_lookup(pkt, ipv4, port)
assert(self.length < BTLookupQueue_size, "BTLookupQueue overflow")
local n = self.length
local streamer = self.streamer
streamer.entries[n].key.ipv4 = ipv4
streamer.entries[n].key.psid = port
self.packet_queue[n] = pkt
n = n + 1
self.length = n
return n == 32
end

function BTLookupQueue:process_queue()
Expand Down
15 changes: 3 additions & 12 deletions src/apps/lwaftr/lwaftr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -780,16 +780,10 @@ end

function LwAftr:enqueue_encapsulation(pkt, ipv4, port, pkt_src_link)
if pkt_src_link == PKT_FROM_INET then
if self.inet_lookup_queue:enqueue_lookup(pkt, ipv4, port) then
-- Flush the queue right away if enough packets are queued up already.
self:flush_encapsulation()
end
self.inet_lookup_queue:enqueue_lookup(pkt, ipv4, port)
else
assert(pkt_src_link == PKT_HAIRPINNED)
if self.hairpin_lookup_queue:enqueue_lookup(pkt, ipv4, port) then
-- Flush the queue right away if enough packets are queued up already.
self:flush_hairpin()
end
self.hairpin_lookup_queue:enqueue_lookup(pkt, ipv4, port)
end
end

Expand Down Expand Up @@ -977,10 +971,7 @@ function LwAftr:flush_decapsulation()
end

function LwAftr:enqueue_decapsulation(pkt, ipv4, port)
if self.inet_lookup_queue:enqueue_lookup(pkt, ipv4, port) then
-- Flush the queue right away if enough packets are queued up already.
self:flush_decapsulation()
end
self.inet_lookup_queue:enqueue_lookup(pkt, ipv4, port)
end

-- FIXME: Verify that the packet length is big enough?
Expand Down
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