CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
cmsRelRegress Namespace Reference

Functions

def _main
 
def compareSimMemPair
 
def getOldRelName
 
def getParameters
 
def regressReports
 

Function Documentation

def cmsRelRegress._main ( )
private

Definition at line 249 of file cmsRelRegress.py.

References getParameters(), cmsPerfCommons.getVerFromLog(), and regressReports().

250 def _main():
251  (oldpath,newpath) = getParameters()
252  regressReports(oldpath,newpath,oldRelName=getVerFromLog(oldpath))
253 
def cmsRelRegress.compareSimMemPair (   newLog,
  candle,
  profdir,
  curdir,
  oldlog,
  oldRelName = "" 
)

Definition at line 57 of file cmsRelRegress.py.

References getOldRelName().

Referenced by regressReports().

57 
58 def compareSimMemPair(newLog,candle,profdir,curdir,oldlog,oldRelName=""):
59  print "oldlog %s"%oldlog
60  print "curdir %s"%curdir
61  #oldRelName = getOldRelName(oldRelName,olddir)
62  oldRelName = getOldRelName(oldRelName,oldlog)
63  print "OLD REL NAME: %s"%oldRelName
64  #base = os.path.basename(newLog)
65  #oldlog = os.path.join(olddir,curdir,base)
66  rootf = "simpmem-regress.root"
67  try:
68  print "TRY candle %s"%candle
69  print "HERE Oldlog:%s"%oldlog
70  print "HERE newLog:%s"%newLog
71  cpr.cmpSimpMemReport(rootf,curdir,oldlog,newLog,1,True,candle,prevrev = oldRelName)
72  except cpr.SimpMemParseErr, detail:
73  print "WARNING: Could not parse data from log file %s; not performing regression" % detail.message
74  except OSError, detail:
75  print "WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail
76  except IOError, detail:
77  print "IOError:", detail
78  else:
79  print "Successfully compared %s and %s" % (oldlog,newLog)
def cmsRelRegress.getOldRelName (   oldRelName,
  adir 
)

Definition at line 46 of file cmsRelRegress.py.

Referenced by compareSimMemPair(), and regressReports().

46 
47 def getOldRelName(oldRelName,adir):
48  #Not sure this function is used but as it was written before it was useless.
49  #Now it parses the adir directory looking for the CMSSW_X_Y_Z(_preN) in the path.
50  if oldRelName == "":
51  oldRelPath = os.path.dirname(adir)
52  oldRelPathDirs = oldRelPath.split("/")
53  for dir in oldRelPathDirs:
54  if 'CMSSW' in dir:
55  oldRelName=dir
56  return oldRelName
def cmsRelRegress.getParameters ( )

Definition at line 8 of file cmsRelRegress.py.

Referenced by _main().

8 
9 def getParameters():
10  global _debug
11  global PROG_NAME
12  PROG_NAME = os.path.basename(sys.argv[0])
13  parser = opt.OptionParser(usage="""%s [OLD_REL_DIR] [NEW_REL_DIR]
14 
15 To compare 2 cmsPerfSuite.py directories pass the previous release as the first argument and the latest release as the second argument """ % PROG_NAME)
16  #
17  # Options
18  #
19  devel = opt.OptionGroup(parser, "Developer Options",
20  "Caution: use these options at your own risk."
21  "It is believed that some of them bite.\n")
22  devel.add_option(
23  '-d',
24  '--debug',
25  type='int',
26  dest='debug',
27  default = 0,
28  help='Show debug output',
29  #metavar='DEBUG',
30  )
31  parser.add_option_group(devel)
32  (options,args) = parser.parse_args()
33  _debug = options.debug
34 
35  if not len(args) == 2:
36  print "ERROR: Not enough arguments"
37  sys.exit()
38 
39  path1 = os.path.abspath(args[0])
40  path2 = os.path.abspath(args[1])
41  if os.path.exists(path1) and os.path.exists(path2):
42  return (path1, path2)
43  else:
44  print "Error: one of the paths does not exist"
45  sys.exit()
def cmsRelRegress.regressReports (   olddir,
  newdir,
  oldRelName = "",
  newRelName = "" 
)

Definition at line 80 of file cmsRelRegress.py.

References compareSimMemPair(), getOldRelName(), and cmsPerfCommons.getVerFromLog().

Referenced by _main().

