Skip to content

Commit 93bad08

Browse files
committed
wb | allow having workloads that start before the nodes
1 parent 57e228c commit 93bad08

File tree

11 files changed

+75
-56
lines changed

11 files changed

+75
-56
lines changed

bench/cardano-profile/data/all-profiles-coay.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46223,6 +46223,7 @@
4622346223
},
4622446224
"name": "latency",
4622546225
"parameters": {},
46226+
"before_nodes": false,
4622646227
"wait_pools": false
4622746228
}
4622846229
]
@@ -46866,6 +46867,7 @@
4686646867
},
4686746868
"name": "latency",
4686846869
"parameters": {},
46870+
"before_nodes": false,
4686946871
"wait_pools": false
4687046872
}
4687146873
]
@@ -63098,6 +63100,7 @@
6309863100
"submit_vote": true,
6309963101
"votes_per_tx": 2
6310063102
},
63103+
"before_nodes": false,
6310163104
"wait_pools": true
6310263105
}
6310363106
]
@@ -64052,6 +64055,7 @@
6405264055
"outs_per_split_transaction": 193,
6405364056
"submit_vote": false
6405464057
},
64058+
"before_nodes": false,
6405564059
"wait_pools": true
6405664060
}
6405764061
]
@@ -65007,6 +65011,7 @@
6500765011
"submit_vote": true,
6500865012
"votes_per_tx": 1
6500965013
},
65014+
"before_nodes": false,
6501065015
"wait_pools": true
6501165016
}
6501265017
]
@@ -90532,6 +90537,7 @@
9053290537
"pre_generator": null,
9053390538
"producers": "cgroup_memory"
9053490539
},
90540+
"before_nodes": true,
9053590541
"wait_pools": true
9053690542
}
9053790543
]
@@ -91421,6 +91427,7 @@
9142191427
"pre_generator": null,
9142291428
"producers": "cgroup_memory"
9142391429
},
91430+
"before_nodes": true,
9142491431
"wait_pools": true
9142591432
}
9142691433
]
@@ -94983,6 +94990,7 @@
9498394990
"submit_vote": true,
9498494991
"votes_per_tx": 2
9498594992
},
94993+
"before_nodes": false,
9498694994
"wait_pools": true
9498794995
}
9498894996
]
@@ -95934,6 +95942,7 @@
9593495942
"outs_per_split_transaction": 193,
9593595943
"submit_vote": false
9593695944
},
95945+
"before_nodes": false,
9593795946
"wait_pools": true
9593895947
}
9593995948
]
@@ -96886,6 +96895,7 @@
9688696895
"submit_vote": true,
9688796896
"votes_per_tx": 1
9688896897
},
96898+
"before_nodes": false,
9688996899
"wait_pools": true
9689096900
}
9689196901
]

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Types.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ data Workload = Workload
557557
{ workloadName :: String
558558
, parameters :: Aeson.Object
559559
, entrypoints :: Entrypoints
560+
, before_nodes :: Bool
560561
, wait_pools :: Bool
561562
}
562563
deriving (Eq, Show, Generic)
@@ -570,10 +571,11 @@ data Entrypoints = Entrypoints
570571
instance Aeson.ToJSON Workload where
571572
toJSON p =
572573
Aeson.object
573-
[ "name" Aeson..= workloadName p
574-
, "parameters" Aeson..= parameters p
575-
, "entrypoints" Aeson..= entrypoints p
576-
, "wait_pools" Aeson..= wait_pools p
574+
[ "name" Aeson..= workloadName p
575+
, "parameters" Aeson..= parameters p
576+
, "entrypoints" Aeson..= entrypoints p
577+
, "before_nodes" Aeson..= before_nodes p
578+
, "wait_pools" Aeson..= wait_pools p
577579
]
578580

579581
instance Aeson.FromJSON Workload where
@@ -583,6 +585,7 @@ instance Aeson.FromJSON Workload where
583585
<$> o Aeson..: "name"
584586
<*> o Aeson..: "parameters"
585587
<*> o Aeson..: "entrypoints"
588+
<*> o Aeson..: "before_nodes"
586589
<*> o Aeson..: "wait_pools"
587590

588591
instance Aeson.ToJSON Entrypoints

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Workload/CGroupMemory.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ cgroupMemoryWorkload = Types.Workload {
2323
Types.pre_generator = Nothing
2424
, Types.producers = "cgroup_memory"
2525
}
26+
, Types.before_nodes = True
2627
, Types.wait_pools = True
2728
}

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Workload/Latency.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ latencyWorkload = Types.Workload {
2323
Types.pre_generator = Nothing
2424
, Types.producers = "latency"
2525
}
26+
, Types.before_nodes = False
2627
, Types.wait_pools = False
2728
}

