Skip to content

Commit a3cd6a8

Browse files
authored
Speed improvements for MC workflow (#397)
* combine DPL devices in O2DPG * Setup env variables to speedup ROOT init
1 parent 8b4225c commit a3cd6a8

File tree

2 files changed

+39
-9
lines changed

2 files changed

+39
-9
lines changed

MC/bin/o2_dpg_workflow_runner.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
parser.add_argument('--checkpoint-on-failure', help=argparse.SUPPRESS) # debug option making a debug-tarball and sending to specified address
5252
# argument is alien-path
5353
parser.add_argument('--retry-on-failure', help=argparse.SUPPRESS, default=2) # number of times a failing task is retried
54+
parser.add_argument('--rootinit-speedup', help=argparse.SUPPRESS, action='store_true') # enable init of ROOT environment vars to speedup init/startup
5455
parser.add_argument('--action-logfile', help='Logfilename for action logs. If none given, pipeline_action_#PID.log will be used')
5556
parser.add_argument('--metric-logfile', help='Logfilename for metric logs. If none given, pipeline_metric_#PID.log will be used')
5657
args = parser.parse_args()
@@ -1001,6 +1002,31 @@ def execute(self):
10011002
psutil.cpu_percent(interval=None)
10021003
os.environ['JOBUTILS_SKIPDONE'] = "ON"
10031004

1005+
def speedup_ROOT_Init():
1006+
"""initialize some env variables that speed up ROOT init
1007+
and prevent ROOT from spawning many short-lived child
1008+
processes"""
1009+
1010+
# a) the PATH for system libraries
1011+
# search taken from ROOT TUnixSystem
1012+
cmd='LD_DEBUG=libs LD_PRELOAD=DOESNOTEXIST ls /tmp/DOESNOTEXIST 2>&1 | grep -m 1 "system search path" | sed \'s/.*=//g\' | awk \'//{print $1}\''
1013+
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
1014+
libpath, err = proc.communicate()
1015+
if (args.rootinit_speedup):
1016+
print ("setting up ROOT system")
1017+
os.environ['ROOT_LDSYSPATH'] = libpath.decode()
1018+
1019+
# b) the PATH for compiler includes needed by Cling
1020+
cmd='LC_ALL=C c++ -xc++ -E -v /dev/null 2>&1 | sed -n \'/^.include/,${/^ \/.*++/{p}}\'' # | sed \'s/ //\''
1021+
proc = subprocess.Popen([cmd], stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
1022+
incpath, err = proc.communicate()
1023+
incpaths = [ line.lstrip() for line in incpath.decode().splitlines() ]
1024+
joined = ':'.join(incpaths)
1025+
if (args.rootinit_speedup):
1026+
os.environ['ROOT_CPPSYSINCL'] = joined
1027+
1028+
speedup_ROOT_Init()
1029+
10041030
# we make our own "tmp" folder
10051031
# where we can put stuff such as tmp socket files etc (for instance DPL FAIR-MQ sockets)
10061032
# (In case of running within docker/singularity, this may not be so important)

MC/bin/o2dpg_sim_workflow.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
# power feature (for playing) --> does not appear in help message
9595
# help='Treat smaller sensors in a single digitization')
9696
parser.add_argument('--combine-smaller-digi', action='store_true', help=argparse.SUPPRESS)
97+
parser.add_argument('--combine-dpl-devices', action='store_true', help=argparse.SUPPRESS)
9798
parser.add_argument('--combine-tpc-clusterization', action='store_true', help=argparse.SUPPRESS) #<--- useful for small productions (pp, low interaction rate, small number of events)
9899
parser.add_argument('--first-orbit', default=0, type=int, help=argparse.SUPPRESS) # to set the first orbit number of the run for HBFUtils (only used when anchoring)
99100
# (consider doing this rather in O2 digitization code directly)
@@ -208,7 +209,7 @@ def addWhenActive(detID, needslist, appendstring):
208209

209210

210211
def getDPL_global_options(bigshm=False):
211-
common=" -b --run --driver-client-backend ws:// "
212+
common=" -b --run " # --driver-client-backend ws:// "
212213
if args.noIPC!=None:
213214
return common + " --no-IPC "
214215
if bigshm:
@@ -652,10 +653,12 @@ def createRestDigiTask(name, det='ALLSMALLER'):
652653
for d in itertools.chain(smallsensorlist, ctp_trigger_inputlist):
653654
tneeds += [ BKG_HITDOWNLOADER_TASKS[d]['name'] ]
654655
t = createTask(name=name, needs=tneeds,
655-
tf=tf, cwd=timeframeworkdir, lab=["DIGI","SMALLDIGI"], cpu=NWORKERS)
656+
tf=tf, cwd=timeframeworkdir, lab=["DIGI","SMALLDIGI"], cpu='1')
656657
t['cmd'] = ('','ln -nfs ../bkg_Hits*.root . ;')[doembedding]
657-
t['cmd'] += commondigicmd + ' --skipDet TPC,TRD '
658-
t['cmd'] += ' --ccdb-tof-sa'
658+
# t['cmd'] += commondigicmd + ' --skipDet TPC,TRD,FT0,FV0,CTP '
659+
t['cmd'] += commondigicmd + ' --onlyDet TOF,CPV,EMC,HMP,PHS,ITS,MFT,MID,MCH,FDD'
660+
t['cmd'] += ' --ccdb-tof-sa '
661+
t['cmd'] += ('',' --combine-devices ')[args.combine_dpl_devices]
659662
workflow['stages'].append(t)
660663
return t
661664

@@ -682,14 +685,14 @@ def createRestDigiTask(name, det='ALLSMALLER'):
682685
t = det_to_digitask['ALLSMALLER'] if args.combine_smaller_digi==True else createRestDigiTask(name, det)
683686
det_to_digitask[det]=t
684687

685-
if args.combine_smaller_digi==False:
688+
if True or args.combine_smaller_digi==False:
686689
# detectors serving CTP need to be treated somewhat special since CTP needs
687690
# these inputs at the same time --> still need to be made better
688691
tneeds = [ContextTask['name']]
689692
t = createTask(name="ft0fv0ctp_digi_" + str(tf), needs=tneeds,
690693
tf=tf, cwd=timeframeworkdir, lab=["DIGI","SMALLDIGI"], cpu='1')
691694
t['cmd'] = ('','ln -nfs ../bkg_HitsFT0.root . ; ln -nfs ../bkg_HitsFV0.root . ;')[doembedding]
692-
t['cmd'] += '${O2_ROOT}/bin/o2-sim-digitizer-workflow ' + getDPL_global_options() + ' -n ' + str(args.ns) + simsoption + ' --onlyDet FT0,FV0,CTP --interactionRate ' + str(INTRATE) + ' --incontext ' + str(CONTEXTFILE) + ' --disable-write-ini' + putConfigValuesNew()
695+
t['cmd'] += '${O2_ROOT}/bin/o2-sim-digitizer-workflow ' + getDPL_global_options() + ' -n ' + str(args.ns) + simsoption + ' --onlyDet FT0,FV0,CTP --interactionRate ' + str(INTRATE) + ' --incontext ' + str(CONTEXTFILE) + ' --disable-write-ini' + putConfigValuesNew() + ('',' --combine-devices')[args.combine_dpl_devices]
693696
workflow['stages'].append(t)
694697
det_to_digitask["FT0"]=t
695698
det_to_digitask["FV0"]=t
@@ -775,7 +778,7 @@ def getDigiTaskName(det):
775778
'TPCGasParam',
776779
'ITSCATrackerParam',
777780
'MFTClustererParam']) \
778-
+ " --track-sources " + anchorConfig.get("o2-tof-matcher-workflow-options",{}).get("track-sources",toftracksrcdefault)
781+
+ " --track-sources " + anchorConfig.get("o2-tof-matcher-workflow-options",{}).get("track-sources",toftracksrcdefault) + ('',' --combine-devices')[args.combine_dpl_devices]
779782
workflow['stages'].append(TOFTPCMATCHERtask)
780783

