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
b2c1fd1c
Commit
b2c1fd1c
authored
Apr 27, 2022
by
kedar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test script
parent
654c03a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
270 additions
and
0 deletions
+270
-0
testfiles/send_coldstart.py
testfiles/send_coldstart.py
+189
-0
testfiles/test_setup.sh
testfiles/test_setup.sh
+81
-0
No files found.
testfiles/send_coldstart.py
0 → 100644
View file @
b2c1fd1c
import
socket
import
struct
import
time
import
threading
import
random
import
time
import
numpy
as
np
import
argparse
import
csv
import
json
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
(
'--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"
)
group
.
add_argument
(
'--n'
,
help
=
'Number of requests to send'
,
type
=
int
,
action
=
"store"
)
args
=
parser
.
parse_args
()
# fids_file = open("fids.json")
# fids = json.loads(fids_file)
# console.log("fids : ", fids)
PORT
=
8000
dataInt
=
0
fid
=
args
.
fid
runtime
=
args
.
t
concurrency
=
args
.
c
SERVER_IP
=
"192.168.210.10"
# packet_holder = [None] * 11
packet_holder
=
[[]
for
i
in
range
(
12
)]
ingress_time
=
{}
stop_thread
=
False
fids
=
[]
with
open
(
'fids.txt'
)
as
f
:
lines
=
f
.
readlines
()
# fids.append(lines.split('\n')[0])
for
line
in
lines
:
fids
.
append
(
int
(
line
.
split
(
'
\n
'
)[
0
]))
print
(
fids
)
# 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.setblocking(0)
# s.bind((CLIENT_IP, port))
# # s.setblocking(0)
# print("listening to {} at port {}".format(CLIENT_IP, port))
# run_status = {}
# packet_holder[i] = []
# while True:
# if stop_thread:
# print "stop thread r"
# break
# packet, addr = s.recvfrom(1024)
# #print "packet received : ", packet
# packet_holder[i].append((packet, time.time() ))
# # print "r", "{0:f}".format((time.time() * 1000)), "{0:f}".format(ingress_time[exec_id])
def
genPacket
(
fid
):
# global fid
packet
=
None
exec_id
=
random
.
randint
(
0
,
2
**
30
)
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_packed
=
struct
.
pack
(
">I"
,
exec_id
)
# execution id
dataInt
=
1
# print " dataInt", dataInt
data
=
struct
.
pack
(
">I"
,
dataInt
)
# data
function_count
=
struct
.
pack
(
"B"
,
function_count
)
# function count
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_packed
+
function_id
+
data
+
function_count
+
f0
+
f1
+
f2
+
f3
+
f4
# print dataInt, offload_status
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
:
if
time
.
time
()
-
start_time
>
runtime
:
break
packet
,
exec_id
=
genPacket
()
if
exec_id
in
ingress_time
:
continue
s
.
sendro
(
packet
,
(
SERVER_IP
,
PORT
))
ingress_time
[
exec_id
]
=
time
.
time
()
time
.
sleep
(
sleep_time
)
def
send
():
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
(
"Runtime:
%
d Concurrency
%
d"
%
(
runtime
,
concurrency
))
print
(
"chain id, exec id, data, function count, functions dependencies..."
)
# op = struct.unpack("B", packet[0])
print
(
"server IP "
,
SERVER_IP
,
PORT
)
if
args
.
n
is
not
None
:
for
i
in
range
(
args
.
n
):
packet
,
exec_id
=
genPacket
(
fids
[
i
])
s
.
sendto
(
packet
,
(
SERVER_IP
,
PORT
))
ingress_time
[
exec_id
]
=
time
.
time
()
*
1000
print
(
"send"
,
"{0:f}"
.
format
(
ingress_time
[
exec_id
]))
elif
args
.
rps
is
not
None
:
start_time
=
time
.
time
()
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
t
.
start
()
time
.
sleep
(
runtime
)
print
"stoppping thread"
stop_thread
=
True
print
"thread stopped"
# s.sendto(packet, (SERVER_IP, PORT))
# r.join()
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
)
np
.
savetxt
(
"bm_static_1.csv"
,
data
,
delimiter
=
' '
,
header
=
''
)
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
)
fields
=
[
args
.
rps
,
mean
,
len
(
e2e_time
)
/
runtime
,
len
(
ingress_time
),
p50
,
p95
,
p99
]
with
open
(
'speedo_data_static2_1f_host.csv'
,
'a'
)
as
f
:
writer
=
csv
.
writer
(
f
)
writer
.
writerow
(
fields
)
print
(
"rps"
,
len
(
e2e_time
)
/
runtime
,
len
(
ingress_time
))
return
0
time
.
sleep
(
1
)
send
()
testfiles/test_setup.sh
0 → 100755
View file @
b2c1fd1c
#! /bin/bash -ex
echo
$1
,
$2
deploy_flag
=
0
req_flag
=
0
rm_flag
=
0
while
getopts
'snd'
flag
;
do
case
"
${
flag
}
"
in
s
)
deploy_flag
=
1
;;
n
)
req_flag
=
1
;;
d
)
rm_flag
=
1
;;
esac
done
# echo $1, $2, $3
if
[[
$deploy_flag
-eq
1
]]
then
i
=
0
for
((
i
=
1
;
$i
<
=
$2
;
i++
))
do
echo
"console.log('running test
$i
')"
>
"testjs"
$i
".js"
done
for
((
i
=
1
;
$i
<
=
$2
;
i++
))
do
curl
-X
POST http://10.129.2.182:8082/serverless/deploy
-F
runtime
=
container
-F
serverless
=
"@/home/ub-01/mahendra/xanadu_coldstart/testfiles/testjs"
$i
".js"
-F
nicfunction
=
@/home/ub-01/mahendra/xanadu_coldstart/testfiles/test5nic.c
>>
curl_output.txt
echo
"
\n
"
>>
curl_output.txt
done
cat
curl_output.txt |
awk
'{ print substr( $0, 84 ) }'
|
grep
[
0-9]
*
-o
>>
fids.txt
cnt
=
1
echo
"{'fids':["
>>
fids.json
while
IFS
=
""
read
-r
p
||
[
-n
"
$p
"
]
do
# printf '%s\n' "$p"
# sudo ip netns exec ns_server python benchmark_dispatcher.py --fid $p --c 50 --t 100 --n 1
echo
$p
" , "
>>
fids.json
done
< fids.txt
echo
"]}"
>>
fids.json
fi
# ####
if
[[
$req_flag
-eq
1
]]
then
sudo
ip netns
exec
ns_server python send_coldstart.py
--c
1
--t
2
--n
$2
# python send_coldstart.py --c 1 --t 2 --n $2
fi
if
[[
$rm_flag
-eq
1
]]
then
rm
-f
curl_output.txt fids.txt
fi
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test1.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test2.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test3.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test4.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test5.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test6.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test7.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test8.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test9.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
# echo "\n" >> curl_output.txt
# curl -X POST http://localhost:8080/serverless/deploy -F runtime=container -F serverless=@/home/pcube/mahendra/speedo_basic_coldstart/xanadu/testfiles/test10.js -F nicfunction=@/home/pcube/nilanjan/xanadu/testfiles/test5nic.c >> curl_output.txt
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