bench/cardano-profile/src/Cardano/Benchmarking/Profile/Workload/Voting.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ votingWorkload parameters = Types.Workload {
2626
Types.pre_generator = Just "workflow_generator"
2727
, Types.producers = "workflow_producer"
2828
}
29+
, Types.before_nodes = False
2930
, Types.wait_pools = True
3031
}
3132

nix/workbench/backend/backend.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ case "${op}" in
5252
start-tracers ) backend_$WB_BACKEND "$@";;
5353
start-nodes ) backend_$WB_BACKEND "$@";;
5454
start-generator ) backend_$WB_BACKEND "$@";;
55-
start-workloads ) backend_$WB_BACKEND "$@";;
55+
start-workload-by-name ) backend_$WB_BACKEND "$@";;
5656
start-healthchecks ) backend_$WB_BACKEND "$@";;
5757
# Fine grained
5858
start-node ) backend_$WB_BACKEND "$@";;

nix/workbench/backend/nomad.sh

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,10 +1527,10 @@ backend_nomad() {
15271527

15281528
############################################################################
15291529
# Functions to start/stop groups of cluster "programs":
1530-
# - start-tracers RUN-DIR
1531-
# - start-nodes RUN-DIR
1532-
# - start-workloads RUN-DIR
1533-
# - start-healthchecks RUN-DIR
1530+
# - start-tracers RUN-DIR
1531+
# - start-nodes RUN-DIR
1532+
# - start-workload-by-name RUN-DIR
1533+
# - start-healthchecks RUN-DIR
15341534
############################################################################
15351535
# * Functions in the backend "interface" must use `fatal` when errors!
15361536

@@ -1640,39 +1640,36 @@ backend_nomad() {
16401640
;;
16411641

16421642
# Called by `scenario.sh` with the exit trap (`scenario_setup_exit_trap`) set!
1643-
start-workloads )
1644-
local usage="USAGE: wb backend $op RUN-DIR"
1643+
start-workload-by-name )
1644+
local usage="USAGE: wb backend $op RUN-DIR WORKLOAD-NAME"
16451645
local dir=${1:?$usage}; shift
1646+
local workload=${1:?$usage}; shift
16461647

1647-
# For every workload
1648-
for workload in $(jq_tolist '.workloads | map(.name)' "$dir"/profile.json)
1648+
local jobs_array=()
1649+
# Workload may or may not run something in all producers.
1650+
local nodes=($(jq_tolist 'map(select(.isProducer) | .name)' "$dir"/node-specs.json))
1651+
for node in ${nodes[*]}
16491652
do
1650-
local jobs_array=()
1651-
# Workload may or may not run something in all producers.
1652-
local nodes=($(jq_tolist 'map(select(.isProducer) | .name)' "$dir"/node-specs.json))
1653-
for node in ${nodes[*]}
1654-
do
1655-
backend_nomad start-workload "${dir}" "${workload}" "${node}" &
1656-
jobs_array+=("$!")
1657-
done
1658-
# Wait and check!
1659-
if test -n "${jobs_array}"
1653+
backend_nomad start-workload "${dir}" "${workload}" "${node}" &
1654+
jobs_array+=("$!")
1655+
done
1656+
# Wait and check!
1657+
if test -n "${jobs_array}"
1658+
then
1659+
if ! wait_kill_em_all "${jobs_array[@]}"
16601660
then
1661-
if ! wait_kill_em_all "${jobs_array[@]}"
1662-
then
1663-
fatal "Failed to start workload(s)"
1664-
return 1
1665-
else
1666-
for node in ${nodes[*]}
1667-
do
1668-
if ! test -f "${dir}"/workloads/"${workload}"/"${node}"/started
1669-
then
1670-
fatal "Workload \"${workload}\" for \"${node}\" failed to start!"
1671-
fi
1672-
done
1673-
fi
1661+
fatal "Failed to start workload(s)"
1662+
return 1
1663+
else
1664+
for node in ${nodes[*]}
1665+
do
1666+
if ! test -f "${dir}"/workloads/"${workload}"/"${node}"/started
1667+
then
1668+
fatal "Workload \"${workload}\" for \"${node}\" failed to start!"
1669+
fi
1670+
done
16741671
fi
1675-
done
1672+
fi
16761673
return 0
16771674
;;
16781675

nix/workbench/backend/nomad/cloud.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ backend_nomadcloud() {
146146
backend_nomad start-generator "$@"
147147
;;
148148

149-
start-workloads )
150-
backend_nomad start-workloads "$@"
149+
start-workload-by-name )
150+
backend_nomad start-workload-by-name "$@"
151151
;;
152152

153153
start-healthchecks )

nix/workbench/backend/nomad/exec.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ backend_nomadexec() {
107107
backend_nomad start-generator "$@"
108108
;;
109109

110-
start-workloads )
111-
backend_nomad start-workloads "$@"
110+
start-workload-by-name )
111+
backend_nomad start-workload-by-name "$@"
112112
;;
113113

114114
start-healthchecks )

nix/workbench/backend/supervisor.sh

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,28 +300,25 @@ EOF
300300
fi
301301
backend_supervisor save-child-pids "$dir";;
302302

303-
start-workloads )
303+
start-workload-by-name )
304304
local usage="USAGE: wb backend $op RUN-DIR"
305305
local dir=${1:?$usage}; shift
306+
local workload=${1:?$usage}; shift
306307

307308
while test $# -gt 0
308309
do case "$1" in
309310
--* ) msg "FATAL: unknown flag '$1'"; usage_supervisor;;
310311
* ) break;; esac; shift; done
311312

312-
# For every workload
313-
for workload in $(jq_tolist '.workloads | map(.name)' "$dir"/profile.json)
314-
do
315-
if ! supervisorctl start "${workload}"
316-
then progress "supervisor" "$(red fatal: failed to start) $(white "${workload} workload")"
317-
echo "$(red "${workload}" workload stdout) ----------------------" >&2
318-
cat "$dir"/workloads/"${workload}"/stdout
319-
echo "$(red "${workload}" workload stderr) ----------------------" >&2
320-
cat "$dir"/workloads/"${workload}"/stderr
321-
echo "$(white -------------------------------------------------)" >&2
322-
fatal "could not start $(white "${workload} workload")"
323-
fi
324-
done
313+
if ! supervisorctl start "${workload}"
314+
then progress "supervisor" "$(red fatal: failed to start) $(white "${workload} workload")"
315+
echo "$(red "${workload}" workload stdout) ----------------------" >&2
316+
cat "$dir"/workloads/"${workload}"/stdout
317+
echo "$(red "${workload}" workload stderr) ----------------------" >&2
318+
cat "$dir"/workloads/"${workload}"/stderr
319+
echo "$(white -------------------------------------------------)" >&2
320+
fatal "could not start $(white "${workload} workload")"
321+
fi
325322
backend_supervisor save-child-pids "$dir";;
326323

327324
wait-node-stopped )

0 commit comments

Comments
 (0)