Skip to content

Commit

Permalink
Merge #1045 (ingress-drop-nfv) into lwaftr
Browse files Browse the repository at this point in the history
This also addresses the review comments from upstream #1047, noting that
the shm.exists() API changed.
  • Loading branch information
wingo committed Oct 21, 2016
2 parents 88b0dce + de93573 commit d4ba4b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/lib/timers/ingress_drop_monitor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ local shm = require("core.shm")
-- Every 100 milliseconds.
local default_interval = 1e8

local default_tips_url =
"https://github.com/snabbco/snabb/blob/master/src/doc/performance-tuning.md"

local now = core.app.now

local IngressDropMonitor = {}
Expand All @@ -19,6 +22,7 @@ function new(args)
threshold = args.threshold or 100000,
wait = args.wait or 20,
action = args.action or 'flush',
tips_url = args.tips_url or default_tips_url,
last_flush = 0,
last_value = ffi.new('uint64_t[1]'),
current_value = ffi.new('uint64_t[1]')
Expand Down Expand Up @@ -51,8 +55,6 @@ function IngressDropMonitor:sample ()
end
end

local tips_url = "https://github.com/Igalia/snabb/blob/lwaftr/src/program/lwaftr/doc/README.performance.md"

function IngressDropMonitor:jit_flush_if_needed ()
if self.current_value[0] - self.last_value[0] < self.threshold then return end
if now() - self.last_flush < self.wait then return end
Expand All @@ -63,7 +65,7 @@ function IngressDropMonitor:jit_flush_if_needed ()
if self.action == 'flush' then
msg = msg.."; flushing JIT to try to recover"
end
msg = msg..". See "..tips_url.." for performance tuning tips."
msg = msg..". See "..self.tips_url.." for performance tuning tips."
print(msg)
if self.action == 'flush' then jit.flush() end
end
Expand Down
10 changes: 10 additions & 0 deletions src/program/lwaftr/run/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ function parse_args(args)
handlers["bench-file"] = function (bench_file)
opts.bench_file = bench_file
end
handlers["ingress-drop-monitor"] = function (arg)
if arg == 'flush' or arg == 'warn' then
opts.ingress_drop_monitor = arg
elseif arg == 'off' then
opts.ingress_drop_monitor = nil
else
fatal("invalid --ingress-drop-monitor argument: " .. arg
.." (valid values: flush, warn, off)")
end
end
function handlers.h() show_usage(0) end
lib.dogetopt(args, handlers, "b:c:vD:yhir:",
{ conf = "c", v4 = 1, v6 = 1, ["v4-pci"] = 1, ["v6-pci"] = 1,
Expand Down
2 changes: 2 additions & 0 deletions src/program/snabbnfv/traffic/traffic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local ffi = require("ffi")
local C = ffi.C
local timer = require("core.timer")
local pci = require("lib.hardware.pci")
local ingress_drop_monitor = require("lib.timers.ingress_drop_monitor")
local counter = require("core.counter")

local long_opts = {
Expand Down Expand Up @@ -90,6 +91,7 @@ function traffic (pciaddr, confpath, sockpath)
timer.activate(timer.new("reconf", check_for_reconfigure, 1e9, 'repeating'))
-- Flush logs every second.
timer.activate(timer.new("flush", io.flush, 1e9, 'repeating'))
timer.activate(ingress_drop_monitor.new({action='warn'}):timer())
while true do
needs_reconfigure = false
print("Loading " .. confpath)
Expand Down

0 comments on commit d4ba4b9

Please sign in to comment.