Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xanadu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
SYNERG
xanadu
Commits
0357774b
Commit
0357774b
authored
Sep 15, 2021
by
Mahendra Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit_message
parent
3a6cef8c
Changes
67
Show whitespace changes
Inline
Side-by-side
Showing
67 changed files
with
983 additions
and
161 deletions
+983
-161
dispatch_system/benchmark_dispatcher.py
dispatch_system/benchmark_dispatcher.py
+75
-55
dispatch_system/benchmark_dispatcher2.py
dispatch_system/benchmark_dispatcher2.py
+149
-0
dispatch_system/benchmark_dispatcher_receive.py
dispatch_system/benchmark_dispatcher_receive.py
+78
-0
dispatch_system/constants.json
dispatch_system/constants.json
+3
-3
dispatch_system/constants_local.json
dispatch_system/constants_local.json
+4
-3
dispatch_system/dispatch_daemon/execute.js
dispatch_system/dispatch_daemon/execute.js
+15
-9
dispatch_system/dispatch_daemon/index.js
dispatch_system/dispatch_daemon/index.js
+2
-1
dispatch_system/dispatch_daemon/lib.js
dispatch_system/dispatch_daemon/lib.js
+2
-1
dispatch_system/dispatch_manager/explicit_chain_handler.js
dispatch_system/dispatch_manager/explicit_chain_handler.js
+1
-1
dispatch_system/dispatch_manager/index.js
dispatch_system/dispatch_manager/index.js
+23
-7
dispatch_system/dispatch_manager/lib.js
dispatch_system/dispatch_manager/lib.js
+27
-22
dispatch_system/dispatch_manager/metrics.js
dispatch_system/dispatch_manager/metrics.js
+2
-2
dispatch_system/dispatch_manager/nic.tgz
dispatch_system/dispatch_manager/nic.tgz
+0
-0
dispatch_system/dispatch_manager/nic/Makefile-nfp4build
dispatch_system/dispatch_manager/nic/Makefile-nfp4build
+1
-3
dispatch_system/dispatch_manager/nic/assign_ip.sh
dispatch_system/dispatch_manager/nic/assign_ip.sh
+32
-4
dispatch_system/dispatch_manager/nic/build_offload.sh
dispatch_system/dispatch_manager/nic/build_offload.sh
+1
-1
dispatch_system/dispatch_manager/nic/p4src/Makefile-nfp4build
...atch_system/dispatch_manager/nic/p4src/Makefile-nfp4build
+0
-0
dispatch_system/dispatch_manager/nic/p4src/bin
dispatch_system/dispatch_manager/nic/p4src/bin
+0
-0
dispatch_system/dispatch_manager/nic/p4src/command_to_offload
...atch_system/dispatch_manager/nic/p4src/command_to_offload
+0
-0
dispatch_system/dispatch_manager/nic/p4src/echo.bmv2.json
dispatch_system/dispatch_manager/nic/p4src/echo.bmv2.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/echo.p4cfg
dispatch_system/dispatch_manager/nic/p4src/echo.p4cfg
+3
-3
dispatch_system/dispatch_manager/nic/p4src/echo.p4info.json
dispatch_system/dispatch_manager/nic/p4src/echo.p4info.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/echo.yml
dispatch_system/dispatch_manager/nic/p4src/echo.yml
+0
-0
dispatch_system/dispatch_manager/nic/p4src/ethernet.p4
dispatch_system/dispatch_manager/nic/p4src/ethernet.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/includes/defines.p4
...tch_system/dispatch_manager/nic/p4src/includes/defines.p4
+1
-0
dispatch_system/dispatch_manager/nic/p4src/includes/headers.p4
...tch_system/dispatch_manager/nic/p4src/includes/headers.p4
+19
-1
dispatch_system/dispatch_manager/nic/p4src/includes/parsers.p4
...tch_system/dispatch_manager/nic/p4src/includes/parsers.p4
+14
-0
dispatch_system/dispatch_manager/nic/p4src/ipv4.p4
dispatch_system/dispatch_manager/nic/p4src/ipv4.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/mds.p4
dispatch_system/dispatch_manager/nic/p4src/mds.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/memory.c
dispatch_system/dispatch_manager/nic/p4src/memory.c
+0
-0
dispatch_system/dispatch_manager/nic/p4src/offload.bmv2.json
dispatch_system/dispatch_manager/nic/p4src/offload.bmv2.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/offload.p4info.json
...tch_system/dispatch_manager/nic/p4src/offload.p4info.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/offload.txt
dispatch_system/dispatch_manager/nic/p4src/offload.txt
+0
-0
dispatch_system/dispatch_manager/nic/p4src/orchestrator.bmv2.json
..._system/dispatch_manager/nic/p4src/orchestrator.bmv2.json
+56
-4
dispatch_system/dispatch_manager/nic/p4src/orchestrator.p4info.json
...ystem/dispatch_manager/nic/p4src/orchestrator.p4info.json
+1
-1
dispatch_system/dispatch_manager/nic/p4src/orchestrator.yml
dispatch_system/dispatch_manager/nic/p4src/orchestrator.yml
+22
-7
dispatch_system/dispatch_manager/nic/p4src/orchestrator2.p4
dispatch_system/dispatch_manager/nic/p4src/orchestrator2.p4
+161
-0
dispatch_system/dispatch_manager/nic/p4src/prime.c
dispatch_system/dispatch_manager/nic/p4src/prime.c
+0
-0
dispatch_system/dispatch_manager/nic/p4src/routing_benchmark.bmv2.json
...em/dispatch_manager/nic/p4src/routing_benchmark.bmv2.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/routing_benchmark.p4
...ch_system/dispatch_manager/nic/p4src/routing_benchmark.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/routing_benchmark.p4info.json
.../dispatch_manager/nic/p4src/routing_benchmark.p4info.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/routing_benchmark.yml
...h_system/dispatch_manager/nic/p4src/routing_benchmark.yml
+0
-0
dispatch_system/dispatch_manager/nic/p4src/sched.p4
dispatch_system/dispatch_manager/nic/p4src/sched.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/sched.txt
dispatch_system/dispatch_manager/nic/p4src/sched.txt
+0
-0
dispatch_system/dispatch_manager/nic/p4src/sched16.p4
dispatch_system/dispatch_manager/nic/p4src/sched16.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/test.bmv2.json
dispatch_system/dispatch_manager/nic/p4src/test.bmv2.json
+3
-3
dispatch_system/dispatch_manager/nic/p4src/test.p4
dispatch_system/dispatch_manager/nic/p4src/test.p4
+0
-0
dispatch_system/dispatch_manager/nic/p4src/test.p4cfg
dispatch_system/dispatch_manager/nic/p4src/test.p4cfg
+0
-0
dispatch_system/dispatch_manager/nic/p4src/test.p4info.json
dispatch_system/dispatch_manager/nic/p4src/test.p4info.json
+0
-0
dispatch_system/dispatch_manager/nic/p4src/test.yml
dispatch_system/dispatch_manager/nic/p4src/test.yml
+4
-4
dispatch_system/dispatch_manager/nic/receive_reply.py
dispatch_system/dispatch_manager/nic/receive_reply.py
+1
-1
dispatch_system/dispatch_manager/nic/send.py
dispatch_system/dispatch_manager/nic/send.py
+13
-7
dispatch_system/dispatch_manager/nic/send.sh
dispatch_system/dispatch_manager/nic/send.sh
+2
-1
dispatch_system/dispatch_manager/nic/send2.py
dispatch_system/dispatch_manager/nic/send2.py
+182
-0
dispatch_system/dispatch_manager/nic/send_docker.sh
dispatch_system/dispatch_manager/nic/send_docker.sh
+2
-1
dispatch_system/dispatch_manager/nic/smartnic_dispatch_monitor.py
..._system/dispatch_manager/nic/smartnic_dispatch_monitor.py
+3
-1
dispatch_system/dispatch_manager/repository/worker_env/env_udp.js
..._system/dispatch_manager/repository/worker_env/env_udp.js
+15
-8
dispatch_system/dispatch_manager/rm.js
dispatch_system/dispatch_manager/rm.js
+12
-1
dispatch_system/dispatch_manager/shared_meta.js
dispatch_system/dispatch_manager/shared_meta.js
+4
-2
dispatch_system/log_listener.js
dispatch_system/log_listener.js
+2
-2
dispatch_system/setup_topics.js
dispatch_system/setup_topics.js
+2
-2
docker-compose.yml
docker-compose.yml
+1
-0
docker-compose2.txt
docker-compose2.txt
+41
-0
test.js
test.js
+1
-0
test1.js
test1.js
+1
-0
test3.js
test3.js
+1
-0
test4.js
test4.js
+1
-0
No files found.
dispatch_system/benchmark_dispatcher.py
View file @
0357774b
...
...
@@ -4,7 +4,7 @@ import time
import
threading
import
random
import
time
import
numpy
as
np
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
'Mininet demo'
)
...
...
@@ -13,6 +13,8 @@ parser.add_argument('--fid', help='Funtion id',
type
=
int
,
action
=
"store"
,
required
=
False
)
parser
.
add_argument
(
'--c'
,
help
=
'Concurrency'
,
type
=
int
,
action
=
"store"
,
required
=
True
)
parser
.
add_argument
(
'--t'
,
help
=
'Runtime'
,
type
=
int
,
action
=
"store"
,
required
=
True
)
group
=
parser
.
add_mutually_exclusive_group
(
required
=
True
)
group
.
add_argument
(
'--rps'
,
help
=
'Requests per second'
,
type
=
int
,
action
=
"store"
)
...
...
@@ -25,106 +27,100 @@ args = parser.parse_args()
PORT
=
8000
dataInt
=
0
fid
=
args
.
fid
runtime
=
args
.
t
concurrency
=
args
.
c
SERVER_IP
=
"192.168.2.3"
egress_time
=
[]
ingress_time
=
[]
packet_holder
=
[
None
]
*
11
ingress_time
=
{}
stop_thread
=
False
def
receive
():
global
egress_time
,
stop_thread
def
receive
(
i
):
global
stop_thread
,
packet_holder
CLIENT_IP
=
"0.0.0.0"
port
=
10000
+
i
print
i
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
bind
((
CLIENT_IP
,
8080
))
print
"listening to {} at port {}"
.
format
(
CLIENT_IP
,
8080
)
s
.
bind
((
CLIENT_IP
,
port
))
print
(
"listening to {} at port {}"
.
format
(
CLIENT_IP
,
port
)
)
run_status
=
{}
packet_holder
[
i
]
=
[]
while
True
:
if
stop_thread
:
break
packet
,
addr
=
s
.
recvfrom
(
1024
)
# print packet
base
=
0
chain_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
exec_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
function_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
data
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
function_count
=
struct
.
unpack
(
"B"
,
packet
[
base
])[
0
]
t
=
int
(
time
.
time
()
*
1000
)
%
1000000000
data
=
int
(
data
)
-
t
print
"rec"
,
chain_id
,
exec_id
,
data
,
function_id
,
function_count
,
packet_holder
[
i
]
.
append
((
packet
,
time
.
time
()
))
# print "r", "{0:f}".format((time.time() * 1000)), "{0:f}".format(ingress_time[exec_id])
def
genPacket
():
global
fid
packet
=
None
exec_id
=
random
.
randint
(
0
,
2
**
30
)
print
exec_id
chain_id
=
1
function_count
=
5
function_id
=
fid
if
(
fid
)
else
1
f0
=
0
;
f1
=
1
;
f2
=
2
;
f3
=
0
;
f4
=
0
print
chain_id
,
exec_id
,
"function_id"
,
function_id
,
function_count
,
\
f0
,
f1
,
f2
,
f3
,
f4
#
print chain_id, exec_id, "function_id", function_id, function_count, \
# f0, f1, f2, f3, f4,
chain_id
=
struct
.
pack
(
">I"
,
chain_id
)
# chain id
exec_id
=
struct
.
pack
(
">I"
,
exec_id
)
# execution id
exec_id
_packed
=
struct
.
pack
(
">I"
,
exec_id
)
# execution id
dataInt
=
int
(
time
.
time
()
*
1000
)
%
1000000000
dataInt
=
0
# print " dataInt", dataInt
data
=
struct
.
pack
(
">I"
,
dataInt
)
# data
function_count
=
struct
.
pack
(
"B"
,
function_count
)
# function count
function_id
_packed
=
struct
.
pack
(
">I"
,
function_id
)
function_id
=
struct
.
pack
(
">I"
,
function_id
)
f0
=
struct
.
pack
(
"B"
,
f0
)
# f0
f1
=
struct
.
pack
(
"B"
,
f1
)
# f1
f2
=
struct
.
pack
(
"B"
,
f2
)
# f2 -> f0
f3
=
struct
.
pack
(
"B"
,
f3
)
# f3 -> f1 f2
f4
=
struct
.
pack
(
"B"
,
f4
)
# f4 -> f3
packet
=
chain_id
+
exec_id
+
function_id_packe
d
+
data
+
function_count
+
f0
+
f1
+
f2
+
f3
+
f4
packet
=
chain_id
+
exec_id
_packed
+
function_i
d
+
data
+
function_count
+
f0
+
f1
+
f2
+
f3
+
f4
# print dataInt, offload_status
return
packet
,
function
_id
return
packet
,
exec
_id
def
sendThread
(
start_time
,
runtime
,
sleep_time
):
global
ingress_time
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
while
True
:
packet
,
function_id
=
genPacket
()
if
time
.
time
()
-
start_time
>
runtime
:
break
packet
,
exec_id
=
genPacket
()
if
exec_id
in
ingress_time
:
continue
s
.
sendto
(
packet
,
(
SERVER_IP
,
PORT
))
ingress_time
.
append
(
time
.
time
())
ingress_time
[
exec_id
]
=
time
.
time
()
time
.
sleep
(
sleep_time
)
def
send
():
global
egress_time
,
ingress_time
global
egress_time
,
ingress_time
,
concurrency
,
runtime
,
stop_thread
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
print
"Sending packet to
%
s at port
%
s"
%
(
SERVER_IP
,
PORT
)
print
"chain id, exec id, data, function count, functions dependencies..."
print
(
"Sending packet to
%
s at port
%
s"
%
(
SERVER_IP
,
PORT
))
print
(
"Runtime:
%
d Concurrency
%
d"
%
(
runtime
,
concurrency
))
print
(
"chain id, exec id, data, function count, functions dependencies..."
)
# op = struct.unpack("B", packet[0])
packet
,
_
=
genPacket
()
if
args
.
n
is
not
None
:
for
i
in
range
(
args
.
req_count
):
for
i
in
range
(
args
.
n
):
packet
,
exec_id
=
genPacket
()
s
.
sendto
(
packet
,
(
SERVER_IP
,
PORT
))
ingress_time
.
append
(
time
.
time
())
ingress_time
[
exec_id
]
=
time
.
time
()
*
1000
print
(
"s"
,
"{0:f}"
.
format
(
ingress_time
[
exec_id
]))
elif
args
.
rps
is
not
None
:
runtime
=
10
thread_count
=
args
.
c
start_time
=
time
.
time
()
sleep_time
=
thread_count
/
float
(
args
.
rps
)
print
"calculated inter-arrival time, offload mode"
,
sleep_time
for
i
in
range
(
thread_count
):
sleep_time
=
concurrency
/
float
(
args
.
rps
)
print
(
"calculated inter-arrival time, offload mode"
,
sleep_time
)
for
i
in
range
(
concurrency
):
t
=
threading
.
Thread
(
target
=
sendThread
,
args
=
[
start_time
,
runtime
,
sleep_time
])
t
.
daemon
=
True
...
...
@@ -135,13 +131,37 @@ def send():
# s.sendto(packet, (SERVER_IP, PORT))
# r.join()
r
=
threading
.
Thread
(
name
=
"receive"
,
target
=
receive
)
r
.
daemon
=
True
r
.
start
()
def
printStatistics
():
global
runtime
e2e_time
=
[]
for
packetThread
in
packet_holder
:
for
packetTuple
in
packetThread
:
packet
=
packetTuple
[
0
]
base
=
0
chain_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
exec_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
e2e_time
.
append
((
packetTuple
[
1
]
-
ingress_time
[
exec_id
])
*
1000
)
print
e2e_time
data
=
np
.
array
(
e2e_time
,
dtype
=
float
)
p50
=
np
.
percentile
(
data
,
50
)
p95
=
np
.
percentile
(
data
,
95
)
p99
=
np
.
percentile
(
data
,
99
)
mean
=
np
.
mean
(
data
)
print
(
"mean
\t
p50
\t
p95
\t
p99"
)
print
(
mean
,
p50
,
p95
,
p99
)
print
(
"rps"
,
len
(
e2e_time
)
/
runtime
,
len
(
ingress_time
))
return
0
for
i
in
range
(
0
,
11
):
r
=
threading
.
Thread
(
name
=
"receive"
,
target
=
receive
,
args
=
[
i
])
r
.
daemon
=
True
r
.
start
()
time
.
sleep
(
1
)
send
()
r
.
join
()
time
.
sleep
(
2
)
# r.join()
printStatistics
()
dispatch_system/benchmark_dispatcher2.py
0 → 100644
View file @
0357774b
import
socket
import
struct
import
time
import
threading
import
random
import
time
import
argparse
parser
=
argparse
.
ArgumentParser
(
description
=
'Mininet demo'
)
parser
.
add_argument
(
'--fid'
,
help
=
'Funtion id'
,
type
=
int
,
action
=
"store"
,
required
=
False
)
parser
.
add_argument
(
'--c'
,
help
=
'Concurrency'
,
type
=
int
,
action
=
"store"
,
required
=
True
)
parser
.
add_argument
(
'--req_count'
,
help
=
'request count'
,
type
=
int
,
action
=
"store"
,
required
=
True
)
group
=
parser
.
add_mutually_exclusive_group
(
required
=
True
)
group
.
add_argument
(
'--rps'
,
help
=
'Requests per second'
,
type
=
int
,
action
=
"store"
)
group
.
add_argument
(
'--n'
,
help
=
'Number of requests to send'
,
type
=
int
,
action
=
"store"
)
args
=
parser
.
parse_args
()
PORT
=
8000
dataInt
=
0
fid
=
args
.
fid
SERVER_IP
=
"192.168.2.3"
egress_time
=
[]
ingress_time
=
[]
stop_thread
=
False
def
receive
():
global
egress_time
,
stop_thread
CLIENT_IP
=
"0.0.0.0"
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
bind
((
CLIENT_IP
,
8080
))
print
"listening to {} at port {}"
.
format
(
CLIENT_IP
,
8080
)
run_status
=
{}
while
True
:
if
stop_thread
:
break
packet
,
addr
=
s
.
recvfrom
(
1024
)
# print packet
base
=
0
chain_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
exec_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
function_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
data
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
function_count
=
struct
.
unpack
(
"B"
,
packet
[
base
])[
0
]
t
=
int
(
time
.
time
()
*
1000
)
%
1000000000
data
=
int
(
data
)
-
t
print
"rec"
,
chain_id
,
exec_id
,
data
,
function_id
,
function_count
,
def
genPacket
():
global
fid
packet
=
None
exec_id
=
random
.
randint
(
0
,
2
**
30
)
print
exec_id
chain_id
=
1
function_count
=
5
function_id
=
fid
if
(
fid
)
else
1
f0
=
0
;
f1
=
1
;
f2
=
2
;
f3
=
0
;
f4
=
0
print
chain_id
,
exec_id
,
"function_id"
,
function_id
,
function_count
,
\
f0
,
f1
,
f2
,
f3
,
f4
chain_id
=
struct
.
pack
(
">I"
,
chain_id
)
# chain id
exec_id
=
struct
.
pack
(
">I"
,
exec_id
)
# execution id
dataInt
=
int
(
time
.
time
()
*
1000
)
%
1000000000
data
=
struct
.
pack
(
">I"
,
dataInt
)
# data
function_count
=
struct
.
pack
(
"B"
,
function_count
)
# function count
function_id_packed
=
struct
.
pack
(
">I"
,
function_id
)
f0
=
struct
.
pack
(
"B"
,
f0
)
# f0
f1
=
struct
.
pack
(
"B"
,
f1
)
# f1
f2
=
struct
.
pack
(
"B"
,
f2
)
# f2 -> f0
f3
=
struct
.
pack
(
"B"
,
f3
)
# f3 -> f1 f2
f4
=
struct
.
pack
(
"B"
,
f4
)
# f4 -> f3
packet
=
chain_id
+
exec_id
+
function_id_packed
+
data
+
function_count
+
f0
+
f1
+
f2
+
f3
+
f4
# print dataInt, offload_status
return
packet
,
function_id
def
sendThread
(
start_time
,
runtime
,
sleep_time
):
global
ingress_time
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
while
True
:
packet
,
function_id
=
genPacket
()
if
time
.
time
()
-
start_time
>
runtime
:
break
s
.
sendto
(
packet
,
(
SERVER_IP
,
PORT
))
ingress_time
.
append
(
time
.
time
())
time
.
sleep
(
sleep_time
)
def
send
():
global
egress_time
,
ingress_time
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
print
"Sending packet to
%
s at port
%
s"
%
(
SERVER_IP
,
PORT
)
print
"chain id, exec id, data, function count, functions dependencies..."
# op = struct.unpack("B", packet[0])
packet
,
_
=
genPacket
()
if
args
.
n
is
not
None
:
for
i
in
range
(
args
.
req_count
):
s
.
sendto
(
packet
,
(
SERVER_IP
,
PORT
))
ingress_time
.
append
(
time
.
time
())
elif
args
.
rps
is
not
None
:
runtime
=
10
thread_count
=
args
.
c
start_time
=
time
.
time
()
sleep_time
=
thread_count
/
float
(
args
.
rps
)
print
"calculated inter-arrival time, offload mode"
,
sleep_time
for
i
in
range
(
thread_count
):
t
=
threading
.
Thread
(
target
=
sendThread
,
args
=
[
start_time
,
runtime
,
sleep_time
])
t
.
daemon
=
True
t
.
start
()
time
.
sleep
(
runtime
)
stop_thread
=
True
# s.sendto(packet, (SERVER_IP, PORT))
# r.join()
r
=
threading
.
Thread
(
name
=
"receive"
,
target
=
receive
)
r
.
daemon
=
True
r
.
start
()
time
.
sleep
(
1
)
send
()
r
.
join
()
dispatch_system/benchmark_dispatcher_receive.py
0 → 100644
View file @
0357774b
import
socket
import
struct
import
time
import
threading
import
random
import
time
import
numpy
as
np
import
argparse
import
signal
parser
=
argparse
.
ArgumentParser
(
description
=
'Mininet demo'
)
packet_holder
=
[
None
]
*
11
ingress_time
=
{}
stop_thread
=
False
runtime
=
10
def
receive
(
i
):
global
stop_thread
,
packet_holder
CLIENT_IP
=
"0.0.0.0"
port
=
10000
+
i
print
i
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
s
.
bind
((
CLIENT_IP
,
port
))
print
(
"listening to {} at port {}"
.
format
(
CLIENT_IP
,
port
))
run_status
=
{}
packet_holder
[
i
]
=
[]
while
True
:
if
stop_thread
:
break
packet
,
addr
=
s
.
recvfrom
(
1024
)
packet_holder
[
i
]
.
append
((
packet
,
time
.
time
()
))
# print "r", "{0:f}".format((time.time() * 1000)), "{0:f}".format(ingress_time[exec_id])
def
printStatistics
():
global
runtime
e2e_time
=
[]
for
packetThread
in
packet_holder
:
for
packetTuple
in
packetThread
:
packet
=
packetTuple
[
0
]
base
=
0
chain_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
base
+=
4
exec_id
=
struct
.
unpack
(
">I"
,
packet
[
base
:
base
+
4
])[
0
]
# e2e_time.append((packetTuple[1] - ingress_time[exec_id])* 1000)
# data = np.array(e2e_time, dtype=float)
# p50 = np.percentile(data, 50)
# p95 = np.percentile(data, 95)
# p99 = np.percentile(data, 99)
# mean = np.mean(data)
# print("mean \t p50 \t p95 \t p99")
# print(mean, p50, p95, p99)
print
(
"rps"
,
len
(
e2e_time
)
/
runtime
,
len
(
ingress_time
))
return
0
ri
=
[]
for
i
in
range
(
0
,
11
):
r
=
threading
.
Thread
(
name
=
"receive"
,
target
=
receive
,
args
=
[
i
])
r
.
daemon
=
True
r
.
start
()
ri
.
append
(
r
)
def
signal_handler
(
sig
,
frame
):
global
stop_thread
print
"sigint"
stop_thread
=
True
print
"here"
time
.
sleep
(
15
)
printStatistics
()
dispatch_system/constants.json
View file @
0357774b
...
...
@@ -4,7 +4,7 @@
"master_address"
:
"localhost"
,
"grunt_host"
:
"https://www.namandixit.net/lovecraftian_nightmares/grunt"
,
"couchdb_host"
:
"10.129.6.5:5984"
,
"env"
:
"env_
ud
p.js"
,
"env"
:
"env_
cp
p.js"
,
"db"
:
{
"function_meta"
:
"serverless"
,
"metrics"
:
"metrics"
,
...
...
@@ -15,10 +15,10 @@
"network_bridge"
:
"hybrid_kafka-serverless"
,
"use_bridge"
:
false
,
"internal"
:
{
"kafka_host"
:
"1
0.129.6.5
:9092"
"kafka_host"
:
"1
27.0.0.1
:9092"
},
"external"
:
{
"kafka_host"
:
"1
0.129.6.5:
9092"
"kafka_host"
:
"1
27.0.0.1:2
9092"
}
},
"topics"
:
{
...
...
dispatch_system/constants_local.json
View file @
0357774b
...
...
@@ -4,6 +4,7 @@
"master_address"
:
"localhost"
,
"grunt_host"
:
"https://www.namandixit.net/lovecraftian_nightmares/grunt"
,
"couchdb_host"
:
"localhost:5984"
,
"env"
:
"env_udp.js"
,
"db"
:
{
"function_meta"
:
"serverless"
,
"metrics"
:
"metrics"
,
...
...
@@ -11,13 +12,13 @@
"explicit_chain_meta"
:
"explicit_chain"
},
"network"
:
{
"network_bridge"
:
"
hybrid
_kafka-serverless"
,
"network_bridge"
:
"
xanadu
_kafka-serverless"
,
"use_bridge"
:
true
,
"internal"
:
{
"kafka_host"
:
"kafka:9092"
},
"external"
:
{
"kafka_host"
:
"
localhost:2
9092"
"kafka_host"
:
"
10.129.2.201:
9092"
}
},
"topics"
:
{
...
...
dispatch_system/dispatch_daemon/execute.js
View file @
0357774b
...
...
@@ -2,7 +2,7 @@
// const isolateBackend = require('./isolate')
const
fs
=
require
(
'
fs
'
)
const
{
spawn
}
=
require
(
'
child_process
'
);
const
constants
=
require
(
"
../constants.json
"
)
const
constants
=
require
(
"
../constants
_local
.json
"
)
const
libSupport
=
require
(
'
./lib
'
)
const
{
Worker
,
isMainThread
,
workerData
}
=
require
(
'
worker_threads
'
);
const
registry_url
=
constants
.
registry_url
...
...
@@ -38,6 +38,7 @@ function runIsolate(local_repository, metadata) {
}
function
runProcess
(
local_repository
,
metadata
)
{
console
.
log
(
"
inside run process :
"
,
metadata
,
local_repository
)
let
port
=
metadata
.
port
,
functionHash
=
metadata
.
functionHash
,
resource_id
=
metadata
.
resource_id
,
...
...
@@ -76,7 +77,7 @@ function runContainer(metadata) {
memory
=
metadata
.
resources
.
memory
logger
.
info
(
imageName
);
console
.
log
(
'
run contianer function :
'
,
metadata
,
imageName
,
port
,
resource_id
,
memory
)
return
new
Promise
((
resolve
,
reject
)
=>
{
let
timeStart
=
Date
.
now
()
...
...
@@ -111,7 +112,9 @@ function runContainer(metadata) {
logger
.
info
(
`stdout:
${
data
}
`
);
let
timeDifference
=
Math
.
ceil
((
Date
.
now
()
-
timeStart
))
logger
.
info
(
"
container run time taken:
"
,
timeDifference
);
let
add_network
=
spawn
(
'
docker
'
,
[
'
network
'
,
'
connect
'
,
'
pub_net
'
,
resource_id
])
// let add_network = spawn('docker', ['network', 'connect', 'pub_net', resource_id])
let
add_network
=
spawn
(
'
docker
'
,
[
'
network
'
,
'
connect
'
,
'
macvlantest
'
,
resource_id
])
let
_
=
spawn
(
'
docker
'
,
[
'
start
'
,
resource_id
])
_
.
on
(
'
data
'
,
(
data
)
=>
{
...
...
@@ -140,7 +143,8 @@ function runContainer(metadata) {
})
}
else
{
logger
.
info
(
"
container starting at port
"
,
port
);
logger
.
info
(
"
container starting at port
"
,
port
,
"
to check
"
);
console
.
log
(
port
,
"
no to check!!
"
)
let
process
=
null
;
/**
* create docker on the default bridge
...
...
@@ -162,7 +166,9 @@ function runContainer(metadata) {
/**
* attach smartnic interface
*/
let
add_network
=
spawn
(
'
docker
'
,
[
'
network
'
,
'
connect
'
,
'
pub_net
'
,
resource_id
])
// let add_network = spawn('docker', ['network', 'connect', 'pub_net', resource_id])
let
add_network
=
spawn
(
'
docker
'
,
[
'
network
'
,
'
connect
'
,
'
pub_net
'
,
resource_id
])
let
_
=
spawn
(
'
docker
'
,
[
'
start
'
,
resource_id
])
_
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
...
...
dispatch_system/dispatch_daemon/index.js
View file @
0357774b
'
use strict
'
;
const
constants
=
require
(
"
.././constants.json
"
)
const
constants
=
require
(
"
.././constants
_local
.json
"
)
const
secrets
=
require
(
'
./secrets.json
'
)
const
config
=
require
(
'
./config.json
'
)
const
libSupport
=
require
(
'
./lib
'
)
...
...
@@ -131,6 +131,7 @@ function startWorker(local_repository, producer, metadata) {
}],
()
=>
{
})
})
else
if
(
runtime
===
"
process
"
)
// console.log("rutime is process : ",metadata)
execute
.
runProcess
(
local_repository
,
metadata
)
.
catch
(
err
=>
{
logger
.
error
(
"
=====================deployment failed=========================
"
);
...
...
dispatch_system/dispatch_daemon/lib.js
View file @
0357774b
...
...
@@ -2,7 +2,7 @@ const fetch = require('node-fetch');
const
fs
=
require
(
'
fs
'
);
const
process
=
require
(
'
process
'
)
const
{
spawnSync
}
=
require
(
'
child_process
'
);
const
constants
=
require
(
"
.././constants.json
"
)
const
constants
=
require
(
"
.././constants
_local
.json
"
)
const
kafka
=
require
(
'
kafka-node
'
)
const
winston
=
require
(
'
winston
'
)
const
{
createLogger
,
format
,
transports
}
=
winston
;
...
...
@@ -24,6 +24,7 @@ function updateConfig() {
file
.
id
=
data
[
data
.
length
-
1
]
fs
.
writeFileSync
(
'
./config.json
'
,
JSON
.
stringify
(
file
));
console
.
log
(
"
Updated Config file
"
);
console
.
log
(
"
updateconfig file
"
,
file
)
}
function
makeTopic
(
id
)
{
...
...
dispatch_system/dispatch_manager/explicit_chain_handler.js
View file @
0357774b
...
...
@@ -5,7 +5,7 @@ const router = express.Router()
const
fs
=
require
(
'
fs
'
)
const
{
spawn
}
=
require
(
'
child_process
'
)
const
fetch
=
require
(
'
node-fetch
'
)
const
constants
=
require
(
'
../constants.json
'
)
const
constants
=
require
(
'
../constants
_local
.json
'
)
const
operator
=
require
(
'
./operator
'
)
const
sharedMeta
=
require
(
'
./shared_meta
'
)
const
util
=
require
(
'
util
'
)
...
...
dispatch_system/dispatch_manager/index.js
View file @
0357774b
...
...
@@ -2,7 +2,7 @@
const
express
=
require
(
'
express
'
);
const
fileUpload
=
require
(
'
express-fileupload
'
);
const
constants
=
require
(
'
.././constants.json
'
);
const
constants
=
require
(
'
.././constants
_local
.json
'
);
const
chainHandler
=
require
(
'
./explicit_chain_handler
'
);
const
secrets
=
require
(
'
./secrets.json
'
);
const
fs
=
require
(
'
fs
'
);
...
...
@@ -14,7 +14,7 @@ const fetch = require('node-fetch');
// const apiSpec = require('./swagger.json');
const
util
=
require
(
'
util
'
)
const
sharedMeta
=
require
(
'
./shared_meta
'
)
var
bodyParser
=
require
(
'
body-parser
'
);
// newcode
const
app
=
express
()
const
libSupport
=
require
(
'
./lib
'
)
...
...
@@ -58,7 +58,11 @@ app.use(morgan('combined', {
skip
:
function
(
req
,
res
)
{
return
res
.
statusCode
<
400
}
}))
app
.
use
(
express
.
json
());
app
.
use
(
express
.
urlencoded
({
extended
:
true
}));
//app.use(express.bodyParser());//newcode
//app.use(express.urlencoded({ extended: true }));//com
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
false
}));
//newcode
app
.
use
(
bodyParser
.
json
());
//newcode
const
file_path
=
__dirname
+
"
/repository/
"
app
.
use
(
'
/repository
'
,
express
.
static
(
file_path
));
// file server hosting deployed functions
app
.
use
(
fileUpload
())
...
...
@@ -79,11 +83,17 @@ app.get('/metrics', (req, res) => {
* REST API to receive deployment requests
*/
app
.
post
(
'
/serverless/deploy
'
,
(
req
,
res
)
=>
{
console
.
log
(
"
req =
"
+
req
+
"
**
"
+
req
.
body
.
runtime
+
"
**
"
+
req
.
body
.
serverless
,
req
.
files
,
req
.
files
.
serverless
)
//newcode
console
.
log
(
"
res =
"
+
res
)
//newcode
// console.log("req json = "+JSON.parse(req)) //newcode
console
.
log
(
"
baseurl :
"
,
req
.
baseUrl
)
console
.
log
(
'
Request URL:
'
,
req
.
originalUrl
)
let
runtime
=
req
.
body
.
runtime
let
file
=
req
.
files
.
serverless
console
.
log
(
"
req =
"
+
req
)
let
functionHash
=
file
.
md5
console
.
log
(
"
filepath:
"
,
file_path
,
"
hash:
"
,
functionHash
)
file
.
mv
(
file_path
+
functionHash
,
function
(
err
)
{
// move function file to repository
functionHash
=
libSupport
.
generateExecutor
(
file_path
,
functionHash
)
...
...
@@ -157,12 +167,16 @@ function deployContainer(path, imageName) {
/**
* Generating dockerfile for the received function
*/
let
environmentCopy
=
""
if
(
constants
.
env
===
"
env_cpp.js
"
)
environmentCopy
=
"
COPY ./worker_env/server /app
"
fs
.
writeFile
(
'
./repository/Dockerfile
'
,
`FROM node:latest
WORKDIR /app
COPY ./worker_env/package.json /app
ADD ./worker_env/node_modules /app/node_modules
COPY
${
imageName
}
.js /app
${
environmentCopy
}
ENTRYPOINT ["node", "
${
imageName
}
.js"]`
,
function
(
err
)
{
if
(
err
)
{
...
...
@@ -214,16 +228,18 @@ function deployContainer(path, imageName) {
* REST API to receive execute requests
*/
app
.
post
(
'
/serverless/execute/:id
'
,
(
req
,
res
)
=>
{
console
.
log
(
"
executing called
"
,
req
.
params
.
id
,
req
.
body
.
runtime
)
let
runtime
=
req
.
body
.
runtime
let
id
=
req
.
params
.
id
+
runtime
res
.
timestamp
=
Date
.
now
()
if
(
functionToResource
.
has
(
id
))
{
res
.
start
=
'
warmstart
'
console
.
log
(
'
warmstart
'
)
res
.
dispatch_time
=
Date
.
now
()
libSupport
.
reverseProxy
(
req
,
res
)
}
else
{
res
.
start
=
'
coldstart
'
console
.
log
(
'
coldstart
'
)
/**
* Requests are queued up before being dispatched. To prevent requests coming in for the
* same function from starting too many workers, they are grouped together
...
...
dispatch_system/dispatch_manager/lib.js
View file @
0357774b
...
...
@@ -4,7 +4,7 @@ const fs = require('fs')
const
rp
=
require
(
'
request-promise
'
);
const
fetch
=
require
(
'
node-fetch
'
);
const
winston
=
require
(
'
winston
'
)
const
constants
=
require
(
'
.././constants.json
'
)
const
constants
=
require
(
'
.././constants
_local
.json
'
)
const
secrets
=
require
(
'
./secrets.json
'
)
const
metrics
=
require
(
'
./metrics
'
)
const
sharedMeta
=
require
(
'
./shared_meta
'
)
...
...
@@ -77,6 +77,7 @@ function generateExecutor(functionPath, functionHash) {