You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#!/usr/bin/env python2.7importsysDEFAULT_LIST_LENGTH=10defmain(argv):
"""Process fcm-make.log files: Optionally extracts all stderr and selected information relating to memory intensive shell commands and longest running shell commands. """importargparsefromargparseimportArgumentParser, RawTextHelpFormatter, \
ArgumentDefaultsHelpFormatterclassFormatter (RawTextHelpFormatter, ArgumentDefaultsHelpFormatter):
passparser=ArgumentParser(formatter_class=Formatter,
description=main.__doc__)
parser.add_argument(
'fcm_log_file', nargs='?', type=argparse.FileType('r'),
default=sys.stdin, help='Location of fcm-make-log file to process - takes from stdin ''if not present')
parser.add_argument(
'--[no-]extract-stderr', dest='extract_stderr',
action='store_true', default='store_true', help='Extract stderr')
parser.add_argument(
'--no-extract-stderr', dest='extract_stderr',
action='store_false', help=argparse.SUPPRESS)
parser.add_argument(
'--memory', type=int, default=DEFAULT_LIST_LENGTH, help='Display top MEMORY intensive commands. Set to 0 to disable.')
parser.add_argument(
'--longest', type=int, default=DEFAULT_LIST_LENGTH, help='Display top LONGEST commands. Set to 0 to disable.')
args=parser.parse_args()
time_list= []
mem_list= []
forlineinargs.fcm_log_file.readlines():
ifargs.extract_stderrand"[>>&2]"inline:
sys.stderr.write(line)
if"[info] shell("inline:
split_line=line.split()
time_list.append(split_line[2].replace(')', '') +" "+" ".join(split_line[3:]) +"\n")
if"Maximum resident set size "inline:
split_line=line.split()
mem_list.append(split_line[6] +" "+split_line[7] +" ".join(split_line[8:]) +"\n")
if"Maximum resident set size (kbytes * 4)"inline:
split_line=line.split()
mem_list.append(str(int(split_line[8])/4) +" "+split_line[5][1: 7] +" ".join(split_line[9:]) +"\n")
if"Maximum resident set size (kbytes)"inline:
split_line=line.split()
mem_list.append(split_line[6] +" "+split_line[5][1: 7] +" ".join(split_line[7:]) +"\n")
ifargs.memory>0:
print("Top "+str(args.memory) +" memory intensive commands:")
sorted_list=sorted(mem_list, key=lambdax: int(x.split()[0]),
reverse=True)
forlineinsorted_list[:args.memory]:
sys.stdout.write(line)
printifargs.longest>0:
print("Top "+str(args.longest) +" longest commands:")
sorted_list=sorted(time_list, key=lambdax: float(x.split()[0]),
reverse=True)
forlineinsorted_list[:args.longest]:
sys.stdout.write(line)
if__name__=='__main__':
main(sys.argv[1:])
The python script above also addresses some aspects of #7.
Ideally most of the above functionality would be included in fcm. If we were to do this, the solution may be related to how we deal with different architectures in "rose mpi-launch".
Note that the above also addresses a known bug with Linux "time" returning 4 times as much memory as truth on our systems.
The text was updated successfully, but these errors were encountered:
As well as how long a particular command takes to complete, it is also useful to know how much memory it takes.
fcm currently does not handle this therefore we use wrapper scripts and post processessing of the fcm-make.log to achieve this goal.
e.g. fcm config files become:
where FCM_COMMAND_WRAPPER is hpmcount-m on our Power 7, and time-m on the Linux desktop platform.
File: hpmcount-m
File: time-m
From within a rose environment:
File: fcm-make
File: fcm-make-log
The python script above also addresses some aspects of #7.
Ideally most of the above functionality would be included in fcm. If we were to do this, the solution may be related to how we deal with different architectures in "rose mpi-launch".
Note that the above also addresses a known bug with Linux "time" returning 4 times as much memory as truth on our systems.
The text was updated successfully, but these errors were encountered: