CMS 3D CMS Logo

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.

00250            :
00251     (oldpath,newpath) = getParameters()
00252     regressReports(oldpath,newpath,oldRelName=getVerFromLog(oldpath))
00253 
              
def cmsRelRegress::compareSimMemPair (   newLog,
  candle,
  profdir,
  curdir,
  oldlog,
  oldRelName = "" 
)

Definition at line 57 of file cmsRelRegress.py.

00058                                                                         :
00059     print "oldlog %s"%oldlog
00060     print "curdir %s"%curdir
00061     #oldRelName = getOldRelName(oldRelName,olddir)
00062     oldRelName = getOldRelName(oldRelName,oldlog)
00063     print "OLD REL NAME: %s"%oldRelName
00064     #base = os.path.basename(newLog)
00065     #oldlog = os.path.join(olddir,curdir,base)
00066     rootf  = "simpmem-regress.root"
00067     try:
00068         print "TRY candle %s"%candle
00069         print "HERE Oldlog:%s"%oldlog
00070         print "HERE newLog:%s"%newLog
00071         cpr.cmpSimpMemReport(rootf,curdir,oldlog,newLog,1,True,candle,prevrev = oldRelName)
00072     except cpr.SimpMemParseErr, detail:
00073         print "WARNING: Could not parse data from log file %s; not performing regression" % detail.message
00074     except OSError, detail:
00075         print "WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail
00076     except IOError, detail:
00077         print "IOError:", detail
00078     else:
00079         print "Successfully compared %s and %s" % (oldlog,newLog)        
        
def cmsRelRegress::getOldRelName (   oldRelName,
  adir 
)

Definition at line 46 of file cmsRelRegress.py.

00047                                   :
00048     #Not sure this function is used but as it was written before it was useless.
00049     #Now it parses the adir directory looking for the CMSSW_X_Y_Z(_preN) in the path.
00050     if oldRelName == "":
00051         oldRelPath = os.path.dirname(adir)
00052         oldRelPathDirs = oldRelPath.split("/")
00053         for dir in oldRelPathDirs:
00054             if 'CMSSW' in dir:
00055                 oldRelName=dir
00056     return oldRelName

def cmsRelRegress::getParameters ( )

Definition at line 8 of file cmsRelRegress.py.

00009                    :
00010     global _debug
00011     global PROG_NAME
00012     PROG_NAME = os.path.basename(sys.argv[0])
00013     parser = opt.OptionParser(usage="""%s [OLD_REL_DIR] [NEW_REL_DIR]
00014 
00015 To compare 2 cmsPerfSuite.py directories pass the previous release as the first argument and the latest release as the second argument """ % PROG_NAME)
00016     #
00017     # Options
00018     #
00019     devel  = opt.OptionGroup(parser, "Developer Options",
00020                                      "Caution: use these options at your own risk."
00021                                      "It is believed that some of them bite.\n")    
00022     devel.add_option(
00023         '-d',
00024         '--debug',
00025         type='int',
00026         dest='debug',
00027         default = 0,
00028         help='Show debug output',
00029         #metavar='DEBUG',
00030         )
00031     parser.add_option_group(devel)
00032     (options,args) = parser.parse_args()
00033     _debug = options.debug
00034     
00035     if not len(args) == 2:
00036         print "ERROR: Not enough arguments"
00037         sys.exit()
00038         
00039     path1 = os.path.abspath(args[0])
00040     path2 = os.path.abspath(args[1])    
00041     if os.path.exists(path1) and os.path.exists(path2):
00042         return (path1, path2)
00043     else:
00044         print "Error: one of the paths does not exist"
00045         sys.exit()

def cmsRelRegress::regressReports (   olddir,
  newdir,
  oldRelName = "",
  newRelName = "" 
)

Definition at line 80 of file cmsRelRegress.py.

