Skip to content

Commit e765b82

Browse files
committed
Added ability for pserver to write provenance data as plain text using -prov_outputpath cmdline option
Services script now allows for disabling of pserver and provDB. If provDB is not used the pserver and AD will be automatically set to write provenance as plain text Services script now waits for the provDB to exit before finishing up
1 parent 2852e04 commit e765b82

3 files changed

Lines changed: 49 additions & 15 deletions

File tree

app/pserver.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ struct pserverArgs{
5454
std::string provdb_addr;
5555
#endif
5656

57-
pserverArgs(): ad("hbos"), nt(-1), logdir("."), ws_addr(""), load_params_set(false), save_params_set(false), freeze_params(false), stat_send_freq(1000), stat_outputdir(""), port(5559)
57+
std::string prov_outputpath;
58+
59+
pserverArgs(): ad("hbos"), nt(-1), logdir("."), ws_addr(""), load_params_set(false), save_params_set(false), freeze_params(false), stat_send_freq(1000), stat_outputdir(""), port(5559), prov_outputpath("")
5860
#ifdef _USE_ZMQNET
5961
, max_pollcyc_msg(10), zmq_io_thr(1), autoshutdown(true)
6062
#endif
@@ -85,6 +87,8 @@ struct pserverArgs{
8587
#ifdef ENABLE_PROVDB
8688
addOptionalCommandLineArg(p, provdb_addr, "Address of the provenance database. If empty (default) the global function and counter statistics will not be send to the provenance DB.\nHas format \"ofi+tcp;ofi_rxm://${IP_ADDR}:${PORT}\". Should also accept \"tcp://${IP_ADDR}:${PORT}\"");
8789
#endif
90+
addOptionalCommandLineArg(p, prov_outputpath, "Output global provenance data to this directory. Can be used in place of or in conjunction with the provenance database. An empty string \"\" (default) disables this output");
91+
8892

8993
init = true;
9094
}
@@ -210,13 +214,25 @@ int main (int argc, char ** argv){
210214
stat_sender.stop_stat_sender(1000);
211215

212216
#ifdef ENABLE_PROVDB
213-
//Send final statistics to the provenance database
214-
if(provdb_client.isConnected()){
215-
progressStream << "Pserver: sending final statistics to provDB" << std::endl;
216-
provdb_client.sendMultipleData(global_func_stats.collect_func_data(), GlobalProvenanceDataType::FunctionStats);
217-
provdb_client.sendMultipleData(global_counter_stats.get_json_state(), GlobalProvenanceDataType::CounterStats);
218-
progressStream << "Pserver: disconnecting from provDB" << std::endl;
219-
provdb_client.disconnect();
217+
//Send final statistics to the provenance database and/or disk
218+
if(provdb_client.isConnected() || args.prov_outputpath.size() > 0){
219+
nlohmann::json global_func_stats_j = global_func_stats.collect_func_data();
220+
nlohmann::json global_counter_stats_j = global_counter_stats.get_json_state();
221+
222+
if(provdb_client.isConnected()){
223+
progressStream << "Pserver: sending final statistics to provDB" << std::endl;
224+
provdb_client.sendMultipleData(global_func_stats_j, GlobalProvenanceDataType::FunctionStats);
225+
provdb_client.sendMultipleData(global_counter_stats_j, GlobalProvenanceDataType::CounterStats);
226+
progressStream << "Pserver: disconnecting from provDB" << std::endl;
227+
provdb_client.disconnect();
228+
}
229+
if(args.prov_outputpath.size() > 0){
230+
progressStream << "Pserver: writing final statistics to disk at path " << args.prov_outputpath << std::endl;
231+
std::ofstream gf(args.prov_outputpath + "/global_func_stats.json");
232+
std::ofstream gc(args.prov_outputpath + "/global_counter_stats.json");
233+
gf << global_func_stats_j.dump();
234+
gc << global_counter_stats_j.dump();
235+
}
220236
}
221237
#endif
222238

scripts/launch/chimbuko_config.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ backend_root="infer" #The root install directory of the PerformanceAnalysis lib
2222
####################################
2323
#Options for the provenance database
2424
####################################
25+
use_provdb=1 #enable or disable the provDB. If disabled the provenance data will be written as JSON ASCII into the ${provdb_writedir} set below
2526
provdb_extra_args="" #any extra command line arguments to pass
2627
provdb_nshards=4 #number of database shards
2728
provdb_engine="ofi+tcp;ofi_rxm" #the OFI libfabric provider used for the Mochi stack
@@ -36,6 +37,7 @@ provdb_domain=mlx5_0 #only needed for verbs provider <------------ ***SET ME (
3637
####################################
3738
#Options for the parameter server
3839
####################################
40+
use_pserver=1 #enable or disable the pserver
3941
pserver_extra_args="" #any extra command line arguments to pass
4042
pserver_port=5559 #port for parameter server
4143
pserver_nt=2 #number of worker threads

scripts/launch/run_services.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ echo "Chimbuko Services: Launching Chimbuko services on interface ${service_node
9090
#Provenance database
9191
extra_args=${ad_extra_args}
9292
ps_extra_args=${pserver_extra_args}
93-
if (( 1 )); then
93+
if (( ${use_provdb} == 1 )); then
9494
echo "==========================================="
9595
echo "Instantiating provenance database"
9696
echo "==========================================="
@@ -126,10 +126,19 @@ if (( 1 )); then
126126
ps_extra_args+=" -provdb_addr \"${prov_add}\""
127127
echo "Chimbuko Services: Enabling provenance database with arg: ${extra_args}"
128128
cd -
129+
else
130+
echo "Chimbuko Services: Provenance database is not in use, provenance data will be stored in ASCII format at ${provdb_writedir}"
131+
extra_args+=" -prov_outputpath ${provdb_writedir}"
132+
ps_extra_args+=" -prov_outputpath ${provdb_writedir}"
129133
fi
130134

131135
#Visualization
132-
if (( ${use_viz} )); then
136+
if (( ${use_viz} == 1 )); then
137+
if (( ${use_pserver} != 1 )); then
138+
echo "Chimbuko Services: Error - cannot use viz without the pserver"
139+
exit 1
140+
fi
141+
133142
cd ${viz_dir}
134143
HOST=`hostname`
135144
export SHARDED_NUM=${provdb_nshards}
@@ -186,7 +195,7 @@ if (( ${use_viz} )); then
186195
echo "Chimbuko Services: Webserver is running on ${HOST}:${viz_port} and is ready for the user to connect"
187196
fi
188197

189-
if (( 1 )); then
198+
if (( ${use_pserver} == 1 )); then
190199
pserver_addr="tcp://${ip}:${pserver_port}" #address for parameter server in format "tcp://IP:PORT"
191200

192201
echo "==========================================="
@@ -227,10 +236,11 @@ echo "Or equivalent"
227236
echo ${ad_opts} > ${var_dir}/chimbuko_ad_opts.var
228237

229238

230-
231-
#Wait for pserver to exit, which means it's time to end the viz
232-
echo "Chimbuko Services: waiting for pserver (pid ${ps_pid}) to terminate"
233-
wait ${ps_pid}
239+
if (( ${use_pserver} == 1 )); then
240+
#Wait for pserver to exit, which means it's time to end the viz
241+
echo "Chimbuko Services: waiting for pserver (pid ${ps_pid}) to terminate"
242+
wait ${ps_pid}
243+
fi
234244

235245
if (( ${use_viz} == 1 )); then
236246
echo "Chimbuko Services: Terminating Chimbuko visualization"
@@ -259,4 +269,10 @@ if (( ${use_viz} == 1 )); then
259269
cd -
260270
fi
261271

272+
if (( ${use_provdb} == 1 )); then
273+
echo "Chimbuko Services: waiting for provdb (pid ${provdb_pid}) to terminate"
274+
wait ${provdb_pid}
275+
fi
276+
277+
262278
echo "Chimbuko Services: Service script complete" $(date)

0 commit comments

Comments
 (0)