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

Iterate binding table using standard 'for' loop #15

Merged

Conversation

dpino
Copy link
Member

@dpino dpino commented Sep 1, 2015

After the use of recycle the only interpreted code reported by LuaJIT's profiler is on lwaftr.lua:

  • -jp=vF (per VM states and files).
35%  Interpreted
  -- 48%  lwaftr.lua:method
  -- 24%  lwaftr.lua:binding_lookup_ipv4_from_pkt
  -- 22%  lwaftr.lua:_encapsulate_ipv4
  • -jp=Fl (per file and line)
32%  lwaftr.lua:binding_lookup_ipv4_from_pkt
  -- 36%  lwaftr.lua:63
  -- 33%  lwaftr.lua:67
  -- 15%  lwaftr.lua:68
  --  8%  lwaftr.lua:65
  --  4%  lwaftr.lua:43
31%  lwaftr.lua:method
  -- 49%  lwaftr.lua:362
  -- 22%  lwaftr.lua:366
  -- 11%  lwaftr.lua:367
  --  6%  lwaftr.lua:358
  --  4%  lwaftr.lua:379
  --  3%  lwaftr.lua:363
  --  3%  lwaftr.lua:374
19%  lwaftr.lua:_encapsulate_ipv4
  -- 28%  lwaftr.lua:262
  -- 26%  lwaftr.lua:263
  --  7%  lwaftr.lua:278
  --  6%  lwaftr.lua:242
  --  5%  lwaftr.lua:190
  --  5%  lwaftr.lua:276
  --  4%  lwaftr.lua:265
  --  3%  lwaftr.lua:290

Entry -- 4% lwaftr.lua:43 corresponds to a loop in binding_lookup_ipv4_from_pkt. Iterating the binding table with a standard for loop instead of ipairs makes LuaJIT happy and after the patch all interpreted code is gone.

99%  Compiled
  -- 12%  class.lua:free
  -- 12%  packet.lua:clone
  -- 10%  packet.lua:prepend
  --  7%  class.lua:new
  --  6%  packet.lua:shiftleft
  --  5%  datagram.lua:push
  --  5%  link.lua:receive
  --  4%  basic_apps.lua:method
  --  3%  lwaftr.lua:binding_lookup_ipv4_from_pkt

Performance improves significantly:

Processed 10.9 million packets in 5.00 seconds (7016299500 bytes; 11.23 Gbps)
Made 42,725 breaths: 255.00 packets per breath; 117.03 us per breath
Rate(Mpps): 2.179

I run the end-to-end.sh tests. All tests passed.

LuaJIT profile reported this loop as consuming a big chunk of time in
interpreted code. The ipairs iterator is replaced for a standard 'for'
loop.

After this change the profiler doesn't report interpreted code in
lwaftr.lua. Performance improves significatively.
@kbara
Copy link

kbara commented Sep 1, 2015

Merging; that's a good performance number to see, and some nice profiling work. That said, in practice we'll be using a hash table here; looping over the whole table is something that only makes sense for toy tables.

kbara added a commit that referenced this pull request Sep 1, 2015
Iterate binding table using standard 'for' loop
@kbara kbara merged commit 5498a5b into Igalia:ipv6_encap Sep 1, 2015
@dpino dpino deleted the ipv6_encap_eliminate_interpreted_code branch September 22, 2015 08:46
takikawa added a commit that referenced this pull request Mar 20, 2017
Optimizations for snabbwall & benchmarking script
wingo pushed a commit that referenced this pull request Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants