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

NPF performance improvement #64

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6ded87d
Faster cache
tbarbette Aug 2, 2023
bc82118
More robust parsing of NIC details
tbarbette Aug 3, 2023
a1be075
Fix result-folder being ignored with npf-run
tbarbette Aug 3, 2023
e08f90a
Faster cache
tbarbette Aug 2, 2023
2736527
Argument --no-color
tbarbette Aug 5, 2023
6f62e8a
Generator modules: Finer threading
tbarbette Aug 9, 2023
a9d550e
Clearer --regress parameters
tbarbette Aug 9, 2023
72b9cb5
Alias for legend
tbarbette Nov 22, 2023
73fd38e
Merge remote-tracking branch 'origin/master'
tbarbette Nov 22, 2023
d7ab604
Merge branch 'PRfaster'
tbarbette Nov 22, 2023
634daf9
Add a fastclick echo module
tbarbette Nov 22, 2023
758cd1a
Fix last merge mistakes
tbarbette Nov 22, 2023
3b873db
Fastlick-light repo but built in debug mode
tbarbette Nov 22, 2023
e273198
Iperf2 repo, built from git
tbarbette Nov 22, 2023
431d566
Fix bad merge
tbarbette Nov 22, 2023
5248a32
Add --env option
tbarbette Nov 24, 2023
6cac75a
Fixes
tbarbette Jan 27, 2024
e54dd81
Merge remote-tracking branch 'origin/master'
tbarbette Jan 27, 2024
f476418
Jinja support
tbarbette May 8, 2024
f5317b1
Add requirement
tbarbette May 10, 2024
74450e1
Generator: Add support for GEN_FNT and change PAUSE to GEN_PAUSE
tbarbette May 10, 2024
b17d302
Merge remote-tracking branch 'origin/master'
tbarbette May 10, 2024
02d3524
Merge jinja
tbarbette May 10, 2024
0df78c0
Add GEN_PAUSE instead of PAUSE
tbarbette May 10, 2024
6932ae0
Revert moving out export_pandas as it is now used by web
tbarbette May 10, 2024
72056d7
Remove leftover message
tbarbette May 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions integration/test_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from npf.test import Test
from npf.build import Build
from npf.variable import dtype, numeric_dict
from npf.types.dataset import Run, ImmutableRun
from npf.types.dataset import Run

def get_args():
parser = argparse.ArgumentParser(description='NPF Tester')
Expand Down Expand Up @@ -91,11 +91,13 @@ def test_runequality():
rb["A"] = 1
b = Run(rb)
assert a == b
assert ImmutableRun(ra) == ImmutableRun(rb)
assert ImmutableRun(ra) == b
assert a.inside(b)
assert b.inside(a)
assert a.__hash__() == b.__hash__()
h = a.__hash__()
a.write_variables()["A"] = 3
assert a.__hash__() != h
assert a != b

def test_local_executor():
l = LocalExecutor()
Expand Down
2 changes: 2 additions & 0 deletions modules/fastclick-echo.npf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
%script deps=fastclick sudo=true
click --dpdk -l 0-7 -a ${self:0:pci} -- -e "FromDPDKDevice(0, PROMISC true) -> EtherMirror -> ToDPDKDevice(0);"
11 changes: 7 additions & 4 deletions modules/fastclick-play-single-mt.npf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ RCV_NIC=0
LIMIT=50000000
LIMIT_TIME=10
GEN_THREADS=4
GEN_RX_THREADS=4
GEN_PIPELINE=1
udpgen:GEN_PIPELINE=0
GEN_TX_PIPELINE=0
Expand All @@ -38,7 +39,7 @@ GEN_BURST=32
PROMISC=false
promisc:PROMISC=true
IGNORE?=0
PAUSE=none
GEN_PAUSE=none
GEN_DESC=0
END_AFTER=0
GEN_PROGRESSIVE=0
Expand Down Expand Up @@ -68,20 +69,21 @@ GEN_NGEN=EXPAND( $((1 if $GEN_PIPELINE else $GEN_THREADS)) )
GEN_IPV6?=0
GEN_NANO?=0
GEN_PREFIX?=
GEN_FNT?=

UNQUEUE=
udpgen:UNQUEUE=Unqueue()
rate:UNQUEUE=EXPAND( BandwidthRatedUnqueue( $(( int($GEN_RATE / $GEN_NGEN) )), EXTRA_LENGTH true, LINK_RATE true, BURST_DURATION 1, BURST $GEN_BURST) )
prate:UNQUEUE=EXPAND( RatedUnqueue($(( int($GEN_RATE / $GEN_NGEN) )), BURST $GEN_BURST, ACTIVE $(( "false" if $GEN_PROGRESSIVE else "true" )) ) )
HAVE_UNQUEUE?=0
udpgen|prate|rate|replay:HAVE_UNQUEUE=1
SAMPLE?=100
NRECORD=EXPAND( $(( int($LIMIT / $SAMPLE + 1024) * 2 )) )
BROADCAST_IGNORE= -> c :: Classifier(0/$mac,-) //Ignore broadcasts
GEN_NOREWRITE_ETHER?=0
TIMING?=false
GEN_BLOCKING=true
TIMING_FNT?=
SAMPLE?=10
DODUMP?=0
dump:DODUMP=1
DOLATVAL=0
Expand Down Expand Up @@ -163,6 +165,7 @@ Idle->[1]output;
elementclass Numberise { $magic |
input-> Strip(14)
$GEN_NUMBER
$GEN_FNT
$(( "" if $GEN_IPV6 else " -> ResetIPChecksum() " ))
-> Unstrip(14) -> output
}
Expand Down Expand Up @@ -195,7 +198,7 @@ $(( " StaticThreadSched(fdIN0 0/0, unqueue0 0/0);" if $GEN_PIPELINE else "" ))

$(( " StaticThreadSched(tdIN 0/%d);" % ($GEN_THREADS + 1) if $GEN_TX_PIPELINE else "" ))

receiveIN :: FromDPDKDevice($port, VERBOSE $rxverbose, MAC $INsrcmac, PROMISC $PROMISC, PAUSE $PAUSE, NDESC $GEN_DESC, MAXTHREADS $GEN_THREADS, NUMA false, ACTIVE $GEN_RX)
receiveIN :: FromDPDKDevice($port, VERBOSE $rxverbose, MAC $INsrcmac, PROMISC $PROMISC, PAUSE $GEN_PAUSE, NDESC $GEN_DESC, MAXTHREADS $GEN_RX_THREADS, NUMA false, ACTIVE $GEN_RX)

elementclass Receiver { $mac, $dir |
input[0]
Expand All @@ -208,7 +211,7 @@ $GEN_MAGIC
c[1] //Not for this computer or broadcasts
-> Discard;

$(( "\n".join([ "magic[%d] -> tsd%d :: $GEN_TSDIFF(gen%d/rt, OFFSET %d, N $NRECORD, SAMPLE $SAMPLE, NANO $GEN_NANO ) -> Unstrip(14) -> avg%d :: AverageCounterMP(IGNORE $ignore) -> Discard; tsd%d[1] -> Print('WARNING: Untimestamped packet on thread %d', 64) -> Discard;" % (t,t,t,${NUMBEROFFSET} + 2,t,t,t) for t in range($GEN_THREADS) ]) ))
$(( "\n".join([ "magic[%d] -> tsd%d :: $GEN_TSDIFF(gen%d/rt, OFFSET %d, N $NRECORD, SAMPLE $SAMPLE, NANO $GEN_NANO ) -> Unstrip(14) -> avg%d :: AverageCounterIMP(IGNORE $ignore) -> Discard; tsd%d[1] -> Print('WARNING: Untimestamped packet on thread %d', 64) -> Discard;" % (t,t,t,${NUMBEROFFSET} + 2,t,t,t) for t in range($GEN_THREADS) ]) ))


$(( ( "avg :: HandlerAggregate( " + ",".join(["ELEMENT avg%d" % (i) for i in range($GEN_THREADS) ]) + " );" ) if 1 else "" ))
Expand Down
1 change: 1 addition & 0 deletions modules/fastclick-replay-single-mt.npf
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ SND_NIC?=EXPAND($CLIENT_NIC)
RCV_NIC?=EXPAND($CLIENT_NIC)
DODUMP?=0
GEN_DUMP?=0
udpgen:GEN_SEQUENTIAL?=1
GEN_SEQUENTIAL?=0
gdb:GDB=gdb -ex run -ex "signal 2" -ex bt -batch -args
udpgen:GEN_TRACE_SUP+=->MarkMACHeader->EnsureDPDKBuffer->Pad
Expand Down
25 changes: 19 additions & 6 deletions npf/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def _writeversion(self, filename, all_results, allow_overwrite):
f.seek(0)
for run, results in all_results.items():
v = []
for key, val in sorted(run.variables.items()):
for key, val in sorted(run.read_variables().items()):
if type(val) is tuple:
val = val[1]
v.append((key + ":" + str(val).replace('\\:', ':').replace(':','\\:')).replace('\\,', ',').replace(',','\\,'))
Expand Down Expand Up @@ -145,14 +145,27 @@ def load_results(self, test, kind=False, cache=True):
if os.path.basename(filename) in f:
kind = f[f.rfind("-") + 1 :]
f = filename + kind
kr[kind] = self._load_results(test, f, cache)
kr[kind] = self._load_results(f, cache)
return kr

else:
filename = self.__resultFilename(test)
return self._load_results(test, filename, cache)
return self._load_results(filename, cache)

def _load_results(self, test, filename, cache):
def _load_results(self, filename, cache):
"""
The function `_load_results` reads data from a file, parses it, and returns the results in a
dictionary format.

:param filename: The `filename` parameter is a string that represents the name of the file from
which the results will be loaded
:param cache: The `cache` parameter is a boolean value that determines whether or not to use a
cache to store and retrieve previously loaded results. If `cache` is `True`, the function will
check if the `filename` is already in the cache and return the cached results if available. If
`cache`
:return: the variable "all_results", which is a dictionary containing the parsed results from
the file.
"""
if not Path(filename).exists():
return None
if cache:
Expand All @@ -171,7 +184,7 @@ def _load_results(self, test, filename, cache):
for v_data in re.split(r'(?<!\\),', variables_data):
if v_data.strip():
k, v = re.split(r'(?<!\\):', v_data)
variables[k] = variable.get_numeric(v) if test.variables.is_numeric(k) else str(v).replace('\:',':')
variables[k] = variable.get_numeric(v) if variable.is_numeric(k) else str(v).replace('\:',':')
results = {}

results_data = results_data.strip()[1:-1].split('},{')
Expand All @@ -189,7 +202,7 @@ def _load_results(self, test, filename, cache):
results[type_r] = type_results
all_results[Run(variables)] = results
except:
print("Could not parse %s. The program will stop to avoid erasing data. Please correct or delete the file.\nLine %d : %s" % (filename,iline, line))
print("Could not parse %s. The program will stop to avoid erasing data. Please correct or delete the file.\nLine %d : %s\n" % (filename,iline, line))
raise
f.close()
self.cache[filename] = all_results
Expand Down
6 changes: 5 additions & 1 deletion npf/executor/executor.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import re

from npf import npf
from colorama import Fore, Back, Style

foreColors = [Fore.BLACK, Fore.RED, Fore.GREEN, Fore.YELLOW, Fore.BLUE, Fore.MAGENTA, Fore.CYAN, Fore.WHITE]
Expand All @@ -9,7 +10,10 @@ class Executor:
index = 0

def __init__(self):
self.color = foreColors[Executor.index % len(foreColors)]
if npf.options.color:
self.color = foreColors[Executor.index % len(foreColors)]
else:
self.color = ""
Executor.index = Executor.index + 1
self.path = None

Expand Down
7 changes: 4 additions & 3 deletions npf/executor/sshexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ def exec(self, cmd, bin_paths : List[str] = None, queue: Queue = None, options =
print("Executing on %s%s (PATH+=%s) :\n%s" % (self.addr,(' with sudo' if sudo and self.user != "root" else ''),':'.join(path_list) + (("NS:" + virt) if virt else ""), cmd.strip()))

# The pre-command goes into the test folder
pre = 'cd '+ self.path + ';'
pre = 'cd '+ self.path + ';\n'

if self.path:
env['NPF_ROOT'] = self.path
env['NPF_CWD_PATH'] = os.path.relpath(npf.cwd_path(options),self.path)
env['NPF_EXPERIMENT_PATH'] = '../' + os.path.relpath(npf.experiment_path(), self.path)
env['NPF_ROOT_PATH'] = '../' + os.path.relpath(npf.npf_root_path(), self.path)

env_str=""
for k,v in env.items():
if v is not None:
pre += 'export ' + k + '='+v+'\n'
env_str += 'export ' + k + '='+v+'\n'
if path_list:
path_cmd = 'export PATH="%s:$PATH"\n' % (':'.join(path_list))
else:
Expand All @@ -86,6 +86,7 @@ def exec(self, cmd, bin_paths : List[str] = None, queue: Queue = None, options =
if stdin is not None:
unbuffer = unbuffer + " -p"

cmd = env_str + cmd
if sudo and self.user != "root":
cmd = "sudo -E mkdir -p "+testdir+" && sudo -E " + virt +" "+unbuffer+" bash -c '"+path_cmd + cmd.replace("'", "'\"'\"'") + "'";
else:
Expand Down
Loading
Loading