80 
81 def regressReports(olddir,newdir,oldRelName = "",newRelName=""):
82 
83  profSets = ["Callgrind",
84  #"Memcheck", #No regression on Memcheck profiles!
85  "IgProf",
86  "TimeSize",
87  #Adding the PU directories:
88  "PU_Callgrind",
89  "PU_IgProf",
90  "PU_TimeSize"
91  ]
92  for candle in Candles:
93  #Loop over the known profilers sets (tests) defined above:
94  for profset in profSets:
95  #Check there is a directory with the profile set (test) being considered:
96  adir = os.path.join(newdir,"%s_%s" % (candle,profset))
97  if os.path.exists(adir):
98  #Start working in directory adir (e.g. MinBias_TimeSize)
99  print "Found directory %s"%adir
100 
101  #Set up the profilers based on the directory name
102  Profs = []
103  if profset == "Callgrind" or profset == "PU_Callgrind":
104  Profs = ["valgrind"] # callgrind actually
105  elif profset == "TimeSize" or profset == "PU_TimeSize":
106  Profs = [ "TimingReport",
107  #"TimeReport", We do not run regression on the plain html TimeReport profile...
108  "SimpleMemoryCheck",
109  "EdmSize"]
110  elif profset == "IgProf" or profset == "PU_IgProf" :
111  Profs = [ "IgProfperf", #This was missing!
112  "IgProfMemTotal",
113  "IgProfMemLive"]
114  #Now for each individual profile in the profile set (e.g for TimeSize TimeReport, TimingReport, SimpleMemoryCheck, EdmSize
115  #collect the various logfiles
116  for prof in Profs:
117  print "Checking %s profile(s)"%prof
118  if prof == "EdmSize" or prof == "valgrind":
119  stepLogs = glob.glob("%s/%s_*_%s" % (adir,CandFname[candle],prof))
120  elif prof == "IgProfMemLive" or prof == "IgProfMemTotal":
121  stepLogs = glob.glob("%s/%s_*_%s.gz" % (adir,CandFname[candle],"IgProfMemTotal")) #This hack necessary since we reuse the IgProfMemTotal profile for MemLive too (it's a unique IgProfMem profile, read with different counters)
122  elif prof == "IgProfperf":
123  stepLogs = glob.glob("%s/%s_*_%s.gz" % (adir,CandFname[candle],prof))
124  elif prof == "SimpleMemoryCheck":
125  #With the change in the use of tee now the SimpleMemoryCheck info will be in the _TimingReport.log too...
126  #The following lines only will work for the unprofiled steps... hence... no need to report them!
127  #stepLogs = os.path.join(adir,"%s.log" % candle)
128  stepLogs = glob.glob("%s/%s_*_%s.log" % (adir,CandFname[candle],'TimingReport'))
129  elif prof == "TimingReport":
130  stepLogs = glob.glob("%s/%s_*_%s.log" % (adir,CandFname[candle],prof))
131 
132  #Debug:
133  print "Found the following step logs: %s"%stepLogs
134 
135  profdir = os.path.basename(adir)
136 
137  #Giant if to single out the SimpleMemoryCheck case that is in the elif at the bottom... maybe should flip things around...
138  #Basically here we do everything but SimpleMemoryCheck:
139  if prof == "TimingReport" or prof == "EdmSize" or prof == "valgrind" or prof == "IgProfMemTotal" or prof == "IgProfMemLive" or prof == "IgProfperf":
140  #This hack necessary since we reuse the IgProfMemTotal profile for MemLive too
141  #(it's a unique IgProfMem profile, read with different counters)
142  if prof == "IgProfMemLive":
143  stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],"IgProfMemTotal"))
144  else:
145  stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],prof))
146 
147  #Loop on the step logfiles collected above
148  for log in stepLogs:
149  base = os.path.basename(log)
150  #Handle the fact the profile ("log") for IgProf is always compressed (.gz):
151  if prof == "IgProfMemTotal" or prof == "IgProfMemLive" or prof == "IgProfperf":
152  base = base.split(".gz")[0]
153  #Use the regular expression defined above to read out the step from the log/profile
154  searchob = stepreg.search(base)
155 
156  #If in this log the regular expression was able match (and so to extract the step)
157  if searchob:
158  #print searchob.groups()
159  step = searchob.groups()[0]
160  #print "and the step taken is %s"%step
161  outpath = os.path.join(adir,"%s_%s_%s_regression" % (CandFname[candle],step,prof))
162  oldlog = os.path.join(olddir,"%s_%s" % (candle,profset),base)
163  #Again handle the fact the profile ("log") for IgProf is always compressed (.gz):
164  if prof == "IgProfMemTotal" or prof == "IgProfMemLive" or prof == "IgProfperf":
165  oldlog = os.path.join(olddir,"%s_%s" % (candle,profset),base + ".gz")
166  if not os.path.exists(outpath):
167  os.mkdir(outpath)
168  if os.path.exists(oldlog):
169  try:
170  print ""
171  print "** "
172  if not prof == "TimingReport":
173  print "** Comparing", candle, step, prof, "previous release: %s, latest release %s" % (oldlog,log)
174  print "**"
175 
176  if prof == "EdmSize":
177  cpr.cmpEdmSizeReport(outpath,oldlog,log)
178  elif prof == "TimingReport":
179  logdir = "%s_%s_%s" % (CandFname[candle],step,prof)
180  outd = os.path.join(adir,logdir)
181  rootf = "timing-regress.root"
182  oldlog = os.path.join(olddir,profdir,base)
183  if os.path.exists(log) and os.path.exists(oldlog) and os.path.exists(outd):
184  print "** Comparing", candle, step, prof, "previous release: %s and latest release: %s" % (oldlog,log)
185  print "**"
186  oldRelName = getOldRelName("",oldlog)
187  #print "TIMING OLD REL extracted from %s :\n %s"%(oldlog,oldRelName)
188  cpr.cmpTimingReport(rootf, outd, oldlog, log, 1, batch = True, prevrev = oldRelName)
189  else:
190  print "WARNING: While comparing", candle, step, prof, " at least one of the logfiles/directories: old (%s) or new (%s) was not found!!!" % (oldlog,log)
191  break
192  elif prof == "valgrind":
193  cpr.cmpCallgrindReport(outpath,oldlog,log)
194  elif prof == "IgProfperf":
195  IgProfMemOpt="" #No need to specify the counter, for IgProfPerf...
196  cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
197  elif prof == "IgProfMemTotal":
198  IgProfMemOpt="-y MEM_TOTAL"
199  cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
200  elif prof == "IgProfMemLive":
201  IgProfMemOpt="-y MEM_LIVE"
202  cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
203  except cpr.PerfReportErr,detail:
204  print "WARNING: Perfreport return non-zero exit status when comparing %s and %s. Perfreport output follows" % (oldlog,log)
205  print detail.message
206  except cpr.TimingParseErr,detail:
207  print "WARNING: Could not parse data from log file %s; not performing regression" % detail.message
208  except OSError, detail:
209  print "WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail
210  except IOError, detail:
211  print "IOError:", detail
212  else:
213  print "Successfully compared %s and %s" % (oldlog,log)
214  else:
215  print "WARNING: Could not find an equivalent logfile for %s in the previous release dir %s " % (log,oldlog)
216 
217 
218  else:
219  continue
220  elif prof == "SimpleMemoryCheck":
221  #print "The logfiles for SimpleMemoryCheck are %s"%stepLogs
222  for log in stepLogs:
223  #print "The logfile considered now is %s"%log
224  stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],"TimingReport"))
225  base = os.path.basename(log)
226  #Use the regular expression defined above to read out the step from the log/profile
227  searchob = stepreg.search(base)
228  #print "Value of searchob is %s"%searchob
229  #If in this log the regular expression was able match (and so to extract the step)
230  if searchob:
231  #print searchob.groups()
232  step = searchob.groups()[0]
233  print "and the step taken is %s"%step
234  #outpath = os.path.join(adir,"%s_%s_%s_regression" % (CandFname[candle],step,prof))
235  oldlog = os.path.join(olddir,"%s_%s" % (candle,profset),base)
236  if os.path.exists(oldlog):
237  print ""
238  print "** "
239  print "** Comparing for SimpleMemoryCheck", candle, step, prof, "previous release: %s, latest release %s" % (oldlog,log)
240  print "**"
241  #The try/except is folded in the following function for SimpleMemoryCheck:
242  compareSimMemPair(log,candle,profdir,adir,oldlog,oldRelName="")
243 
244  if newRelName == "":
245  newRelName = getVerFromLog(newdir)
246  regress = open("%s/REGRESSION.%s.vs.%s" % (newdir,getVerFromLog(olddir),newRelName),"w")
247  regress.write(olddir)
248  regress.close()