Skip to content

Commit 428c66e

Browse files
committed
print distributed work runtime
preferrably with monotonic clock also now printing ssh output for index output query results will write to files
1 parent c7964bf commit 428c66e

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

scripts/gufi_distributed.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import shlex
6767
import subprocess
6868
import sys
69+
import time
6970

7071
import gufi_common
7172

@@ -105,7 +106,6 @@ def run_ssh(args, target, cmd):
105106
# in waiting for the process to complete
106107
# pylint: disable=consider-using-with
107108
return subprocess.Popen([args.ssh, target, 'cd', os.getcwd(), '&&'] + [shlex.quote(argv) for argv in cmd],
108-
stdout=subprocess.DEVNULL, # Python 3.3
109109
cwd=os.getcwd())
110110

111111
# wait for all jobs to complete
@@ -202,8 +202,25 @@ def schedule_top(args, func):
202202

203203
return DISTRIBUTORS[args.distributor][0](args, target, cmd)
204204

205+
def clock():
206+
# assume Python 3+
207+
if sys.version_info.minor < 3:
208+
return time.time()
209+
if sys.version_info.minor < 7:
210+
return time.monotonic() # Python 3.3
211+
return time.monotonic_ns() # Python 3.7
212+
213+
def clock_diff(start, end):
214+
# assume Python 3+
215+
diff = end - start
216+
if sys.version_info.minor >= 7:
217+
diff /= 1e9
218+
return diff
219+
205220
# call this combined function to distribute work
206221
def distribute_work(args, root, schedule_subtree_func, schedule_top_func):
222+
start = clock()
223+
207224
dirs = dirs_at_level(root, args.level)
208225
group_size, groups = group_dirs(dirs, len(args.hosts[0]), args.sort)
209226

@@ -217,7 +234,13 @@ def distribute_work(args, root, schedule_subtree_func, schedule_top_func):
217234
print('Waiting for {0} jobs to complete'.format(args.distributor))
218235

219236
# wait for actual jobs to return
220-
return DISTRIBUTORS[args.distributor][1](args, procs)
237+
jobids = DISTRIBUTORS[args.distributor][1](args, procs)
238+
239+
end = clock()
240+
241+
print('Jobs completed in {0} seconds'.format(clock_diff(start, end)))
242+
243+
return jobids
221244

222245
# argparse type for existing directories (i.e. source tree)
223246
def dir_arg(path):

test/regression/gufi_distributed.sh.in

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,10 @@ trap cleanup_exit EXIT
161161

162162
cleanup
163163

164+
remove_distributed_output() {
165+
remove_indexing_time | @GREP@ -v "Creating GUFI\|Total Dirs:\|Total Non-Dirs\|Total Files:\|Jobs completed in"
166+
}
167+
164168
run_no_sort "${GUFI_DIR2INDEX_DISTRIBUTED} --help"
165169
run_no_sort "${GUFI_DIR2TRACE_DISTRIBUTED} --help"
166170
run_no_sort "${GUFI_QUERY_DISTRIBUTED} --help"
@@ -246,7 +250,7 @@ echo "# Diff original index results against the trace files"
246250
# shellcheck disable=SC2145,SC2153
247251
run_no_sort "@DIFF@ <(${GUFI_QUERY} -d \" \" -S \"SELECT rpath(sname, sroll) FROM vrsummary;\" -E \"SELECT rpath(sname, sroll) || '/' || name FROM vrpentries;\" \"${INDEXROOT}\" | sort | @SED@ 's/${SEARCH//\//\\/}\\///g') <(cat ${traces[@]} | @AWK@ -F'${DELIM}' '{ print \$1 }' | sort)"
248252
echo "#####################################"
249-
) 2>&1 | tee "${OUTPUT}"
253+
) 2>&1 | remove_distributed_output | tee "${OUTPUT}"
250254

251255
@DIFF@ @CMAKE_CURRENT_BINARY_DIR@/gufi_distributed.expected "${OUTPUT}"
252256
rm "${OUTPUT}"

0 commit comments

Comments
 (0)