2 from __future__
import print_function
3 from builtins
import range
4 from itertools
import groupby
5 from operator
import attrgetter,itemgetter
7 from collections
import defaultdict
11 To Use: Add the Tracer Service to the cmsRun job use something like this 14 process.add_(cms.Service("Tracer", fileName = cms.untracked.string("tracer.log"))) 16 After running the job, execute this script and pass the name of the 17 Tracer log file to the script. 19 This script will output a more human readable form of the data in the Tracer log file.''' 48 kSourceFindEvent =
"sourceFindEvent" 49 kSourceDelayedRead =
"sourceDelayedRead" 56 writeProcessBlock = -9
69 accessInputProcessBlock = 7
80 if transition == Phase.startTracing:
81 return 'start tracing' 82 if transition == Phase.construction:
84 if transition == Phase.destruction:
86 if transition == Phase.beginJob:
88 if transition == Phase.endJob:
90 if transition == Phase.beginStream:
92 if transition == Phase.endStream:
94 if transition == Phase.beginProcessBlock:
95 return 'begin process block' 96 if transition == Phase.endProcessBlock:
97 return 'end process block' 98 if transition == Phase.accessInputProcessBlock:
99 return 'access input process block' 100 if transition == Phase.writeProcessBlock:
101 return 'write process block' 102 if transition == Phase.globalBeginRun:
103 return 'global begin run' 104 if transition == Phase.globalEndRun:
105 return 'global end run' 106 if transition == Phase.globalWriteRun:
107 return 'global write run' 108 if transition == Phase.streamBeginRun:
109 return 'stream begin run' 110 if transition == Phase.streamEndRun:
111 return 'stream end run' 112 if transition == Phase.globalBeginLumi:
113 return 'global begin lumi' 114 if transition == Phase.globalEndLumi:
115 return 'global end lumi' 116 if transition == Phase.globalWriteLumi:
117 return 'global write lumi' 118 if transition == Phase.streamBeginLumi:
119 return 'stream begin lumi' 120 if transition == Phase.streamEndLumi:
121 return 'stream end lumi' 122 if transition == Phase.esSyncEnqueue:
123 return 'EventSetup synchronization' 124 if transition == Phase.esSync:
125 return 'EventSetup synchronization' 126 if transition == Phase.Event:
130 if transition == Phase.startTracing:
132 if transition == Phase.construction
or transition == Phase.destruction:
134 if transition == Phase.endJob
or transition == Phase.beginJob:
136 if transition == Phase.beginStream
or transition == Phase.endStream:
138 if transition == Phase.beginProcessBlock
or transition == Phase.endProcessBlock:
140 if transition == Phase.accessInputProcessBlock:
142 if transition == Phase.writeProcessBlock:
144 if transition == Phase.globalBeginRun
or Phase.globalEndRun == transition:
146 if transition == Phase.globalWriteRun:
148 if transition == Phase.streamBeginRun
or Phase.streamEndRun == transition:
150 if transition == Phase.globalBeginLumi
or Phase.globalEndLumi == transition:
152 if transition == Phase.globalWriteLumi:
154 if transition == Phase.streamBeginLumi
or Phase.streamEndLumi == transition:
156 if transition == Phase.Event:
158 if transition == Phase.esSyncEnqueue
or transition == Phase.esSync:
164 return f
'{time:>11} '+
"++"*indentLevel
178 return f
'run={self.sync[0]}' 180 return f
'run={self.sync[0]}' 182 return f
'run={self.sync[0]}' 184 return f
'run={self.sync[0]} lumi={self.sync[1]}' 186 return f
'run={self.sync[0]} lumi={self.sync[1]}' 188 return f
'run={self.sync[0]} lumi={self.sync[1]}' 190 return f
'run={self.sync[0]} lumi={self.sync[1]} event={self.sync[2]}' 192 return f
'run={self.sync[0]} lumi={self.sync[1]}' 202 return f
'{transitionName(self.transition)} : id={self.index} {self.syncText()}' 204 return f
'{self.textPrefix()} {self.textSpecial()}: {self.textPostfix()}' 243 return f
'source during {transitionName(self.transition)} : id={self.index}' 245 return f
'{self.textPrefix()} {self.textSpecial()}: {self.textPostfix()}' 279 return f
'{self.moduleName} during {transitionName(self.transition)} : id={self.index}' 281 return f
'{self.textPrefix(context)} {self.textSpecial()}: {self.textPostfix()}' 287 return "starting action" 293 return "finished action" 299 return "starting prefetch" 305 return "finished prefetch" 311 return "starting acquire" 317 return "finished acquire" 323 return "starting delayed get" 329 return "finished delayed get" 335 return "starting read from source" 341 return "finished read from source" 344 def __init__(self, payload, moduleNames, esModuleNames, recordNames):
366 return f
'esmodule {self.moduleName} in record {self.recordName} during {transitionName(self.transition)} : id={self.index}' 368 return f
'{self.textPrefix(context)} {self.textSpecial()}: {self.textPostfix()}' 371 def __init__(self, payload, names, esNames, recordNames):
372 super().
__init__(payload, names, esNames, recordNames)
374 return "starting action" 377 def __init__(self, payload, names, esNames, recordNames):
378 super().
__init__(payload, names, esNames, recordNames)
380 return "finished action" 383 def __init__(self, payload, names, esNames, recordNames):
384 super().
__init__(payload, names, esNames, recordNames)
386 return "starting prefetch" 389 def __init__(self, payload, names, esNames, recordNames):
390 super().
__init__(payload, names, esNames, recordNames)
392 return "finished prefetch" 396 super().
__init__(payload, names, recordNames)
398 return "starting acquire" 401 def __init__(self, payload, names, esNames, recordNames):
402 super().
__init__(payload, names, esNames, recordNames)
404 return "finished acquire" 410 if parser.transition == Phase.esSyncEnqueue:
459 if not l
or l[0] ==
'#':
461 (step,payload) =
tuple(l.split(
None,1))
462 payload=payload.split()
464 parser =
lineParserFactory(step, payload, moduleNames, esModuleNames, recordNames, frameworkOnly)
471 streamBeginRun =
str(Phase.streamBeginRun)
473 numStreamsFromSource = 0
479 if l
and l[0] ==
'M':
481 if i[3] == streamBeginRun:
483 numStreams =
int(i[1])+1
485 if numStreams == 0
and l
and l[0] ==
'S':
486 s =
int(l.split(
' ')[1])
487 if s > numStreamsFromSource:
488 numStreamsFromSource = s
489 if len(l) > 5
and l[0:2] ==
"#M":
491 moduleNames[
int(id)] = name
493 if len(l) > 5
and l[0:2] ==
"#N":
495 esModuleNames[
int(id)] = name
497 if len(l) > 5
and l[0:2] ==
"#R":
499 recordNames[
int(id)] = name
505 numStreams = numStreamsFromSource +2
511 for n
in moduleNames.items():
513 for n
in esModuleNames.items():
519 """Create a generator which can step through the file and return each processing step. 520 Using a generator reduces the memory overhead when parsing a large file. 527 for p
in parser.processingSteps():
528 print(p.text(context))
531 if __name__==
"__main__":
537 parser = argparse.ArgumentParser(description=
'Convert a compact tracer file into human readable output.',
538 formatter_class=argparse.RawDescriptionHelpFormatter,
540 parser.add_argument(
'filename',
541 type=argparse.FileType(
'r'), # open file 542 help='file to process')
543 parser.add_argument(
'-f',
'--frameworkOnly',
545 help=
'''Output only the framework transitions, excluding the individual module transitions.''')
546 args = parser.parse_args()
def __init__(self, payload, moduleNames)
def __init__(self, payload, names, esNames, recordNames)
def processingSteps(self)
def lineParserFactory(step, payload, moduleNames, esModuleNames, recordNames, frameworkOnly)
def transitionName(transition)
def __init__(self, payload)
def __init__(self, payload)
def textPrefix(self, context)
def processingStepsFromFile(f, moduleNames, esModuleNames, recordNames, frameworkOnly)
def __init__(self, f, frameworkOnly)
def __init__(self, payload, names)
def __init__(self, payload, names, recordNames)
def __init__(self, payload, names)
def __init__(self, payload, names, esNames, recordNames)
def __init__(self, payload, names)
def baseIndentLevel(self)
def __init__(self, payload)
def __init__(self, payload, names)
def __init__(self, payload, names)
def __init__(self, payload, names)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def __init__(self, payload)
def baseIndentLevel(self)
def textPrefix_(time, indentLevel)
def __init__(self, payload, names, esNames, recordNames)
def split(sequence, size)
def __init__(self, payload, names)
def __init__(self, payload, names)
def __init__(self, payload, moduleNames, esModuleNames, recordNames)
def transitionIndentLevel(transition)
def __init__(self, payload)
def __init__(self, payload, names)
def __init__(self, payload, names, esNames, recordNames)
def __init__(self, payload, names)
def __init__(self, payload)
def textPrefix(self, context)
def __init__(self, payload)
def __init__(self, payload, names, esNames, recordNames)