Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
78d4c701
Commit
78d4c701
authored
Jul 02, 2022
by
Jonas Kaufmann
Committed by
Antoine Kaufmann
Jul 12, 2022
Browse files
fix all pylint issues except missing doc strings in experiments/
parent
7549fa9e
Changes
63
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
323 additions
and
306 deletions
+323
-306
experiments/pyexps/pci_validation.py
experiments/pyexps/pci_validation.py
+4
-3
experiments/pyexps/qemu_tcp_multi.py
experiments/pyexps/qemu_tcp_multi.py
+4
-4
experiments/pyexps/qemu_tcp_single.py
experiments/pyexps/qemu_tcp_single.py
+6
-6
experiments/pyexps/qemu_udp_multi.py
experiments/pyexps/qemu_udp_multi.py
+4
-4
experiments/pyexps/qemu_udp_single.py
experiments/pyexps/qemu_udp_single.py
+6
-6
experiments/pyexps/rpc_singlecore.py
experiments/pyexps/rpc_singlecore.py
+6
-6
experiments/pyexps/scalability.py
experiments/pyexps/scalability.py
+12
-12
experiments/pyexps/scale_host.py
experiments/pyexps/scale_host.py
+15
-15
experiments/pyexps/scale_load.py
experiments/pyexps/scale_load.py
+25
-25
experiments/run.py
experiments/run.py
+23
-19
experiments/simbricks/exectools.py
experiments/simbricks/exectools.py
+26
-20
experiments/simbricks/experiment/experiment_environment.py
experiments/simbricks/experiment/experiment_environment.py
+24
-19
experiments/simbricks/experiments.py
experiments/simbricks/experiments.py
+25
-25
experiments/simbricks/nodeconfig.py
experiments/simbricks/nodeconfig.py
+92
-74
experiments/simbricks/proxy.py
experiments/simbricks/proxy.py
+2
-20
experiments/simbricks/runtime/common.py
experiments/simbricks/runtime/common.py
+8
-8
experiments/simbricks/runtime/distributed.py
experiments/simbricks/runtime/distributed.py
+10
-9
experiments/simbricks/runtime/local.py
experiments/simbricks/runtime/local.py
+15
-15
experiments/simbricks/runtime/slurm.py
experiments/simbricks/runtime/slurm.py
+10
-10
experiments/simbricks/simulator_utils.py
experiments/simbricks/simulator_utils.py
+6
-6
No files found.
experiments/pyexps/pci_validation.py
View file @
78d4c701
...
...
@@ -67,9 +67,10 @@ for internal in [True, False]:
for
h
in
[
client
,
server
]:
h
.
cpu_type
=
h
.
cpu_type_cp
=
'TimingSimpleCPU'
h
.
variant
=
'opt'
# need opt gem5 variant with debug support
h
.
extra_main_args
.
append
(
'--debug-flags=SimBricksEthernet,SimBricksPci,EthernetAll,EthernetDesc'
)
h
.
extra_main_args
.
append
((
'--debug-flags='
'SimBricksEthernet,SimBricksPci,EthernetAll,EthernetDesc'
))
if
internal
:
h
.
add_netdirect
(
net
)
else
:
...
...
experiments/pyexps/qemu_tcp_multi.py
View file @
78d4c701
...
...
@@ -45,15 +45,15 @@ experiments = []
for
n
in
kinds_of_net
:
if
n
==
'switch'
:
n
et
_c
lass
=
sim
.
SwitchNet
N
et
C
lass
=
sim
.
SwitchNet
if
n
==
'dumbbell'
:
n
et
_c
lass
=
sim
.
NS3DumbbellNet
N
et
C
lass
=
sim
.
NS3DumbbellNet
if
n
==
'bridge'
:
n
et
_c
lass
=
sim
.
NS3BridgeNet
N
et
C
lass
=
sim
.
NS3BridgeNet
# set nic sim
for
c
in
kinds_of_nic
:
net
=
n
et
_c
lass
()
net
=
N
et
C
lass
()
e
=
exp
.
Experiment
(
'qemu-'
+
c
+
'-'
+
n
+
'-'
+
'TCPm'
)
e
.
add_network
(
net
)
...
...
experiments/pyexps/qemu_tcp_single.py
View file @
78d4c701
...
...
@@ -43,19 +43,19 @@ experiments = []
# set network sim
for
n
in
kinds_of_net
:
if
n
==
'wire'
:
n
et
_c
lass
=
sim
.
WireNet
N
et
C
lass
=
sim
.
WireNet
if
n
==
'switch'
:
n
et
_c
lass
=
sim
.
SwitchNet
N
et
C
lass
=
sim
.
SwitchNet
if
n
==
'dumbbell'
:
n
et
_c
lass
=
sim
.
NS3DumbbellNet
N
et
C
lass
=
sim
.
NS3DumbbellNet
if
n
==
'bridge'
:
n
et
_c
lass
=
sim
.
NS3BridgeNet
N
et
C
lass
=
sim
.
NS3BridgeNet
if
n
==
'tofino'
:
n
et
_c
lass
=
sim
.
TofinoNet
N
et
C
lass
=
sim
.
TofinoNet
# set nic sim
for
c
in
kinds_of_nic
:
net
=
n
et
_c
lass
()
net
=
N
et
C
lass
()
e
=
exp
.
Experiment
(
'qemu-'
+
c
+
'-'
+
n
+
'-'
+
'TCPs'
)
e
.
add_network
(
net
)
...
...
experiments/pyexps/qemu_udp_multi.py
View file @
78d4c701
...
...
@@ -47,15 +47,15 @@ experiments = []
for
n
in
kinds_of_net
:
if
n
==
'switch'
:
n
et
_c
lass
=
sim
.
SwitchNet
N
et
C
lass
=
sim
.
SwitchNet
if
n
==
'dumbbell'
:
n
et
_c
lass
=
sim
.
NS3DumbbellNet
N
et
C
lass
=
sim
.
NS3DumbbellNet
if
n
==
'bridge'
:
n
et
_c
lass
=
sim
.
NS3BridgeNet
N
et
C
lass
=
sim
.
NS3BridgeNet
# set nic sim
for
c
in
kinds_of_nic
:
net
=
n
et
_c
lass
()
net
=
N
et
C
lass
()
e
=
exp
.
Experiment
(
'qemu-'
+
c
+
'-'
+
n
+
'-'
+
'UDPm'
)
e
.
add_network
(
net
)
...
...
experiments/pyexps/qemu_udp_single.py
View file @
78d4c701
...
...
@@ -45,19 +45,19 @@ experiments = []
# set network sim
for
n
in
kinds_of_net
:
if
n
==
'wire'
:
n
et
_c
lass
=
sim
.
WireNet
N
et
C
lass
=
sim
.
WireNet
if
n
==
'switch'
:
n
et
_c
lass
=
sim
.
SwitchNet
N
et
C
lass
=
sim
.
SwitchNet
if
n
==
'dumbbell'
:
n
et
_c
lass
=
sim
.
NS3DumbbellNet
N
et
C
lass
=
sim
.
NS3DumbbellNet
if
n
==
'bridge'
:
n
et
_c
lass
=
sim
.
NS3BridgeNet
N
et
C
lass
=
sim
.
NS3BridgeNet
if
n
==
'tofino'
:
n
et
_c
lass
=
sim
.
TofinoNet
N
et
C
lass
=
sim
.
TofinoNet
# set nic sim
for
c
in
kinds_of_nic
:
net
=
n
et
_c
lass
()
net
=
N
et
C
lass
()
e
=
exp
.
Experiment
(
'qemu-'
+
c
+
'-'
+
n
+
'-'
+
'UDPs'
)
e
.
add_network
(
net
)
...
...
experiments/pyexps/rpc_singlecore.py
View file @
78d4c701
...
...
@@ -34,20 +34,20 @@ experiments = []
for
msg_size
in
msg_sizes
:
for
stack
in
stacks
:
e
=
exp
.
Experiment
(
'qemu-ib-switch-rpc-
%s
-1t-1fpc-
%db-0mpc'
%
(
stack
,
msg_size
)
f
'qemu-ib-switch-rpc-
{
stack
}
-1t-1fpc-
{
msg_size
}
b-0mpc'
)
net
=
sim
.
SwitchNet
()
e
.
add_network
(
net
)
if
stack
==
'tas'
:
n
=
node
.
TASNode
N
=
node
.
TASNode
elif
stack
==
'mtcp'
:
n
=
node
.
MtcpNode
N
=
node
.
MtcpNode
else
:
n
=
node
.
I40eLinuxNode
N
=
node
.
I40eLinuxNode
servers
=
create_basic_hosts
(
e
,
1
,
'server'
,
net
,
sim
.
I40eNIC
,
sim
.
QemuHost
,
n
,
node
.
RPCServer
e
,
1
,
'server'
,
net
,
sim
.
I40eNIC
,
sim
.
QemuHost
,
N
,
node
.
RPCServer
)
clients
=
create_basic_hosts
(
...
...
@@ -57,7 +57,7 @@ for msg_size in msg_sizes:
net
,
sim
.
I40eNIC
,
sim
.
QemuHost
,
n
,
N
,
node
.
RPCClient
,
ip_start
=
2
)
...
...
experiments/pyexps/scalability.py
View file @
78d4c701
...
...
@@ -37,14 +37,14 @@ for host_config in host_configs:
e
=
exp
.
Experiment
(
'scalability-'
+
host_config
+
'-'
+
str
(
nc
))
if
host_config
==
'bm'
:
h
ost
_c
lass
=
sim
.
QemuHost
n
ic
_c
lass
=
sim
.
CorundumBMNIC
nc_c
lass
=
node
.
CorundumLinuxNode
H
ost
C
lass
=
sim
.
QemuHost
N
ic
C
lass
=
sim
.
CorundumBMNIC
NcC
lass
=
node
.
CorundumLinuxNode
net
=
sim
.
SwitchNet
()
elif
host_config
==
'cycle'
:
h
ost
_c
lass
=
sim
.
Gem5Host
n
ic
_c
lass
=
sim
.
CorundumVerilatorNIC
nc_c
lass
=
node
.
CorundumLinuxNode
H
ost
C
lass
=
sim
.
Gem5Host
N
ic
C
lass
=
sim
.
CorundumVerilatorNIC
NcC
lass
=
node
.
CorundumLinuxNode
net
=
sim
.
NS3BridgeNet
()
else
:
raise
NameError
(
host_config
)
...
...
@@ -56,9 +56,9 @@ for host_config in host_configs:
1
,
'server'
,
net
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPServer
)
...
...
@@ -67,9 +67,9 @@ for host_config in host_configs:
nc
,
'client'
,
net
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPClient
)
...
...
experiments/pyexps/
S
cale
H
ost.py
→
experiments/pyexps/
s
cale
_h
ost.py
View file @
78d4c701
...
...
@@ -72,7 +72,7 @@ for n_client in num_client_types:
# host
if
host_type
==
'qemu'
:
h
ost
_c
lass
=
sim
.
QemuHost
H
ost
C
lass
=
sim
.
QemuHost
elif
host_type
==
'qt'
:
def
qemu_timing
():
...
...
@@ -80,23 +80,23 @@ for n_client in num_client_types:
h
.
sync
=
True
return
h
h
ost
_c
lass
=
qemu_timing
H
ost
C
lass
=
qemu_timing
elif
host_type
==
'gt'
:
h
ost
_c
lass
=
sim
.
Gem5Host
H
ost
C
lass
=
sim
.
Gem5Host
e
.
checkpoint
=
True
else
:
raise
NameError
(
host_type
)
# nic
if
nic_type
==
'ib'
:
n
ic
_c
lass
=
sim
.
I40eNIC
nc_c
lass
=
node
.
I40eLinuxNode
N
ic
C
lass
=
sim
.
I40eNIC
NcC
lass
=
node
.
I40eLinuxNode
elif
nic_type
==
'cb'
:
n
ic
_c
lass
=
sim
.
CorundumBMNIC
nc_c
lass
=
node
.
CorundumLinuxNode
N
ic
C
lass
=
sim
.
CorundumBMNIC
NcC
lass
=
node
.
CorundumLinuxNode
elif
nic_type
==
'cv'
:
n
ic
_c
lass
=
sim
.
CorundumVerilatorNIC
nc_c
lass
=
node
.
CorundumLinuxNode
N
ic
C
lass
=
sim
.
CorundumVerilatorNIC
NcC
lass
=
node
.
CorundumLinuxNode
else
:
raise
NameError
(
nic_type
)
...
...
@@ -106,9 +106,9 @@ for n_client in num_client_types:
1
,
'server'
,
net
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPServer
)
...
...
@@ -117,9 +117,9 @@ for n_client in num_client_types:
n_client
,
'client'
,
net
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPClient
,
ip_start
=
2
)
...
...
experiments/pyexps/
S
cale
L
oad.py
→
experiments/pyexps/
s
cale
_l
oad.py
View file @
78d4c701
...
...
@@ -59,18 +59,18 @@ for rate in rate_types:
)
# network
if
net_type
==
'sw'
:
n
et
=
sim
.
SwitchNet
()
N
et
Class
=
sim
.
SwitchNet
()
elif
net_type
==
'br'
:
n
et
=
sim
.
NS3BridgeNet
()
N
et
Class
=
sim
.
NS3BridgeNet
()
elif
net_type
==
'wire'
:
n
et
=
sim
.
WireNet
()
N
et
Class
=
sim
.
WireNet
()
else
:
raise
NameError
(
net_type
)
e
.
add_network
(
n
et
)
e
.
add_network
(
N
et
Class
)
# host
if
host_type
==
'qemu'
:
h
ost
_c
lass
=
sim
.
QemuHost
H
ost
C
lass
=
sim
.
QemuHost
elif
host_type
==
'qt'
:
def
qemu_timing
():
...
...
@@ -78,23 +78,23 @@ for rate in rate_types:
h
.
sync
=
True
return
h
h
ost
_c
lass
=
qemu_timing
H
ost
C
lass
=
qemu_timing
elif
host_type
==
'gt'
:
h
ost
_c
lass
=
sim
.
Gem5Host
H
ost
C
lass
=
sim
.
Gem5Host
e
.
checkpoint
=
True
else
:
raise
NameError
(
host_type
)
# nic
if
nic_type
==
'ib'
:
n
ic
_c
lass
=
sim
.
I40eNIC
nc_c
lass
=
node
.
I40eLinuxNode
N
ic
C
lass
=
sim
.
I40eNIC
NcC
lass
=
node
.
I40eLinuxNode
elif
nic_type
==
'cb'
:
n
ic
_c
lass
=
sim
.
CorundumBMNIC
nc_c
lass
=
node
.
CorundumLinuxNode
N
ic
C
lass
=
sim
.
CorundumBMNIC
NcC
lass
=
node
.
CorundumLinuxNode
elif
nic_type
==
'cv'
:
n
ic
_c
lass
=
sim
.
CorundumVerilatorNIC
nc_c
lass
=
node
.
CorundumLinuxNode
N
ic
C
lass
=
sim
.
CorundumVerilatorNIC
NcC
lass
=
node
.
CorundumLinuxNode
else
:
raise
NameError
(
nic_type
)
...
...
@@ -103,10 +103,10 @@ for rate in rate_types:
e
,
1
,
'server'
,
n
et
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
et
Class
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPServer
)
...
...
@@ -115,10 +115,10 @@ for rate in rate_types:
e
,
1
,
'client'
,
n
et
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
et
Class
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPClientSleep
,
ip_start
=
2
)
...
...
@@ -127,10 +127,10 @@ for rate in rate_types:
e
,
1
,
'client'
,
n
et
,
n
ic
_c
lass
,
h
ost
_c
lass
,
nc_c
lass
,
N
et
Class
,
N
ic
C
lass
,
H
ost
C
lass
,
NcC
lass
,
node
.
IperfUDPClient
,
ip_start
=
2
)
...
...
experiments/run.py
View file @
78d4c701
...
...
@@ -30,15 +30,16 @@ import pickle
import
sys
import
typing
as
tp
import
simbricks.exectools
as
exectools
from
simbricks.runtime.common
import
*
from
simbricks.runtime.distributed
import
*
from
simbricks.runtime.local
import
*
from
simbricks.runtime.slurm
import
*
from
simbricks.runtime.common
import
Run
from
simbricks.runtime.distributed
import
DistributedSimpleRuntime
,
auto_dist
from
simbricks.runtime.local
import
LocalParallelRuntime
,
LocalSimpleRuntime
from
simbricks.runtime.slurm
import
SlurmRuntime
import
simbricks.experiments
as
exp
from
simbricks
import
exectools
# pylint: disable=redefined-outer-name
def
mkdir_if_not_exists
(
path
):
if
not
os
.
path
.
exists
(
path
):
os
.
mkdir
(
path
)
...
...
@@ -212,9 +213,10 @@ g_dist.add_argument(
args
=
parser
.
parse_args
()
# pylint: disable=redefined-outer-name
def
load_executors
(
path
):
"""Load hosts list from json file and return list of executors."""
with
open
(
path
,
'r'
)
as
f
:
with
open
(
path
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
hosts
=
json
.
load
(
f
)
exs
=
[]
...
...
@@ -252,7 +254,10 @@ def warn_multi_exec():
if
args
.
runtime
==
'parallel'
:
warn_multi_exec
()
rt
=
LocalParallelRuntime
(
cores
=
args
.
cores
,
mem
=
args
.
mem
,
verbose
=
args
.
verbose
,
exec
=
executors
[
0
]
cores
=
args
.
cores
,
mem
=
args
.
mem
,
verbose
=
args
.
verbose
,
executor
=
executors
[
0
]
)
elif
args
.
runtime
==
'slurm'
:
rt
=
SlurmRuntime
(
args
.
slurmdir
,
args
,
verbose
=
args
.
verbose
)
...
...
@@ -260,9 +265,10 @@ elif args.runtime == 'dist':
rt
=
DistributedSimpleRuntime
(
executors
,
verbose
=
args
.
verbose
)
else
:
warn_multi_exec
()
rt
=
LocalSimpleRuntime
(
verbose
=
args
.
verbose
,
exec
=
executors
[
0
])
rt
=
LocalSimpleRuntime
(
verbose
=
args
.
verbose
,
exec
utor
=
executors
[
0
])
# pylint: disable=redefined-outer-name
def
add_exp
(
e
:
exp
.
Experiment
,
run
:
int
,
...
...
@@ -271,15 +277,15 @@ def add_exp(
restore_cp
:
bool
,
no_simbricks
:
bool
):
outpath
=
'%s/%s-%d.json'
%
(
args
.
outdir
,
e
.
name
,
run
)
outpath
=
f
'
{
args
.
outdir
}
/
{
e
.
name
}
-
{
run
}
.json'
if
os
.
path
.
exists
(
outpath
)
and
not
args
.
force
:
print
(
'skip
%s run %d'
%
(
e
.
name
,
run
)
)
print
(
f
'skip
{
e
.
name
}
run
{
run
}
'
)
return
None
workdir
=
'%s/%s/%d'
%
(
args
.
workdir
,
e
.
name
,
run
)
cpdir
=
'%s/%s/%d'
%
(
args
.
cpdir
,
e
.
name
,
0
)
workdir
=
f
'
{
args
.
workdir
}
/
{
e
.
name
}
/
{
run
}
'
cpdir
=
f
'
{
args
.
cpdir
}
/
{
e
.
name
}
/0'
if
args
.
shmdir
is
not
None
:
shmdir
=
'%s/%s/%d'
%
(
args
.
shmdir
,
e
.
name
,
run
)
shmdir
=
f
'
{
args
.
shmdir
}
/
{
e
.
name
}
/
{
run
}
'
env
=
exp
.
ExpEnv
(
args
.
repo
,
workdir
,
cpdir
)
env
.
create_cp
=
create_cp
...
...
@@ -320,17 +326,15 @@ if not args.pickled:
if
(
args
.
filter
)
and
(
len
(
args
.
filter
)
>
0
):
match
=
False
for
f
in
args
.
filter
:
if
fnmatch
.
fnmatch
(
e
.
name
,
f
)
:
match
=
True
match
=
fnmatch
.
fnmatch
(
e
.
name
,
f
)
if
match
:
break
if
not
match
:
continue
# if this is an experiment with a checkpoint we might have to create it
if
e
.
no_simbricks
:
no_simbricks
=
True
else
:
no_simbricks
=
False
no_simbricks
=
e
.
no_simbricks
if
e
.
checkpoint
:
prereq
=
add_exp
(
e
,
0
,
None
,
True
,
False
,
no_simbricks
)
else
:
...
...
experiments/simbricks/exectools.py
View file @
78d4c701
...
...
@@ -32,7 +32,10 @@ from asyncio.subprocess import Process
class
HostConfig
(
object
):
def
__init__
(
self
,
name
,
ip
,
mac
,
sudopwd
,
other
=
{}):
def
__init__
(
self
,
name
,
ip
,
mac
,
sudopwd
,
other
=
None
):
if
other
is
None
:
other
=
{}
self
.
name
=
name
self
.
ip
=
ip
self
.
used_ip
=
ip
...
...
@@ -170,7 +173,7 @@ class Component(object):
class
SimpleComponent
(
Component
):
def
__init__
(
self
,
label
,
cmd_parts
,
verbose
=
True
,
canfail
=
False
,
*
args
,
**
kwargs
self
,
label
,
cmd_parts
,
*
args
,
verbose
=
True
,
canfail
=
False
,
**
kwargs
):
self
.
label
=
label
self
.
verbose
=
verbose
...
...
@@ -180,12 +183,12 @@ class SimpleComponent(Component):
async
def
process_out
(
self
,
lines
,
eof
):
if
self
.
verbose
:
for
l
in
lines
:
for
_
in
lines
:
print
(
self
.
label
,
'OUT:'
,
lines
,
flush
=
True
)
async
def
process_err
(
self
,
lines
,
eof
):
if
self
.
verbose
:
for
l
in
lines
:
for
_
in
lines
:
print
(
self
.
label
,
'ERR:'
,
lines
,
flush
=
True
)
async
def
terminated
(
self
,
rc
):
...
...
@@ -203,11 +206,14 @@ class SimpleRemoteComponent(SimpleComponent):
host_name
,
label
,
cmd_parts
,
cwd
=
None
,
ssh_extra_args
=
[],
*
args
,
cwd
=
None
,
ssh_extra_args
=
None
,
**
kwargs
):
if
ssh_extra_args
is
None
:
ssh_extra_args
=
[]
self
.
host_name
=
host_name
self
.
extra_flags
=
ssh_extra_args
# add a wrapper to print the PID
...
...
@@ -300,14 +306,14 @@ class Executor(object):
raise
NotImplementedError
(
'Please Implement this method'
)
# runs the list of commands as strings sequentially
async
def
run_cmdlist
(
self
,
label
,
cmds
,
verbose
=
True
,
host
=
None
):
async
def
run_cmdlist
(
self
,
label
,
cmds
,
verbose
=
True
):
i
=
0
for
cmd
in
cmds
:
cmd
C
=
self
.
create_component
(
cmd
_c
=
self
.
create_component
(
label
+
'.'
+
str
(
i
),
shlex
.
split
(
cmd
),
verbose
=
verbose
)
await
cmd
C
.
start
()
await
cmd
C
.
wait
()
await
cmd
_c
.
start
()
await
cmd
_c
.
wait
()
async
def
await_files
(
self
,
paths
,
*
args
,
**
kwargs
):
xs
=
[]
...
...
@@ -323,7 +329,7 @@ class LocalExecutor(Executor):
async
def
await_file
(
self
,
path
,
delay
=
0.05
,
verbose
=
False
,
timeout
=
30
):
if
verbose
:
print
(
'await_file(
%s)'
%
path
)
print
(
f
'await_file(
{
path
}
)'
)
t
=
0
while
not
os
.
path
.
exists
(
path
):
if
t
>=
timeout
:
...
...
@@ -365,18 +371,18 @@ class RemoteExecutor(Executor):
async
def
await_file
(
self
,
path
,
delay
=
0.05
,
verbose
=
False
,
timeout
=
30
):
if
verbose
:
print
(
'%s
.await_file(
%s
) started'
%
(
self
.
host_name
,
path
)
)
print
(
f
'
{
self
.
host_name
}
.await_file(
{
path
}
) started'
)
to_its
=
timeout
/
delay
loop_cmd
=
(
'i=0 ; while [ ! -e
%s
] ; do '
'if [ $i -ge
%u
] ; then exit 1 ; fi ; '
'sleep
%f
; '
f
'i=0 ; while [ ! -e
{
path
}
] ; do '
f
'if [ $i -ge
{
to_its
:
u
}
] ; then exit 1 ; fi ; '
f
'sleep
{
delay
}
; '
'i=$(($i+1)) ; done; exit 0'
)
%
(
path
,
to_its
,
delay
)
parts
=
[
'/bin/sh'
,
'-c'
,
loop_cmd
]
sc
=
self
.
create_component
(
"%s.await_file('%s')"
%
(
self
.
host_name
,
path
)
,
f
"
{
self
.
host_name
}
.await_file('
{
path
}
')"
,
parts
,
canfail
=
False
,
verbose
=
verbose
...
...
@@ -393,9 +399,9 @@ class RemoteExecutor(Executor):
'UserKnownHostsFile=/dev/null'
,
'-o'
,
'StrictHostKeyChecking=no'
]
+
self
.
scp_extra_args
+
[
path
,
'%s:%s'
%
(
self
.
host_name
,
path
)
]
]
+
self
.
scp_extra_args
+
[
path
,
f
'
{
self
.
host_name
}
:
{
path
}
'
]
sc
=
SimpleComponent
(
"%s.send_file('%s')"
%
(
self
.
host_name
,
path
)
,
f
'
{
self
.
host_name
}
.send_file("
{
path
}
")'
,
parts
,
canfail
=
False
,
verbose
=
verbose
...
...
@@ -405,7 +411,7 @@ class RemoteExecutor(Executor):
async
def
mkdir
(
self
,
path
,
verbose
=
False
):
sc
=
self
.
create_component
(
"%s.mkdir('%s')"
%
(
self
.
host_name
,
path
)
,
[
'mkdir'
,
'-p'
,
path
],
f
"
{
self
.
host_name
}
.mkdir('
{
path
}
')"
,
[
'mkdir'
,
'-p'
,
path
],
canfail
=
False
,
verbose
=
verbose
)
...
...
@@ -414,7 +420,7 @@ class RemoteExecutor(Executor):
async
def
rmtree
(
self
,
path
,
verbose
=
False
):
sc
=
self
.
create_component
(
"%s.rmtree('%s')"
%
(
self
.
host_name
,
path
)
,
[
'rm'
,
'-rf'
,
path
],
f
'
{
self
.
host_name
}
.rmtree("
{
path
}
")'
,
[
'rm'
,
'-rf'
,
path
],
canfail
=
False
,
verbose
=
verbose
)
...
...
experiments/simbricks/experiment/experiment_environment.py
View file @
78d4c701
...
...
@@ -33,50 +33,55 @@ class ExpEnv(object):
self
.
workdir
=
os
.
path
.
abspath
(
workdir
)
self
.
cpdir
=
os
.
path
.
abspath
(
cpdir
)
self
.
shm_base
=
self
.
workdir
self
.
qemu_img_path
=
self
.
repodir
+
'/sims/external/qemu/build/qemu-img'
self
.
qemu_path
=
self
.
repodir
+
'/sims/external/qemu/build/x86_64-softmmu/qemu-system-x86_64'
self
.
qemu_kernel_path
=
self
.
repodir
+
'/images/bzImage'
self
.
gem5_py_path
=
self
.
repodir
+
'/sims/external/gem5/configs/simbricks/simbricks.py'
self
.
gem5_kernel_path
=
self
.
repodir
+
'/images/vmlinux'
self
.
qemu_img_path
=
f
'
{
self
.
repodir
}
/sims/external/qemu/build/qemu-img'
self
.
qemu_path
=
(
f
'
{
self
.
repodir
}
/sims/external/qemu/build/'
'x86_64-softmmu/qemu-system-x86_64'
)
self
.
qemu_kernel_path
=
f
'
{
self
.
repodir
}
/images/bzImage'
self
.
gem5_py_path
=
(
f
'
{
self
.
repodir
}
/sims/external/gem5/configs/simbricks/simbricks.py'
)
self
.
gem5_kernel_path
=
f
'
{
self
.
repodir
}
/images/vmlinux'
def
gem5_path
(
self
,
variant
):
return
self
.
repodir
+
'
/sims/external/gem5/build/X86/gem5.
'
+
variant
return
f
'
{
self
.
repodir
}
/sims/external/gem5/build/X86/gem5.
{
variant
}
'
def
hdcopy_path
(
self
,
sim
):
return
'%s/hdcopy.%s'
%
(
self
.
workdir
,
sim
.
name
)
return
f
'
{
self
.
workdir
}
/hdcopy.
{
sim
.
name
}
'
def
hd_path
(
self
,
hd_name
):
return
'%s/images/output-%s/%s'
%
(
self
.
repodir
,
hd_name
,
hd_name
)
return
f
'
{
self
.
repodir
}
/images/output-
{
hd_name
}
/
{
hd_name
}
'
def
hd_raw_path
(
self
,
hd_name
):
return
'%s/images/output-%s/%s.raw'
%
(
self
.
repodir
,
hd_name
,
hd_name
)
return
f
'
{
self
.
repodir
}
/images/output-
{
hd_name
}
/
{
hd_name
}
.raw'
def
cfgtar_path
(
self
,
sim
):
return
'%s/cfg.%s.tar'
%
(
self
.
workdir
,
sim
.
name
)
return
f
'
{
self
.
workdir
}
/cfg.
{
sim
.
name
}
.tar'
def
dev_pci_path
(
self
,
sim
):
return
'%s/dev.pci.%s'
%
(
self
.
workdir
,
sim
.
name
)
return
f
'
{
self
.
workdir
}
/dev.pci.
{
sim
.
name
}
'
def
nic_eth_path
(
self
,
sim
):
return
'%s/nic.eth.%s'
%
(
self
.
workdir
,
sim
.
name
)
return
f
'
{
self
.
workdir
}
/nic.eth.
{
sim
.
name
}
'
def
dev_shm_path
(
self
,
sim
):
return
'%s/dev.shm.%s'
%
(
self
.
shm_base
,
sim
.
name
)
return
f
'
{
self
.
shm_base
}
/dev.shm.
{
sim
.
name
}
'
def
n2n_eth_path
(
self
,
sim_l
,
sim_c
):
return
'%s/n2n.eth.%s.%s'
%
(
self
.
workdir
,
sim_l
.
name
,
sim_c
.
name
)
return
f
'
{
self
.
workdir
}
/n2n.eth.
{
sim_l
.
name
}
.
{
sim_c
.
name
}
'
def
net2host_eth_path
(
self
,
sim_n
,
sim_h
):
return
'%s/n2h.eth.%s.%s'
%
(
self
.
workdir
,
sim_n
.
name
,
sim_h
.
name
)
return
f
'
{
self
.
workdir
}
/n2h.eth.
{
sim_n
.
name
}
.
{
sim_h
.
name
}
'
def
net2host_shm_path
(
self
,
sim_n
,
sim_h
):
return
'%s/n2h.shm.%s.%s'
%
(
self
.
workdir
,
sim_n
.
name
,
sim_h
.
name
)
return
f
'
{
self
.
workdir
}
/n2h.shm.
{
sim_n
.
name
}
.
{
sim_h
.
name
}
'
def
proxy_shm_path
(
self
,
sim
):
return
'%s/proxy.shm.%s'
%
(
self
.
shm_base
,
sim
.
name
)
return
f
'
{
self
.
shm_base
}
/proxy.shm.
{
sim
.
name
}
'
def
gem5_outdir
(
self
,
sim
):
return
'%s/gem5-out.%s'
%
(
self
.
workdir
,
sim
.
name
)
return
f
'
{
self
.
workdir
}
/gem5-out.
{
sim
.
name
}
'
def
gem5_cpdir
(
self
,
sim
):
return
'%s/gem5-cp.%s'
%
(
self
.
cpdir
,
sim
.
name
)
return
f
'
{
self
.
cpdir
}
/gem5-cp.
{
sim
.
name
}
'
experiments/simbricks/experiments.py
View file @
78d4c701
...
...
@@ -26,7 +26,6 @@ import shlex
import
traceback
import
typing
as
tp
import
simbricks.utils.graphlib
as
graphlib
from
simbricks.exectools
import
Executor
,
SimpleComponent
from
simbricks.experiment.experiment_environment
import
ExpEnv
from
simbricks.experiment.experiment_output
import
ExpOutput
...
...
@@ -34,6 +33,7 @@ from simbricks.proxy import NetProxyConnecter, NetProxyListener, SimProxy
from
simbricks.simulators
import
(
HostSim
,
I40eMultiNIC
,
NetSim
,
NICSim
,
PCIDevSim
,
Simulator
)
from
simbricks.utils
import
graphlib
class
Experiment
(
object
):
...
...
@@ -135,7 +135,7 @@ class DistributedExperiment(Experiment):
def
assign_sim_host
(
self
,
sim
:
Simulator
,
host
:
int
):
"""Assign host ID (< self.num_hosts) for a simulator."""
assert
(
host
>=
0
and
host
<
self
.
num_hosts
)
assert
0
<=
host
<
self
.
num_hosts
self
.
host_mapping
[
sim
]
=
host
def
all_sims_assigned
(
self
):
...
...
@@ -178,17 +178,17 @@ class ExperimentBaseRunner(tp.Generic[T]):
name
=
sim
.
full_name
()
if
self
.
verbose
:
print
(
'%s: starting %s'
%
(
self
.
exp
.
name
,
name
)
)
print
(
f
'
{
self
.
exp
.
name
}
: starting
{
name
}
'
)
run_cmd
=
sim
.
run_cmd
(
self
.
env
)
if
run_cmd
is
None
:
if
self
.
verbose
:
print
(
'%s: started dummy %s'
%
(
self
.
exp
.
name
,
name
)
)
print
(
f
'
{
self
.
exp
.
name
}
: started dummy
{
name
}
'
)
return
# run simulator
exec
=
self
.
sim_executor
(
sim
)
sc
=
exec
.
create_component
(
exec
utor
=
self
.
sim_executor
(
sim
)
sc
=
exec
utor
.
create_component
(
name
,
shlex
.
split
(
run_cmd
),
verbose
=
self
.
verbose
,
canfail
=
True
)
await
sc
.
start
()
...
...
@@ -196,15 +196,15 @@ class ExperimentBaseRunner(tp.Generic[T]):
# add sockets for cleanup
for
s
in
sim
.
sockets_cleanup
(
self
.
env
):
self
.
sockets
.
append
((
exec
,
s
))
self
.
sockets
.
append
((
exec
utor
,
s
))
# Wait till sockets exist
wait_socks
=
sim
.
sockets_wait
(
self
.
env
)
if
wait_socks
:
if
self
.
verbose
:
print
(
'%s
: waiting for sockets
%s'
%
(
self
.
exp
.
name
,
name
)
)
print
(
f
'
{
self
.
exp
.
name
}
: waiting for sockets
{
name
}
'
)
await
exec
.
await_files
(
wait_socks
,
verbose
=
self
.
verbose
)
await
exec
utor
.
await_files
(
wait_socks
,
verbose
=
self
.
verbose
)
# add time delay if required
delay
=
sim
.
start_delay
()
...
...
@@ -215,7 +215,7 @@ class ExperimentBaseRunner(tp.Generic[T]):
self
.
wait_sims
.
append
(
sc
)
if
self
.
verbose
:
print
(
'%s: started %s'
%
(
self
.
exp
.
name
,
name
)
)
print
(
f
'
{
self
.
exp
.
name
}
: started
{
name
}
'
)
async
def
before_wait
(
self
):
pass
...
...
@@ -240,10 +240,10 @@ class ExperimentBaseRunner(tp.Generic[T]):
# prepare all simulators in parallel
sims
=
[]
for
sim
in
self
.
exp
.
all_simulators
():
prep_cmds
=
[
pc
for
pc
in
sim
.
prep_cmds
(
self
.
env
)
]
exec
=
self
.
sim_executor
(
sim
)
prep_cmds
=
list
(
sim
.
prep_cmds
(
self
.
env
)
)
exec
utor
=
self
.
sim_executor
(
sim
)
sims
.
append
(
exec
.
run_cmdlist
(
exec
utor
.
run_cmdlist
(
'prepare_'
+
self
.
exp
.
name
,
prep_cmds
,
verbose
=
self
.
verbose
)
)
...
...
@@ -252,7 +252,7 @@ class ExperimentBaseRunner(tp.Generic[T]):
async
def
wait_for_sims
(
self
):
"""Wait for simulators to terminate (the ones marked to wait on)."""
if
self
.
verbose
:
print
(
'%s
: waiting for hosts to terminate'
%
self
.
exp
.
name
)
print
(
f
'
{
self
.
exp
.
name
}
: waiting for hosts to terminate'
)
for
sc
in
self
.
wait_sims
:
await
sc
.
wait
()
...
...
@@ -279,7 +279,7 @@ class ExperimentBaseRunner(tp.Generic[T]):
await
self
.
before_wait
()
await
self
.
wait_for_sims
()
except
:
except
:
# pylint: disable=bare-except
self
.
out
.
set_failed
()
traceback
.
print_exc
()
...
...
@@ -288,7 +288,7 @@ class ExperimentBaseRunner(tp.Generic[T]):
# shut things back down
if
self
.
verbose
:
print
(
'%s: cleaning up'
%
self
.
exp
.
name
)
print
(
f
'
{
self
.
exp
.
name
}
: cleaning up'
)
await
self
.
before_cleanup
()
...
...
@@ -304,9 +304,9 @@ class ExperimentBaseRunner(tp.Generic[T]):
# remove all sockets
scs
=
[]
for
(
exec
,
sock
)
in
self
.
sockets
:
scs
.
append
(
exec
.
rmtree
(
sock
))
if
len
(
scs
)
:
for
(
exec
utor
,
sock
)
in
self
.
sockets
:
scs
.
append
(
exec
utor
.
rmtree
(
sock
))
if
scs
:
await
asyncio
.
wait
(
scs
)
# add all simulator components to the output
...
...
@@ -320,12 +320,12 @@ class ExperimentBaseRunner(tp.Generic[T]):
class
ExperimentSimpleRunner
(
ExperimentBaseRunner
[
Experiment
]):
"""Simple experiment runner with just one executor."""
def
__init__
(
self
,
exec
:
Executor
,
*
args
,
**
kwargs
):
self
.
exec
=
exec
def
__init__
(
self
,
exec
utor
:
Executor
,
*
args
,
**
kwargs
):
self
.
exec
utor
=
exec
utor
super
().
__init__
(
*
args
,
**
kwargs
)
def
sim_executor
(
self
,
sim
:
Simulator
):
return
self
.
exec
return
self
.
exec
utor
class
ExperimentDistributedRunner
(
ExperimentBaseRunner
[
DistributedExperiment
]):
...
...
@@ -342,13 +342,13 @@ class ExperimentDistributedRunner(ExperimentBaseRunner[DistributedExperiment]):
async
def
prepare
(
self
):
# make sure all simulators are assigned to an executor
assert
(
self
.
exp
.
all_sims_assigned
()
)
assert
self
.
exp
.
all_sims_assigned
()
# set IP addresses for proxies based on assigned executors
for
p
in
itertools
.
chain
(
self
.
exp
.
proxies_listen
,
self
.
exp
.
proxies_connect
):
exec
=
self
.
sim_executor
(
p
)
p
.
ip
=
exec
.
ip
exec
utor
=
self
.
sim_executor
(
p
)
p
.
ip
=
exec
utor
.
ip
await
super
().
prepare
()
experiments/simbricks/nodeconfig.py
View file @
78d4c701
...
...
@@ -20,6 +20,8 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from
__future__
import
annotations
import
io
import
tarfile
...
...
@@ -27,7 +29,8 @@ import tarfile
class
AppConfig
(
object
):
"""Manages the application to be run on a simulated host."""
def
run_cmds
(
self
,
node
):
# pylint: disable=unused-argument
def
run_cmds
(
self
,
node
:
NodeConfig
):
return
[]
def
prepare_pre_cp
(
self
):
...
...
@@ -69,7 +72,7 @@ class NodeConfig(object):
cp_es
=
[]
exit_es
=
[
'poweroff -f'
]
else
:
if
(
self
.
nockp
)
:
if
self
.
nockp
:
cp_es
=
[]
else
:
cp_es
=
[
'm5 checkpoint'
]
...
...
@@ -81,29 +84,26 @@ class NodeConfig(object):
return
'
\n
'
.
join
(
es
)
def
make_tar
(
self
,
path
):
tar
=
tarfile
.
open
(
path
,
'w:'
)
# add main run script
cfg_i
=
tarfile
.
TarInfo
(
'guest/run.sh'
)
cfg_i
.
mode
=
0o777
cfg_f
=
self
.
strfile
(
self
.
config_str
())
cfg_f
.
seek
(
0
,
io
.
SEEK_END
)
cfg_i
.
size
=
cfg_f
.
tell
()
cfg_f
.
seek
(
0
,
io
.
SEEK_SET
)
tar
.
addfile
(
tarinfo
=
cfg_i
,
fileobj
=
cfg_f
)
cfg_f
.
close
()
# add additional config files
for
(
n
,
f
)
in
self
.
config_files
().
items
():
f_i
=
tarfile
.
TarInfo
(
'guest/'
+
n
)
f_i
.
mode
=
0o777
f
.
seek
(
0
,
io
.
SEEK_END
)
f_i
.
size
=
f
.
tell
()
f
.
seek
(
0
,
io
.
SEEK_SET
)
tar
.
addfile
(
tarinfo
=
f_i
,
fileobj
=
f
)
f
.
close
()
tar
.
close
()
with
tarfile
.
open
(
path
,
'w:'
)
as
tar
:
# add main run script
cfg_i
=
tarfile
.
TarInfo
(
'guest/run.sh'
)
cfg_i
.
mode
=
0o777
cfg_f
=
self
.
strfile
(
self
.
config_str
())
cfg_f
.
seek
(
0
,
io
.
SEEK_END
)
cfg_i
.
size
=
cfg_f
.
tell
()
cfg_f
.
seek
(
0
,
io
.
SEEK_SET
)
tar
.
addfile
(
tarinfo
=
cfg_i
,
fileobj
=
cfg_f
)
cfg_f
.
close
()
# add additional config files
for
(
n
,
f
)
in
self
.
config_files
().
items
():
f_i
=
tarfile
.
TarInfo
(
'guest/'
+
n
)
f_i
.
mode
=
0o777
f
.
seek
(
0
,
io
.
SEEK_END
)
f_i
.
size
=
f
.
tell
()
f
.
seek
(
0
,
io
.
SEEK_SET
)
tar
.
addfile
(
tarinfo
=
f_i
,
fileobj
=
f
)
f
.
close
()
def
prepare_pre_cp
(
self
):
return
[
...
...
@@ -150,9 +150,7 @@ class LinuxNode(NodeConfig):
self
.
force_mac_addr
)
l
.
append
(
'ip link set dev '
+
self
.
ifname
+
' up'
)
l
.
append
(
'ip addr add %s/%d dev %s'
%
(
self
.
ip
,
self
.
prefix
,
self
.
ifname
)
)
l
.
append
(
f
'ip addr add
{
self
.
ip
}
/
{
self
.
prefix
}
dev
{
self
.
ifname
}
'
)
return
super
().
prepare_post_cp
()
+
l
...
...
@@ -169,6 +167,7 @@ class CorundumLinuxNode(LinuxNode):
super
().
__init__
()
self
.
drivers
.
append
(
'/tmp/guest/mqnic.ko'
)
# pylint: disable=consider-using-with
def
config_files
(
self
):
m
=
{
'mqnic.ko'
:
open
(
'../images/mqnic/mqnic.ko'
,
'rb'
)}
return
{
**
m
,
**
super
().
config_files
()}
...
...
@@ -207,7 +206,7 @@ class MtcpNode(NodeConfig):
'insmod /root/mtcp/dpdk-iface-kmod/dpdk_iface.ko'
,
'/root/mtcp/dpdk-iface-kmod/dpdk_iface_main'
,
'ip link set dev dpdk0 up'
,
'ip addr add
%s/%d dev dpdk0'
%
(
self
.
ip
,
self
.
prefix
)
f
'ip addr add
{
self
.
ip
}
/
{
self
.
prefix
}
dev dpdk0'
]
def
config_files
(
self
):
...
...
@@ -256,8 +255,10 @@ class TASNode(NodeConfig):
'insmod /root/dpdk/lib/modules/5.4.46/extra/dpdk/igb_uio.ko'
,
'/root/dpdk/sbin/dpdk-devbind -b igb_uio '
+
self
.
pci_dev
,
'cd /root/tas'
,
'tas/tas --ip-addr=%s/%d --fp-cores-max=%d --fp-no-ints &'
%
(
self
.
ip
,
self
.
prefix
,
self
.
fp_cores
),
(
f
'tas/tas --ip-addr=
{
self
.
ip
}
/
{
self
.
prefix
}
'
f
' --fp-cores-max=
{
self
.
fp_cores
}
--fp-no-ints &'
),
'sleep 1'
]
...
...
@@ -358,7 +359,7 @@ class DctcpClient(AppConfig):
is_last
=
False
def
run_cmds
(
self
,
node
):
if
(
self
.
is_last
)
:
if
self
.
is_last
:
return
[
'sleep 1'
,
f
'iperf -w 1M -c
{
self
.
server_ip
}
-Z dctcp -i 1'
,
...
...
@@ -454,10 +455,10 @@ class NoTraffic(AppConfig):
def
run_cmds
(
self
,
node
):
cmds
=
[]
if
(
self
.
is_server
)
:
if
self
.
is_server
:
cmds
.
append
(
'sleep infinity'
)
else
:
if
(
self
.
is_sleep
)
:
if
self
.
is_sleep
:
cmds
.
append
(
'sleep 10'
)
else
:
...
...
@@ -478,10 +479,15 @@ class NetperfClient(AppConfig):
duration_lat
=
10
def
run_cmds
(
self
,
node
):
return
[
'netserver'
,
'sleep 0.5'
,
'netperf -H '
+
self
.
server_ip
+
' -l '
+
str
(
self
.
duration_tp
),
'netperf -H '
+
self
.
server_ip
+
' -l '
+
str
(
self
.
duration_lat
)
+
\
' -t TCP_RR -- -o mean_latency,p50_latency,p90_latency,p99_latency'
]
return
[
'netserver'
,
'sleep 0.5'
,
f
'netperf -H
{
self
.
server_ip
}
-l
{
self
.
duration_tp
}
'
,
(
f
'netperf -H
{
self
.
server_ip
}
-l
{
self
.
duration_lat
}
-t TCP_RR'
' -- -o mean_latency,p50_latency,p90_latency,p99_latency'
)
]
class
VRReplica
(
AppConfig
):
...
...
@@ -542,9 +548,10 @@ class NOPaxosClient(AppConfig):
class
NOPaxosSequencer
(
AppConfig
):
def
run_cmds
(
self
,
node
):
return
[
'/root/nopaxos/sequencer/sequencer -c /root/nopaxos.config -m nopaxos'
]
return
[(
'/root/nopaxos/sequencer/sequencer -c /root/nopaxos.config'
' -m nopaxos'
)]
class
RPCServer
(
AppConfig
):
...
...
@@ -558,8 +565,10 @@ class RPCServer(AppConfig):
'echoserver_mtcp'
return
[
'cd /root/tasbench/micro_rpc'
,
'./%s %d %d /tmp/guest/mtcp.conf %d %d'
%
(
exe
,
self
.
port
,
self
.
threads
,
self
.
max_flows
,
self
.
max_bytes
)
(
f
'./
{
exe
}
{
self
.
port
}
{
self
.
threads
}
/tmp/guest/mtcp.conf'
f
'
{
self
.
max_flows
}
{
self
.
max_bytes
}
'
)
]
...
...
@@ -580,19 +589,13 @@ class RPCClient(AppConfig):
'testclient_mtcp'
return
[
'cd /root/tasbench/micro_rpc'
,
'./%s %s %d %d /tmp/guest/mtcp.conf %d %d %d %d %d %d &'
%
(
exe
,
self
.
server_ip
,
self
.
port
,
self
.
threads
,
self
.
max_bytes
,
self
.
max_pending
,
self
.
max_flows
,
self
.
openall_delay
,
self
.
max_msgs_conn
,
self
.
max_pend_conns
(
f
'./
{
exe
}
{
self
.
server_ip
}
{
self
.
port
}
{
self
.
threads
}
'
f
' /tmp/guest/mtcp.conf
{
self
.
max_bytes
}
{
self
.
max_pending
}
'
f
'
{
self
.
max_flows
}
{
self
.
openall_delay
}
{
self
.
max_msgs_conn
}
'
f
'
{
self
.
max_pend_conns
}
&'
),
'sleep
%d'
%
(
self
.
time
)
f
'sleep
{
self
.
time
}
'
]
...
...
@@ -606,14 +609,22 @@ class HTTPD(AppConfig):
httpd_dir
:
str
# TODO added because doesn't originally exist
def
prepare_pre_cp
(
self
):
return
[
'mkdir -p /srv/www/htdocs/ /tmp/lighttpd/'
,
'dd if=/dev/zero of=/srv/www/htdocs/file bs=%d count=1'
%
\
(
self
.
file_size
)]
return
[
'mkdir -p /srv/www/htdocs/ /tmp/lighttpd/'
,
(
f
'dd if=/dev/zero of=/srv/www/htdocs/file bs=
{
self
.
file_size
}
'
' count=1'
)
]
def
run_cmds
(
self
,
node
):
return
[
'cd %s/src/'
%
(
self
.
httpd_dir
),
'./lighttpd -D -f ../doc/config/%s -n %d -m ./.libs/'
%
\
(
self
.
mtcp_config
,
self
.
threads
)]
return
[
f
'cd
{
self
.
httpd_dir
}
/src/'
,
(
f
'./lighttpd -D -f ../doc/config/
{
self
.
mtcp_config
}
'
f
' -n
{
self
.
threads
}
-m ./.libs/'
)
]
class
HTTPDLinux
(
HTTPD
):
...
...
@@ -630,9 +641,12 @@ class HTTPDMtcp(HTTPD):
def
prepare_pre_cp
(
self
):
return
super
().
prepare_pre_cp
()
+
[
'cp /tmp/guest/mtcp.conf %s/src/mtcp.conf'
%
(
self
.
httpd_dir
),
'sed -i "s:^server.document-root =.*:server.document-root = server_root +
\\
"/htdocs
\\
":" %s'
%
\
(
self
.
httpd_dir
+
'/doc/config/'
+
self
.
mtcp_config
)
f
'cp /tmp/guest/mtcp.conf
{
self
.
httpd_dir
}
/src/mtcp.conf'
,
(
'sed -i "s:^server.document-root =.*:server.document-root = '
'server_root +
\\
"/htdocs
\\
":" '
f
'
{
self
.
httpd_dir
}
/doc/config/
{
self
.
mtcp_config
}
'
)
]
...
...
@@ -646,10 +660,13 @@ class HTTPC(AppConfig):
ab_dir
:
str
# TODO added because doesn't originally exist
def
run_cmds
(
self
,
node
):
return
[
'cd %s/support/'
%
(
self
.
ab_dir
),
'./ab -N %d -c %d -n %d %s%s'
%
\
(
self
.
threads
,
self
.
conns
,
self
.
requests
,
self
.
server_ip
,
self
.
url
)]
return
[
f
'cd
{
self
.
ab_dir
}
/support/'
,
(
f
'./ab -N
{
self
.
threads
}
-c
{
self
.
conns
}
-n
{
self
.
requests
}
'
f
'
{
self
.
server_ip
}{
self
.
url
}
'
)
]
class
HTTPCLinux
(
HTTPC
):
...
...
@@ -661,9 +678,8 @@ class HTTPCMtcp(HTTPC):
def
prepare_pre_cp
(
self
):
return
super
().
prepare_pre_cp
()
+
[
'cp /tmp/guest/mtcp.conf %s/support/config/mtcp.conf'
%
\
(
self
.
ab_dir
),
'rm -f %s/support/config/arp.conf'
%
(
self
.
ab_dir
)
f
'cp /tmp/guest/mtcp.conf
{
self
.
ab_dir
}
/support/config/mtcp.conf'
,
f
'rm -f
{
self
.
ab_dir
}
/support/config/arp.conf'
]
...
...
@@ -682,6 +698,8 @@ class MemcachedClient(AppConfig):
def
run_cmds
(
self
,
node
):
servers
=
[
ip
+
':11211'
for
ip
in
self
.
server_ips
]
servers
=
','
.
join
(
servers
)
return
[
f
'memaslap --binary --time 10s --server=
{
servers
}
--thread=
{
self
.
threads
}
--concurrency=
{
self
.
concurrency
}
--tps=
{
self
.
throughput
}
--verbose'
]
return
[(
f
'memaslap --binary --time 10s --server=
{
servers
}
'
f
' --thread=
{
self
.
threads
}
--concurrency=
{
self
.
concurrency
}
'
f
' --tps=
{
self
.
throughput
}
--verbose'
)]
experiments/simbricks/proxy.py
View file @
78d4c701
...
...
@@ -29,9 +29,6 @@ class SimProxy(Simulator):
ip
=
''
listen
=
False
def
__init__
(
self
):
super
().
__init__
()
def
full_name
(
self
):
return
'proxy.'
+
self
.
name
...
...
@@ -47,9 +44,6 @@ class NetProxy(SimProxy):
# Shared memory size in GB
shm_size
=
2048
def
__init__
(
self
):
super
().
__init__
()
def
start_delay
(
self
):
return
10
...
...
@@ -83,7 +77,7 @@ class NetProxyListener(NetProxy):
for
(
nic
,
local
)
in
self
.
nics
:
if
local
:
deps
.
append
(
nic
)
for
((
net_c
,
net_l
),
local
)
in
self
.
n2ns
:
for
((
_
,
net_l
),
local
)
in
self
.
n2ns
:
if
local
:
deps
.
append
(
net_l
)
return
deps
...
...
@@ -151,7 +145,7 @@ class NetProxyConnecter(NetProxy):
for
(
nic
,
local
)
in
self
.
nics
:
if
not
local
:
deps
.
append
(
nic
)
for
((
net_c
,
net_l
),
local
)
in
self
.
n2ns
:
for
((
_
,
net_l
),
local
)
in
self
.
n2ns
:
if
not
local
:
deps
.
append
(
net_l
)
return
deps
...
...
@@ -194,9 +188,6 @@ class NetProxyConnecter(NetProxy):
class
RDMANetProxyListener
(
NetProxyListener
):
def
__init__
(
self
):
super
().
__init__
()
def
run_cmd
(
self
,
env
):
cmd
=
f
'
{
env
.
repodir
}
/dist/rdma/net_rdma -l '
cmd
+=
super
().
run_cmd_base
(
env
)
...
...
@@ -205,9 +196,6 @@ class RDMANetProxyListener(NetProxyListener):
class
RDMANetProxyConnecter
(
NetProxyConnecter
):
def
__init__
(
self
,
listener
):
super
().
__init__
(
listener
)
def
run_cmd
(
self
,
env
):
cmd
=
f
'
{
env
.
repodir
}
/dist/rdma/net_rdma '
cmd
+=
super
().
run_cmd_base
(
env
)
...
...
@@ -216,9 +204,6 @@ class RDMANetProxyConnecter(NetProxyConnecter):
class
SocketsNetProxyListener
(
NetProxyListener
):
def
__init__
(
self
):
super
().
__init__
()
def
run_cmd
(
self
,
env
):
cmd
=
f
'
{
env
.
repodir
}
/dist/sockets/net_sockets -l '
cmd
+=
super
().
run_cmd_base
(
env
)
...
...
@@ -227,9 +212,6 @@ class SocketsNetProxyListener(NetProxyListener):
class
SocketsNetProxyConnecter
(
NetProxyConnecter
):
def
__init__
(
self
,
listener
):
super
().
__init__
(
listener
)
def
run_cmd
(
self
,
env
):
cmd
=
f
'
{
env
.
repodir
}
/dist/sockets/net_sockets '
cmd
+=
super
().
run_cmd_base
(
env
)
...
...
experiments/simbricks/runtime/common.py
View file @
78d4c701
...
...
@@ -28,10 +28,10 @@ import shutil
import
typing
as
tp
from
abc
import
ABCMeta
,
abstractmethod
import
simbricks.exectools
as
exectools
from
simbricks.experiment.experiment_environment
import
ExpEnv
from
simbricks.experiment.experiment_output
import
ExpOutput
from
simbricks
import
exectools
from
simbricks.experiments
import
Experiment
...
...
@@ -56,22 +56,22 @@ class Run(object):
def
name
(
self
):
return
self
.
experiment
.
name
+
'.'
+
str
(
self
.
index
)
async
def
prep_dirs
(
self
,
exec
=
exectools
.
LocalExecutor
()):
async
def
prep_dirs
(
self
,
exec
utor
=
exectools
.
LocalExecutor
()):
shutil
.
rmtree
(
self
.
env
.
workdir
,
ignore_errors
=
True
)
await
exec
.
rmtree
(
self
.
env
.
workdir
)
await
exec
utor
.
rmtree
(
self
.
env
.
workdir
)
shutil
.
rmtree
(
self
.
env
.
shm_base
,
ignore_errors
=
True
)
await
exec
.
rmtree
(
self
.
env
.
shm_base
)
await
exec
utor
.
rmtree
(
self
.
env
.
shm_base
)
if
self
.
env
.
create_cp
:
shutil
.
rmtree
(
self
.
env
.
cpdir
,
ignore_errors
=
True
)
await
exec
.
rmtree
(
self
.
env
.
cpdir
)
await
exec
utor
.
rmtree
(
self
.
env
.
cpdir
)
pathlib
.
Path
(
self
.
env
.
workdir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
await
exec
.
mkdir
(
self
.
env
.
workdir
)
await
exec
utor
.
mkdir
(
self
.
env
.
workdir
)
pathlib
.
Path
(
self
.
env
.
cpdir
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
await
exec
.
mkdir
(
self
.
env
.
cpdir
)
await
exec
utor
.
mkdir
(
self
.
env
.
cpdir
)
pathlib
.
Path
(
self
.
env
.
shm_base
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
await
exec
.
mkdir
(
self
.
env
.
shm_base
)
await
exec
utor
.
mkdir
(
self
.
env
.
shm_base
)
class
Runtime
(
metaclass
=
ABCMeta
):
...
...
experiments/simbricks/runtime/distributed.py
View file @
78d4c701
...
...
@@ -22,21 +22,22 @@
import
asyncio
import
pathlib
import
typing
as
tp
import
simbricks.proxy
as
proxy
from
simbricks.exectools
import
Executor
from
simbricks.runtime.common
import
*
from
simbricks.runtime.common
import
Run
,
Runtime
import
simbricks.experiments
as
exp
from
simbricks
import
proxy
class
DistributedSimpleRuntime
(
Runtime
):
def
__init__
(
self
,
execs
,
verbose
=
False
):
def
__init__
(
self
,
exec
utor
s
,
verbose
=
False
):
self
.
runnable
=
[]
self
.
complete
=
[]
self
.
verbose
=
verbose
self
.
execs
=
execs
self
.
exec
utor
s
=
exec
utor
s
def
add_run
(
self
,
run
:
Run
):
if
not
isinstance
(
run
.
experiment
,
exp
.
DistributedExperiment
):
...
...
@@ -46,16 +47,16 @@ class DistributedSimpleRuntime(Runtime):
async
def
do_run
(
self
,
run
:
Run
):
runner
=
exp
.
ExperimentDistributedRunner
(
self
.
execs
,
run
.
experiment
,
run
.
env
,
self
.
verbose
self
.
exec
utor
s
,
run
.
experiment
,
run
.
env
,
self
.
verbose
)
for
exec
in
self
.
execs
:
await
run
.
prep_dirs
(
exec
)
for
exec
utor
in
self
.
exec
utor
s
:
await
run
.
prep_dirs
(
exec
utor
)
await
runner
.
prepare
()
run
.
output
=
await
runner
.
run
()
self
.
complete
.
append
(
run
)
pathlib
.
Path
(
run
.
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
run
.
outpath
,
'w'
)
as
f
:
with
open
(
run
.
outpath
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
run
.
output
.
dumps
())
def
start
(
self
):
...
...
@@ -64,7 +65,7 @@ class DistributedSimpleRuntime(Runtime):
def
auto_dist
(
e
:
Experiment
,
execs
:
tp
.
List
[
Executor
],
proxy_type
:
str
=
'sockets'
e
:
exp
.
Experiment
,
execs
:
tp
.
List
[
Executor
],
proxy_type
:
str
=
'sockets'
):
"""
Converts an Experiment into a DistributedExperiment.
...
...
experiments/simbricks/runtime/local.py
View file @
78d4c701
...
...
@@ -22,12 +22,12 @@
import
asyncio
import
pathlib
from
typing
import
Optional
import
typing
as
tp
import
simbricks.exectools
as
exectools
from
simbricks.runtime.common
import
*
from
simbricks.runtime.common
import
Run
,
Runtime
import
simbricks.experiments
as
exp
from
simbricks
import
exectools
class
LocalSimpleRuntime
(
Runtime
):
...
...
@@ -36,12 +36,12 @@ class LocalSimpleRuntime(Runtime):
def
__init__
(
self
,
verbose
=
False
,
exec
:
exectools
.
Executor
=
exectools
.
LocalExecutor
()
exec
utor
:
exectools
.
Executor
=
exectools
.
LocalExecutor
()
):
self
.
runnable
:
tp
.
List
[
Run
]
=
[]
self
.
complete
:
tp
.
List
[
Run
]
=
[]
self
.
verbose
=
verbose
self
.
exec
=
exec
self
.
exec
utor
=
exec
utor
def
add_run
(
self
,
run
:
Run
):
self
.
runnable
.
append
(
run
)
...
...
@@ -49,15 +49,15 @@ class LocalSimpleRuntime(Runtime):
async
def
do_run
(
self
,
run
:
Run
):
"""Actually executes `run`."""
runner
=
exp
.
ExperimentSimpleRunner
(
self
.
exec
,
run
.
experiment
,
run
.
env
,
self
.
verbose
self
.
exec
utor
,
run
.
experiment
,
run
.
env
,
self
.
verbose
)
await
run
.
prep_dirs
(
self
.
exec
)
await
run
.
prep_dirs
(
self
.
exec
utor
)
await
runner
.
prepare
()
run
.
output
=
await
runner
.
run
()
self
.
complete
.
append
(
run
)
pathlib
.
Path
(
run
.
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
run
.
outpath
,
'w'
)
as
f
:
with
open
(
run
.
outpath
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
run
.
output
.
dumps
())
def
start
(
self
):
...
...
@@ -72,9 +72,9 @@ class LocalParallelRuntime(Runtime):
def
__init__
(
self
,
cores
:
int
,
mem
:
Optional
[
int
]
=
None
,
mem
:
tp
.
Optional
[
int
]
=
None
,
verbose
=
False
,
exec
:
exectools
.
Executor
=
exectools
.
LocalExecutor
()
exec
utor
:
exectools
.
Executor
=
exectools
.
LocalExecutor
()
):
self
.
runs_noprereq
:
tp
.
List
[
Run
]
=
[]
"""Runs with no prerequesite runs."""
...
...
@@ -84,7 +84,7 @@ class LocalParallelRuntime(Runtime):
self
.
cores
=
cores
self
.
mem
=
mem
self
.
verbose
=
verbose
self
.
exec
=
exec
self
.
exec
utor
=
exec
utor
def
add_run
(
self
,
run
:
Run
):
if
run
.
experiment
.
resreq_cores
()
>
self
.
cores
:
...
...
@@ -101,15 +101,15 @@ class LocalParallelRuntime(Runtime):
async
def
do_run
(
self
,
run
:
Run
):
"""Actually executes `run`."""
runner
=
exp
.
ExperimentSimpleRunner
(
self
.
exec
,
run
.
experiment
,
run
.
env
,
self
.
verbose
self
.
exec
utor
,
run
.
experiment
,
run
.
env
,
self
.
verbose
)
await
run
.
prep_dirs
(
exec
=
self
.
exec
)
await
run
.
prep_dirs
(
exec
utor
=
self
.
exec
utor
)
await
runner
.
prepare
()
print
(
'starting run '
,
run
.
name
())
run
.
output
=
await
runner
.
run
()
pathlib
.
Path
(
run
.
outpath
).
parent
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
with
open
(
run
.
outpath
,
'w'
)
as
f
:
with
open
(
run
.
outpath
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
run
.
output
.
dumps
())
print
(
'finished run '
,
run
.
name
())
return
run
...
...
@@ -130,7 +130,7 @@ class LocalParallelRuntime(Runtime):
def
enough_resources
(
self
,
run
:
Run
):
"""Check if enough cores and mem are available for the run."""
exp
=
run
.
experiment
exp
=
run
.
experiment
# pylint: disable=redefined-outer-name
if
self
.
cores
is
not
None
:
enough_cores
=
(
self
.
cores
-
self
.
cores_used
)
>=
exp
.
resreq_cores
()
...
...
experiments/simbricks/runtime/slurm.py
View file @
78d4c701
...
...
@@ -25,7 +25,7 @@ import pathlib
import
pickle
import
re
from
simbricks.runtime.common
import
*
from
simbricks.runtime.common
import
Run
,
Runtime
class
SlurmRuntime
(
Runtime
):
...
...
@@ -55,17 +55,17 @@ class SlurmRuntime(Runtime):
print
(
exp_script
)
# write out pickled run
with
open
(
exp_path
,
'wb'
)
as
f
:
with
open
(
exp_path
,
'wb'
,
encoding
=
'utf-8'
)
as
f
:
run
.
prereq
=
None
# we don't want to pull in the prereq too
pickle
.
dump
(
run
,
f
)
# create slurm batch script
with
open
(
exp_script
,
'w'
)
as
f
:
with
open
(
exp_script
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
'#!/bin/sh
\n
'
)
f
.
write
(
'#SBATCH -o
%s -e %s
\n
'
%
(
exp_log
,
exp_log
)
)
f
.
write
(
f
'#SBATCH -o
{
exp_log
}
-e
{
exp_log
}
\n
'
)
#f.write('#SBATCH -c %d\n' % (exp.resreq_cores(),))
f
.
write
(
'#SBATCH --mem=
%dM
\n
'
%
(
exp
.
resreq_mem
()
,)
)
f
.
write
(
'#SBATCH --job-name="
%s"
\n
'
%
(
run
.
name
()
,)
)
f
.
write
(
f
'#SBATCH --mem=
{
exp
.
resreq_mem
()
}
M
\n
'
)
f
.
write
(
f
'#SBATCH --job-name="
{
run
.
name
()
}
"
\n
'
)
f
.
write
(
'#SBATCH --exclude=spyder[01-05],spyder16
\n
'
)
f
.
write
(
'#SBATCH -c 32
\n
'
)
f
.
write
(
'#SBATCH --nodes=1
\n
'
)
...
...
@@ -73,16 +73,16 @@ class SlurmRuntime(Runtime):
h
=
int
(
exp
.
timeout
/
3600
)
m
=
int
((
exp
.
timeout
%
3600
)
/
60
)
s
=
int
(
exp
.
timeout
%
60
)
f
.
write
(
'#SBATCH --time=
%02d:%02d:%
02d
\n
'
%
(
h
,
m
,
s
)
)
f
.
write
(
f
'#SBATCH --time=
{
h
:
02
d
}
:
{
m
:
02
d
}
:
{
s
:
02
d
}
\n
'
)
extra
=
''
if
self
.
verbose
:
extra
=
'--verbose'
f
.
write
(
'python3 run.py
%s
--pickled
%s
\n
'
%
(
extra
,
exp_path
)
)
f
.
write
(
f
'python3 run.py
{
extra
}
--pickled
{
exp_path
}
\n
'
)
f
.
write
(
'status=$?
\n
'
)
if
self
.
cleanup
:
f
.
write
(
'rm -rf
%s
\n
'
%
(
run
.
env
.
workdir
)
)
f
.
write
(
f
'rm -rf
{
run
.
env
.
workdir
}
\n
'
)
f
.
write
(
'exit $status
\n
'
)
return
exp_script
...
...
@@ -100,7 +100,7 @@ class SlurmRuntime(Runtime):
script
=
self
.
prep_run
(
run
)
stream
=
os
.
popen
(
'sbatch
%s %s'
%
(
dep_cmd
,
script
)
)
stream
=
os
.
popen
(
f
'sbatch
{
dep_cmd
}
{
script
}
'
)
output
=
stream
.
read
()
result
=
stream
.
close
()
...
...
experiments/simbricks/simulator_utils.py
View file @
78d4c701
...
...
@@ -56,12 +56,12 @@ def create_basic_hosts(
nic
.
set_network
(
net
)
host
=
host_class
()
host
.
name
=
'%s.%d'
%
(
name_prefix
,
i
)
host
.
name
=
f
'
{
name_prefix
}
.
{
i
}
'
node_config
=
nc_class
()
node_config
.
prefix
=
ip_prefix
ip
=
ip_start
+
i
node_config
.
ip
=
'10.0.
%d.%d'
%
(
int
(
ip
/
256
)
,
ip
%
256
)
node_config
.
ip
=
f
'10.0.
{
int
(
ip
/
256
)
}
.
{
ip
%
256
}
'
node_config
.
app
=
app_class
()
host
.
set_config
(
node_config
)
...
...
@@ -105,12 +105,12 @@ def create_multinic_hosts(
nic
.
set_network
(
net
)
host
=
host_class
()
host
.
name
=
'%s.%d'
%
(
name_prefix
,
i
)
host
.
name
=
f
'
{
name_prefix
}
.
{
i
}
'
node_config
=
nc_class
()
node_config
.
prefix
=
ip_prefix
ip
=
ip_start
+
i
node_config
.
ip
=
'10.0.
%d.%d'
%
(
int
(
ip
/
256
)
,
ip
%
256
)
node_config
.
ip
=
f
'10.0.
{
int
(
ip
/
256
)
}
.
{
ip
%
256
}
'
node_config
.
app
=
app_class
()
host
.
set_config
(
node_config
)
...
...
@@ -150,12 +150,12 @@ def create_dctcp_hosts(
nic
.
set_network
(
net
)
host
=
host_class
()
host
.
name
=
'%s.%d'
%
(
name_prefix
,
i
)
host
.
name
=
f
'
{
name_prefix
}
.
{
i
}
'
host
.
cpu_freq
=
cpu_freq
node_config
=
nc_class
()
node_config
.
mtu
=
mtu
node_config
.
ip
=
'192.168.64.
%d'
%
(
ip_start
+
i
)
node_config
.
ip
=
f
'192.168.64.
{
ip_start
+
i
}
'
node_config
.
app
=
app_class
()
host
.
set_config
(
node_config
)
...
...
Prev
1
2
3
4
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment