libmoon icon indicating copy to clipboard operation
libmoon copied to clipboard

resetting device stats on X552

Open SharleneFletcher opened this issue 6 years ago • 2 comments

Hi,

running the following script:

local device	= require "device"
local lm	= require "libmoon"
local log	= require "log"
local memory	= require "memory"
local stats	= require "stats"
local timer	= require "timer"

local DST_MAC	= "01:23:45:67:89:AB"
local SRC_IP	= "10.0.0.10"
local DST_IP	= "10.1.0.10"
local SRC_PORT	= 1234
local DST_PORT	= 319

function configure(parser)
	parser:description("Generates UDP traffic.")
	parser:argument("txDev", "Device to transmit from."):convert(tonumber)
	parser:argument("rxDev", "Device to receive from."):convert(tonumber)
end

function master(args)
	txDev = device.config{port = args.txDev, rxQueues = 3, txQueues = 3}
	rxDev = device.config{port = args.rxDev, rxQueues = 3, txQueues = 3}
	device.waitForLinks()
	local rate, size = 100, 100
	txDev:getTxQueue(0):setRate(rate - (size + 4) * 8 / 1000)
	lm.startTask("loadSlave", txDev:getTxQueue(0), rxDev, size)
	lm.waitForTasks()
end

local function fillUdpPacket(buf, len)
	buf:getUdpPacket():fill{
		ethSrc = queue,
		ethDst = DST_MAC,
		ip4Src = SRC_IP,
		ip4Dst = DST_IP,
		udpSrc = SRC_PORT,
		udpDst = DST_PORT,
		pktLength = len
	}
end

function loadSlave(queue, rxDev, size)
	local mempool = memory.createMemPool(function(buf)
		fillUdpPacket(buf, size)
	end)
	local bufs = mempool:bufArray()
	local txCtr = stats:newDevTxCounter(queue, "plain")
	log:info('finalize immediately')
	txCtr:finalize()
	log:info('new txDev counter (1)')
	txCtr = stats:newDevTxCounter(queue, "plain")
	local time = timer:new(1)
	while lm.running() and not time:expired() do
		bufs:alloc(size)
		bufs:offloadUdpChecksums()
		queue:send(bufs)
		txCtr:update()
	end
	log:info('finalize after while')
	txCtr:finalize()
	lm.sleepMillis(5000)
	log:info('new txDev counter (2)')
	txCtr = stats:newDevTxCounter(queue, "plain")
	log:info('update & finalize')
	txCtr:update()
	txCtr:finalize()
end

produces as output:

$ ./build/MoonGen test.lua 0 1
# <snip>
[INFO]  Found 2 usable devices:
   Device 0: E0:DF:84:9B:C2:50 (Intel Corporation Ethernet Connection X552 10 GbE SFP+)
   Device 1: 9B:90:24:EC:46:42 (Intel Corporation Ethernet Connection X552 10 GbE SFP+)
# <snip>
[INFO]  finalize immediately
[Device: id=0] TX: nan (StdDev 0.00) Mpps, nan (StdDev 0) Mbit/s (nan Mbit/s with framing), total 0 packets with 0 bytes (incl. CRC)
[INFO]  new txDev counter (1)
[Device: id=0] TX: 0.12 Mpps, 99 Mbit/s (118 Mbit/s with framing)
[INFO]  finalize after while
[Device: id=0] TX: nan (StdDev 0.00) Mpps, nan (StdDev 0) Mbit/s (nan Mbit/s with framing), total 120078 packets with 12488112 bytes (incl. CRC)
[INFO]  new txDev counter (2)
[INFO]  update & finalize
[Device: id=0] TX: nan (StdDev 0.00) Mpps, nan (StdDev 0) Mbit/s (nan Mbit/s with framing), total 120078 packets with 12488112 bytes (incl. CRC)

which is, in my opinion, unexpected. I'd expect the last line to report 0 packets/bytes, since stats:newDevTxCounter

https://github.com/libmoon/libmoon/blob/db11ff1972448389562588100149730e2654876c/lua/stats.lua#L456

promises to reset stats.

Am I missing something?

Thanks!

Regards, Sharlene

SharleneFletcher avatar Jul 31 '18 15:07 SharleneFletcher

@emmericp ?

scholzd avatar Aug 30 '18 11:08 scholzd

getThroughput() no longer resets the stats, this was changed because we moved to using the DPDK stats functions on some NICs to support more NICs; so the comment is wrong.

What would be needed is an explizit reset for the device counters; current the device counters are just that: count everything the device has seen.

emmericp avatar Oct 16 '18 20:10 emmericp