Skip to content

Commit

Permalink
Add -j option to "snabb lwaftr run" and "bench"
Browse files Browse the repository at this point in the history
The format is as for "snabb snsh", but it applies to the data plane
processes, not the main process.  For -jp and -jtprof, reports will go
out every 10 seconds.
  • Loading branch information
wingo committed Sep 6, 2017
1 parent 4595ead commit a77330d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/program/lwaftr/bench/bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ function parse_args(args)
function handlers.n(arg) opts.name = assert(arg) end
function handlers.b(arg) opts.bench_file = arg end
function handlers.y() opts.hydra = true end
function handlers.j(arg) scheduling.j = arg end
function handlers.h() show_usage(0) end
args = lib.dogetopt(args, handlers, "n:hyb:D:", {
args = lib.dogetopt(args, handlers, "j:n:hyb:D:", {
help="h", hydra="y", ["bench-file"]="b", duration="D", name="n", cpu=1})
if #args ~= 3 then show_usage(1) end
return opts, scheduling, unpack(args)
Expand Down
3 changes: 2 additions & 1 deletion src/program/lwaftr/run/run.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ function parse_args(args)
io.stderr:write("Warning: the --reconfigurable flag has been deprecated")
io.stderr:write(" as the lwaftr is now always reconfigurable.\n")
end
function handlers.j(arg) scheduling.j = arg end
function handlers.h() show_usage(0) end
lib.dogetopt(args, handlers, "b:c:vD:yhir:n:",
lib.dogetopt(args, handlers, "b:c:vD:yhir:n:j:",
{ conf = "c", v4 = 1, v6 = 1, ["v4-pci"] = 1, ["v6-pci"] = 1,
verbose = "v", duration = "D", help = "h", virtio = "i", cpu = 1,
["ring-buffer-size"] = "r", ["real-time"] = 0, ["bench-file"] = "b",
Expand Down
27 changes: 26 additions & 1 deletion src/program/lwaftr/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,8 @@ local apply_scheduling_opts = {
cpu = { required=false },
pci_addrs = { default={} },
real_time = { default=false },
ingress_drop_monitor = { default='flush' }
ingress_drop_monitor = { default='flush' },
j = {}
}
function apply_scheduling(opts)
local lib = require("core.lib")
Expand All @@ -579,6 +580,30 @@ function apply_scheduling(opts)
fatal('Failed to enable real-time scheduling. Try running as root.')
end
end
if opts.j then
local arg = opts.j
if arg:match("^v") then
local file = arg:match("^v=(.*)")
if file == '' then file = nil end
require("jit.v").start(file)
elseif arg:match("^p") then
local opts, file = arg:match("^p=([^,]*),?(.*)")
if file == '' then file = nil end
local prof = require('jit.p')
prof.start(opts, file)
local function report() prof.stop(); prof.start(opts, file) end
timer.activate(timer.new('p', report, 10e9, 'repeating'))
elseif arg:match("^dump") then
local opts, file = arg:match("^dump=([^,]*),?(.*)")
if file == '' then file = nil end
require("jit.dump").on(opts, file)
elseif arg:match("^tprof") then
local prof = require('lib.traceprof.traceprof')
prof.start()
local function report() prof.stop(); prof.start() end
timer.activate(timer.new('tprof', report, 10e9, 'repeating'))
end
end
end

function run_worker(scheduling)
Expand Down

0 comments on commit a77330d

Please sign in to comment.