Skip to content

Commit ca91453

Browse files
authored
Merge pull request #24 from Elliotkim2/main
Adds throughput and chaining tests for C API and Seveless
2 parents 14e4caf + 0dad4bb commit ca91453

File tree

5 files changed

+168
-10
lines changed

5 files changed

+168
-10
lines changed

.github/workflows/daily.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ jobs:
7777
uses: actions/checkout@v3
7878
- name: Test Vine Serverless Mode
7979
run: ./test-vine-serverless.sh
80-
80+
8181
parrot-cvmfs-job:
8282
runs-on: ubuntu-20.04
8383
timeout-minutes: 10
@@ -96,6 +96,23 @@ jobs:
9696
- name: Test TopEFT + Work Queue
9797
run: ./test-topeft.sh
9898

99+
vine-task-throughput:
100+
runs-on: ubuntu-20.04
101+
timeout-minutes: 20
102+
steps:
103+
- name: Checkout
104+
uses: actions/checkout@v3
105+
- name: Test Vine Throughput
106+
run: ./test-vine-task-throughput.sh
107+
108+
vine-throughput-capi-job:
109+
runs-on: ubuntu-20.04
110+
timeout-minutes: 20
111+
steps:
112+
- name: Checkout
113+
uses: actions/checkout@v3
114+
- name: Test Vine Throughput Test C API
115+
run: ./test-vine-task-throughput-capi.sh
99116
# Removed plain coffea test 7/24/2023 to replace with coffea-dask-taskvine when ready.
100117
# coffea-job:
101118
# runs-on: ubuntu-20.04

test-vine-task-throughput-capi.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
#!/bin/sh
3+
4+
# Build the sources from github
5+
. ./install-github.sh
6+
7+
# Compile C API test using environment
8+
gcc test-vine-task-throughput.c -o test-vine-task-throughput -I $PREFIX/include/cctools/ -L $PREFIX/lib -ltaskvine -ldttools -lm -lcrypto -lssl -lz
9+
10+
./test-vine-task-throughput &
11+
12+
vine_worker localhost 9123 --single-shot

test-vine-task-throughput.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#include "taskvine.h"
2+
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
#include <errno.h>
7+
#include <unistd.h>
8+
#include <time.h>
9+
#include <assert.h>
10+
int main(int argc, char *argv[])
11+
{
12+
struct vine_manager *m;
13+
int i;
14+
int tasksC = 5000;
15+
16+
m = vine_create(VINE_DEFAULT_PORT);
17+
18+
if(!m) {
19+
printf("couldn't create manager: %s\n", strerror(errno));
20+
return 1;
21+
}
22+
printf("TaskVine listening on %d\n", vine_port(m));
23+
24+
for(i=0;i<tasksC;i++) {
25+
struct vine_task *t = vine_task_create(":");
26+
vine_task_set_cores(t, 1);
27+
28+
int task_id = vine_submit(m, t);
29+
30+
}
31+
bool start_timer = true;
32+
clock_t start = 0;
33+
while(!vine_empty(m)) {
34+
struct vine_task *t = vine_wait(m, 5);
35+
if (start_timer){
36+
start = clock();
37+
start_timer = false;
38+
}
39+
if(t) {
40+
vine_task_delete(t);
41+
}
42+
}
43+
clock_t end = clock();
44+
double throughtput_time = ((double)(end - start)) / CLOCKS_PER_SEC;
45+
46+
double throughput = tasksC / throughtput_time;
47+
48+
start_timer = true;
49+
start = 0;
50+
for(i=0;i<tasksC;i++) {
51+
struct vine_task *t = vine_task_create(":");
52+
vine_task_set_cores(t, 1);
53+
if (start_timer){
54+
start = clock();
55+
start_timer = false;
56+
}
57+
int task_id = vine_submit(m, t);
58+
while(!vine_empty(m)) {
59+
t = vine_wait(m, 5);
60+
if(t) {
61+
vine_task_delete(t);
62+
}
63+
}
64+
}
65+
end = clock();
66+
double chaining_time = ((double)(end - start)) / CLOCKS_PER_SEC;
67+
double chaining = tasksC / chaining_time;
68+
69+
printf("Throughput was %f tasks per second\n", throughput);
70+
printf("Chaining was %f tasks per second\n", chaining);
71+
printf("all tasks complete!\n");
72+
vine_delete(m);
73+
74+
return 0;
75+
}

test-vine-task-throughput.py

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22

33
import ndcctools.taskvine as vine
44
import time
5+
import sys
56

6-
if __name__ == "__main__":
7+
def func():
8+
return
9+
10+
def main():
711

812
q = vine.Manager()
13+
print("Creating Library from functions...")
14+
function_lib = q.create_library_from_functions('test-library', func, add_env=False)
15+
q.install_library(function_lib)
16+
917
print("listening on port", q.port)
1018
factory = vine.Factory("local",manager_host_port="localhost:{}".format(q.port))
1119
factory.max_workers=1
1220
factory.min_workers=1
13-
factory.disk = 100
1421

1522
num_tasks = 1000
1623

@@ -29,11 +36,58 @@
2936
start = time.time()
3037
start_timer = False
3138

32-
end = time.time()
33-
e = end-start
34-
print(f"It took {e} seconds\n")
35-
print(f"Throughput was {num_tasks/e} tasks per second")
36-
print("all tasks complete!")
39+
end = time.time()
40+
many = end - start
41+
42+
start = time.time()
43+
44+
for i in range(num_tasks):
45+
while not q.empty():
46+
result = q.wait(5)
47+
t = vine.Task(command=":")
48+
task_id = q.submit(t)
49+
50+
print("waiting for tasks to complete...")
51+
end = time.time()
52+
one = end - start
53+
throughput = num_tasks/many
54+
chaining = num_tasks/one
55+
#serverless tasks
56+
for i in range (num_tasks):
57+
t = vine.FunctionCall('test-library', 'func')
58+
task_id = q.submit(t)
59+
60+
print("Waiting for tasks to complete...")
61+
start_timer = True
62+
while not q.empty():
63+
t = q.wait(5)
64+
if start_timer:
65+
start = time.time()
66+
start_timer = False
67+
end = time.time()
68+
serverless_many = end - start
69+
70+
start = time.time()
71+
for i in range(num_tasks):
72+
while not q.empty():
73+
result = q.wait(5)
74+
t = vine.FunctionCall('test-library', 'func')
75+
task_id = q.submit(t)
76+
end = time.time()
77+
serverless_one = end-start
78+
serverless_throughput = num_tasks/serverless_many
79+
serverless_chaining = num_tasks/serverless_one
80+
3781

82+
print(f"\nThroughput was {throughput} tasks per second")
83+
print(f"Chaining was {chaining} tasks per second")
84+
print(f"Serverless Throughput was {serverless_throughput} tasks per second")
85+
print(f"Serverless Chaining was {serverless_chaining} tasks per second")
86+
print("all tasks complete!")
87+
88+
89+
if __name__ == '__main__':
90+
main()
91+
3892
# vim: set sts=4 sw=4 ts=4 expandtab ft=python:
3993

test-vine-task-throughput.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
# Install conda development environment
77
. ./install-github.sh
88

9-
# Run the serverless test case.
10-
python3 test-vine-task-throughput.py
9+
# Run the test case.
10+
python test-vine-task-throughput.py

0 commit comments

Comments
 (0)