781784
MFTRECOtask = createTask(name='mftreco_'+str(tf), needs=[getDigiTaskName("MFT")], tf=tf, cwd=timeframeworkdir, lab=["RECO"], mem='1500')
@@ -875,7 +878,7 @@ def getDigiTaskName(det):
875878
PVFINDERtask = createTask(name='pvfinder_'+str(tf), needs=pvfinderneeds, tf=tf, cwd=timeframeworkdir, lab=["RECO"], cpu=NWORKERS, mem='4000')
876879
PVFINDERtask['cmd'] = '${O2_ROOT}/bin/o2-primary-vertexing-workflow ' \
877880
+ getDPL_global_options() + putConfigValuesNew(['ITSAlpideParam','MFTAlpideParam', 'pvertexer', 'TPCGasParam'], {"NameConf.mDirMatLUT" : ".."})
878-
PVFINDERtask['cmd'] += ' --vertexing-sources ' + pvfinder_sources + ' --vertex-track-matching-sources ' + pvfinder_matching_sources
881+
PVFINDERtask['cmd'] += ' --vertexing-sources ' + pvfinder_sources + ' --vertex-track-matching-sources ' + pvfinder_matching_sources + ('',' --combine-source-devices')[args.combine_dpl_devices]
879882
workflow['stages'].append(PVFINDERtask)
880883

881884
if includeFullQC or includeLocalQC:
@@ -995,7 +998,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
995998
svfinder_sources = "ITS,ITS-TPC,TPC-TRD,TPC-TOF,ITS-TPC-TRD,ITS-TPC-TOF"
996999
if isActive("MID"):
9971000
svfinder_sources += ",MID"
998-
SVFINDERtask['cmd'] += ' --vertexing-sources ' + svfinder_sources
1001+
SVFINDERtask['cmd'] += ' --vertexing-sources ' + svfinder_sources + ('',' --combine-source-devices')[args.combine_dpl_devices]
9991002
workflow['stages'].append(SVFINDERtask)
10001003

10011004
# -----------
@@ -1043,6 +1046,7 @@ def addQCPerTF(taskName, needs, readerCommand, configFilePath, objectsFile=''):
10431046
AODtask['cmd'] += ' --lpmp-prod-tag ${ALIEN_JDL_LPMPRODUCTIONTAG:-unknown}'
10441047
AODtask['cmd'] += ' --anchor-pass ${ALIEN_JDL_LPMANCHORPASSNAME:-unknown}'
10451048
AODtask['cmd'] += ' --anchor-prod ${ALIEN_JDL_MCANCHOR:-unknown}'
1049+
AODtask['cmd'] += ('',' --combine-source-devices ')[args.combine_dpl_devices]
10461050
if environ.get('O2DPG_AOD_NOTRUNCATE') != None or environ.get('ALIEN_JDL_O2DPG_AOD_NOTRUNCATE') != None:
10471051
AODtask['cmd'] += ' --enable-truncation 0' # developer option to suppress precision truncation
10481052

0 commit comments

Comments
 (0)