00081                                                                :
00082 
00083     profSets = ["Callgrind",
00084                 #"Memcheck", #No regression on Memcheck profiles!
00085                 "IgProf",
00086                 "TimeSize",
00087                 #Adding the PU directories:
00088                 "PU_Callgrind",
00089                 "PU_IgProf",
00090                 "PU_TimeSize"
00091                 ]
00092     for candle in Candles:
00093         #Loop over the known profilers sets (tests) defined above:
00094         for profset in profSets:
00095             #Check there is a directory with the profile set (test) being considered:
00096             adir = os.path.join(newdir,"%s_%s" % (candle,profset))
00097             if os.path.exists(adir):
00098                 #Start working in directory adir (e.g. MinBias_TimeSize)
00099                 print "Found directory %s"%adir
00100 
00101                 #Set up the profilers based on the directory name
00102                 Profs = []
00103                 if   profset == "Callgrind" or  profset == "PU_Callgrind":
00104                     Profs = ["valgrind"] # callgrind actually
00105                 elif profset == "TimeSize" or profset == "PU_TimeSize":
00106                     Profs = [ "TimingReport",
00107                               #"TimeReport", We do not run regression on the plain html TimeReport profile...
00108                               "SimpleMemoryCheck",
00109                               "EdmSize"]
00110                 elif profset == "IgProf" or profset == "PU_IgProf" :
00111                     Profs = [ "IgProfperf", #This was missing!
00112                               "IgProfMemTotal",
00113                               "IgProfMemLive"]
00114                 #Now for each individual profile in the profile set (e.g for TimeSize TimeReport, TimingReport, SimpleMemoryCheck, EdmSize
00115                 #collect the various logfiles
00116                 for prof in Profs:
00117                     print "Checking %s profile(s)"%prof
00118                     if   prof == "EdmSize" or prof == "valgrind":
00119                         stepLogs = glob.glob("%s/%s_*_%s"       % (adir,CandFname[candle],prof))
00120                     elif prof == "IgProfMemLive" or prof == "IgProfMemTotal": 
00121                         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) 
00122                     elif prof == "IgProfperf":
00123                         stepLogs = glob.glob("%s/%s_*_%s.gz"       % (adir,CandFname[candle],prof))
00124                     elif prof == "SimpleMemoryCheck":
00125                         #With the change in the use of tee now the SimpleMemoryCheck info will be in the _TimingReport.log too...
00126                         #The following lines only will work for the unprofiled steps... hence... no need to report them!
00127                         #stepLogs = os.path.join(adir,"%s.log" % candle)
00128                         stepLogs = glob.glob("%s/%s_*_%s.log"   % (adir,CandFname[candle],'TimingReport'))
00129                     elif prof == "TimingReport":
00130                         stepLogs = glob.glob("%s/%s_*_%s.log"   % (adir,CandFname[candle],prof))
00131 
00132                     #Debug:
00133                     print "Found the following step logs: %s"%stepLogs
00134                     
00135                     profdir = os.path.basename(adir)
00136 
00137                     #Giant if to single out the SimpleMemoryCheck case that is in the elif at the bottom... maybe should flip things around...
00138                     #Basically here we do everything but SimpleMemoryCheck:
00139                     if prof == "TimingReport" or prof == "EdmSize" or prof == "valgrind" or prof == "IgProfMemTotal" or prof == "IgProfMemLive" or prof == "IgProfperf":
00140                         #This hack necessary since we reuse the IgProfMemTotal profile for MemLive too
00141                         #(it's a unique IgProfMem profile, read with different counters)
00142                         if prof == "IgProfMemLive": 
00143                             stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],"IgProfMemTotal"))
00144                         else:
00145                             stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],prof))
00146 
00147                         #Loop on the step logfiles collected above
00148                         for log in stepLogs:
00149                             base = os.path.basename(log)
00150                             #Handle the fact the profile ("log") for IgProf is always compressed (.gz):
00151                             if prof == "IgProfMemTotal" or prof == "IgProfMemLive" or prof == "IgProfperf":
00152                                 base = base.split(".gz")[0]
00153                             #Use the regular expression defined above to read out the step from the log/profile
00154                             searchob = stepreg.search(base)
00155 
00156                             #If in this log the regular expression was able match (and so to extract the step)
00157                             if searchob:
00158                                 #print searchob.groups()
00159                                 step = searchob.groups()[0]
00160                                 #print "and the step taken is %s"%step
00161                                 outpath = os.path.join(adir,"%s_%s_%s_regression" % (CandFname[candle],step,prof))
00162                                 oldlog  = os.path.join(olddir,"%s_%s" % (candle,profset),base)
00163                                 #Again handle the fact the profile ("log") for IgProf is always compressed (.gz):
00164                                 if prof == "IgProfMemTotal" or prof == "IgProfMemLive" or prof == "IgProfperf":
00165                                     oldlog  = os.path.join(olddir,"%s_%s" % (candle,profset),base + ".gz")
00166                                 if not os.path.exists(outpath):
00167                                     os.mkdir(outpath)
00168                                 if os.path.exists(oldlog):
00169                                     try:
00170                                         print ""
00171                                         print "** "
00172                                         if not prof == "TimingReport":
00173                                             print "** Comparing", candle, step, prof, "previous release: %s, latest release %s" % (oldlog,log)
00174                                             print "**"
00175 
00176                                         if   prof == "EdmSize":
00177                                             cpr.cmpEdmSizeReport(outpath,oldlog,log)
00178                                         elif prof == "TimingReport":
00179                                             logdir = "%s_%s_%s" % (CandFname[candle],step,prof)
00180                                             outd   = os.path.join(adir,logdir)
00181                                             rootf  = "timing-regress.root" 
00182                                             oldlog = os.path.join(olddir,profdir,base)
00183                                             if os.path.exists(log) and os.path.exists(oldlog) and os.path.exists(outd):
00184                                                 print "** Comparing", candle, step, prof, "previous release: %s and latest release: %s" % (oldlog,log)
00185                                                 print "**"
00186                                                 oldRelName = getOldRelName("",oldlog)
00187                                                 #print "TIMING OLD REL extracted from %s :\n %s"%(oldlog,oldRelName)
00188                                                 cpr.cmpTimingReport(rootf, outd, oldlog, log, 1, batch = True, prevrev = oldRelName)
00189                                             else:
00190                                                 print "WARNING: While comparing", candle, step, prof, " at least one of the logfiles/directories: old (%s) or new (%s) was not found!!!" % (oldlog,log)
00191                                                 break
00192                                         elif prof == "valgrind":
00193                                             cpr.cmpCallgrindReport(outpath,oldlog,log)
00194                                         elif prof == "IgProfperf":
00195                                             IgProfMemOpt="" #No need to specify the counter, for IgProfPerf...
00196                                             cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
00197                                         elif prof == "IgProfMemTotal":
00198                                             IgProfMemOpt="-y MEM_TOTAL"
00199                                             cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
00200                                         elif prof == "IgProfMemLive":
00201                                             IgProfMemOpt="-y MEM_LIVE"
00202                                             cpr.cmpIgProfReport(outpath,oldlog,log,IgProfMemOpt)
00203                                     except cpr.PerfReportErr,detail:
00204                                         print "WARNING: Perfreport return non-zero exit status when comparing %s and %s. Perfreport output follows" % (oldlog,log)
00205                                         print detail.message
00206                                     except cpr.TimingParseErr,detail:
00207                                         print "WARNING: Could not parse data from log file %s; not performing regression" % detail.message                                            
00208                                     except OSError, detail:
00209                                         print "WARNING: The OS returned the following error when comparing %s and %s" % (oldlog,log), detail
00210                                     except IOError, detail:
00211                                         print "IOError:", detail
00212                                     else:
00213                                         print "Successfully compared %s and %s" % (oldlog,log)                                            
00214                                 else:
00215                                     print "WARNING: Could not find an equivalent logfile for %s in the previous release dir %s " % (log,oldlog)
00216                                         
00217                                                             
00218                             else:
00219                                 continue
00220                     elif prof == "SimpleMemoryCheck":
00221                         #print "The logfiles for SimpleMemoryCheck are %s"%stepLogs
00222                         for log in stepLogs:
00223                             #print "The logfile considered now is %s"%log 
00224                             stepreg = re.compile("%s_([^_]*(_PILEUP)?)_%s((.log)|(.gz))?" % (CandFname[candle],"TimingReport"))
00225                             base = os.path.basename(log)
00226                             #Use the regular expression defined above to read out the step from the log/profile
00227                             searchob = stepreg.search(base)
00228                             #print "Value of searchob is %s"%searchob
00229                             #If in this log the regular expression was able match (and so to extract the step)
00230                             if searchob:
00231                                 #print searchob.groups()
00232                                 step = searchob.groups()[0]
00233                                 print "and the step taken is %s"%step
00234                                 #outpath = os.path.join(adir,"%s_%s_%s_regression" % (CandFname[candle],step,prof))
00235                                 oldlog  = os.path.join(olddir,"%s_%s" % (candle,profset),base)
00236                             if os.path.exists(oldlog):
00237                                 print ""
00238                                 print "** "
00239                                 print "** Comparing for SimpleMemoryCheck", candle, step, prof, "previous release: %s, latest release %s" % (oldlog,log)
00240                                 print "**"
00241                                 #The try/except is folded in the following function for SimpleMemoryCheck:
00242                                 compareSimMemPair(log,candle,profdir,adir,oldlog,oldRelName="")
00243                                
00244     if newRelName == "":
00245         newRelName = getVerFromLog(newdir)
00246     regress = open("%s/REGRESSION.%s.vs.%s" % (newdir,getVerFromLog(olddir),newRelName),"w")
00247     regress.write(olddir)
00248     regress.close()