Skip to content
Snippets Groups Projects
Commit 0c6ecad2 authored by Maël Madon's avatar Maël Madon
Browse files

dev: change < to <= for the threshold and adapt related tests

parent 950f51ac
Branches
Tags
No related merge requests found
%% Cell type:markdown id: tags:
# Visualization of session graphs
### Initializing libs and vars
%% Cell type:code id: tags:
``` python
import networkx as nx
KTH_WL = 'workloads/KTH-SP2-1996-2.1-cln.swf'
example_WL = 'workloads/example.swf'
```
%% Cell type:markdown id: tags:
### Example workload
Let's run the session decomposition of our simple example with the option `--graph`. Delimitation approach: Arrival with theshold of 60 minutes.
%% Cell type:code id: tags:
``` python
out_dir = "out/example_arrival_t60"
!mkdir -p {out_dir}
!./swf2userSessions.py -a 60 --graph {example_WL} {out_dir}
```
%% Output
SWF parsing done.
Number of users: 1
Number of sessions: 4
The output files have been stored in the folder out/example_arrival_t60
%% Cell type:markdown id: tags:
Now let's visualize the graph output:
%% Cell type:code id: tags:
``` python
G = nx.read_gml(f"{out_dir}/graphs/1.gml")
nx.draw_networkx(G, pos=nx.planar_layout(G))
```
%% Output
%% Cell type:markdown id: tags:
With another value for the threshold:
*Note: a threshold of 0 with the Arrival delimitation method will populate only sessions containing jobs submitted at the same time (so most likely only single-job sessions)*
*Note: a threshold of 0 with the Arrival delimitation method will populate only single-job sessions*
%% Cell type:code id: tags:
``` python
out_dir = "out/example_arrival_t0"
!mkdir -p {out_dir}
!./swf2userSessions.py -a 0 --graph --quiet {example_WL} {out_dir}
G = nx.read_gml(f"{out_dir}/graphs/1.gml")
nx.draw_networkx(G, pos=nx.planar_layout(G))
```
%% Output
%% Cell type:markdown id: tags:
With the Max delimitation approach (and still a threshold of 0):
%% Cell type:code id: tags:
``` python
out_dir = "out/example_max_t0"
!mkdir -p {out_dir}
!./swf2userSessions.py -m 0 --graph --quiet {example_WL} {out_dir}
G = nx.read_gml(f"{out_dir}/graphs/1.gml")
nx.draw_networkx(G, pos=nx.planar_layout(G))
```
%% Output
%% Cell type:markdown id: tags:
### Dynamic reduction
Let's see how the graph would look without dynamic reduction.
%% Cell type:code id: tags:
``` python
# Without dynamic reduction
out_dir = "out/example_arrival_t0_nodyn"
!mkdir -p {out_dir}
!./swf2userSessions.py -a 0 --graph --quiet --no_dynamic_reduction {example_WL} {out_dir}
G_nodyn = nx.read_gml(f"{out_dir}/graphs/1.gml")
nx.draw_networkx(G_nodyn, pos=nx.circular_layout(G_nodyn))
```
%% Output
%% Cell type:code id: tags:
``` python
# For comparison: with dynamic reduction (circular layout)
nx.draw_circular(nx.read_gml(f"out/example_arrival_t0/graphs/1.gml"))
```
%% Output
%% Cell type:markdown id: tags:
*Note: running the script with the option `--no_dynamic_reduction` becomes quickly impossible to handle. For example with the KTH SWF workload which is only 2.6MB, it produces already 585MB of output!!*
......
......@@ -50,15 +50,15 @@ class User:
if self.delim_approach == 'arrival':
inter_arrival_time = date_now - self.__last_submit_time
return (inter_arrival_time > self.delim_threshold)
return (inter_arrival_time >= self.delim_threshold)
elif self.delim_approach == 'last':
think_time = date_now - self.__last_finish_time
return (think_time > self.delim_threshold)
return (think_time >= self.delim_threshold)
else: # 'max' delimitation approach
think_time = date_now - self.__max_finish_time
return (think_time > self.delim_threshold)
return (think_time >= self.delim_threshold)
def __sessions_finished_at_time(self, t):
"""Return the list of session that were finished at time t"""
......@@ -92,7 +92,7 @@ class User:
for s_id in self.__sessions_in_progress.copy():
sess = self.sessions[s_id]
if date_now > sess.max_finish_time: # ie sess is finished
if date_now >= sess.max_finish_time: # ie sess is finished
self.__sessions_in_progress.discard(s_id)
self.__current_dep = self.__current_dep - set(
sess.preceding_sessions)
......
......@@ -36,9 +36,9 @@
},
{
"id": 3,
"first_submit_time": 2001.0,
"first_submit_time": 2000.0,
"preceding_sessions": [1],
"thinking_time_after_preceding_session": [1001],
"thinking_time_after_preceding_session": [1000],
"nb_jobs": 1,
"jobs": [
{
......@@ -52,9 +52,9 @@
},
{
"id": 4,
"first_submit_time": 2002.0,
"first_submit_time": 2000.0,
"preceding_sessions": [1],
"thinking_time_after_preceding_session": [1002],
"thinking_time_after_preceding_session": [1000],
"nb_jobs": 1,
"jobs": [
{
......@@ -68,9 +68,9 @@
},
{
"id": 5,
"first_submit_time": 2003.0,
"first_submit_time": 2000.0,
"preceding_sessions": [1],
"thinking_time_after_preceding_session": [1003],
"thinking_time_after_preceding_session": [1000],
"nb_jobs": 1,
"jobs": [
{
......
{
"description": "A session (session 6) depends on five others, with a think time of 1000s. Slightly different than batmen version.",
"description": "A session (session 6) depends on five others, with a think time of 1000s.",
"nb_res": 16,
"sessions": [
{
......@@ -20,14 +20,14 @@
},
{
"id": 2,
"first_submit_time": 1001.0,
"first_submit_time": 1000.0,
"preceding_sessions": [],
"thinking_time_after_preceding_session": [],
"nb_jobs": 1,
"jobs": [
{
"id": 2,
"profile": "1500",
"profile": "2000",
"res": 16,
"subtime": 0.0,
"walltime": 2592000.0
......@@ -36,7 +36,7 @@
},
{
"id": 3,
"first_submit_time": 1002.0,
"first_submit_time": 1000.0,
"preceding_sessions": [],
"thinking_time_after_preceding_session": [],
"nb_jobs": 1,
......
......@@ -41,10 +41,10 @@ def SABjson_sanity_check(SABjson_file, arrival_threshold=None):
if arrival_threshold is not None and previous_job_subtime != -1:
interrarrival = job_sub_time - previous_job_subtime
if job == session["jobs"][0]:
assert interrarrival > arrival_threshold * 60, f"Session {s_id} was started but the interrarrival time was not suffisiant"
assert interrarrival >= arrival_threshold * 60, f"Session {s_id} was started but the interrarrival time was not suffisiant"
else:
job_id = job["id"]
assert interrarrival <= arrival_threshold * 60, f"Job {job_id} in session {s_id} should be in a new session"
assert interrarrival < arrival_threshold * 60, f"Job {job_id} in session {s_id} should be in a new session"
s_id += 1
fd.close()
......
......@@ -3,7 +3,7 @@
1 0 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
2 2000 0 2000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
3 2001 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
4 2002 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
5 2003 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
3 2000 50 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
4 2000 50 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
5 2000 50 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
6 3000 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
......@@ -2,8 +2,8 @@
; Expected to produce many_preceding.SABjson with arrival_t0
1 1000 1000 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
2 1001 499 1500 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
3 1002 998 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
2 1000 0 2000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
3 1000 1000 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
4 1500 500 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
5 2000 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
6 4000 0 1000 16 -1 -1 16 2592000 -1 1 1 1 -1 -1 -1 -1 -1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment