Skip to content

Commit 502eb78

Browse files
committed
Add time logging
1 parent 0dd00c9 commit 502eb78

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

rc/control/bookkeeping.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
sys.path.append(os.environ["ARTDAQ_DAQINTERFACE_DIR"])
66

77
import re
8+
import time
89
from concurrent.futures import ThreadPoolExecutor, as_completed
910

1011
from rc.control.utilities import table_range
@@ -70,6 +71,9 @@
7071

7172
def bookkeeping_for_fhicl_documents_artdaq_v3_base(self):
7273

74+
_bk_start = time.time()
75+
_bk_section_start = _bk_start
76+
7377
# Start calculating values (fragment counts, memory sizes, etc.)
7478
# which will need to appear in the FHiCL
7579

@@ -120,6 +124,9 @@ def bookkeeping_for_fhicl_documents_artdaq_v3_base(self):
120124
)
121125
)
122126

127+
self.print_log("d", "Bookkeeping: max_fragment_size extraction took %.4f s" % (time.time() - _bk_section_start))
128+
_bk_section_start = time.time()
129+
123130
# Now loop over the boardreaders again to determine
124131
# subsystem-level things, such as the number of fragments per
125132
# event produced by each subsystem's boardreader set, and the
@@ -249,6 +256,9 @@ def calculate_subsystem_fragment_ids(ss):
249256
_frag_ids_cache[ss] = ids
250257
return ids
251258

259+
self.print_log("d", "Bookkeeping: boardreader fragment counting took %.4f s" % (time.time() - _bk_section_start))
260+
_bk_section_start = time.time()
261+
252262
expected_fragments_per_event = {}
253263
max_event_sizes = {}
254264
fragment_ids = {}
@@ -258,6 +268,9 @@ def calculate_subsystem_fragment_ids(ss):
258268
max_event_sizes[ss] = calculate_max_event_size(ss)
259269
fragment_ids[ss] = calculate_subsystem_fragment_ids(ss)
260270

271+
self.print_log("d", "Bookkeeping: recursive subsystem calculations took %.4f s" % (time.time() - _bk_section_start))
272+
_bk_section_start = time.time()
273+
261274
# If we have advanced memory usage switched on, then make sure the
262275
# max_event_size_bytes gets set to the value calculated here in
263276
# bookkeeping, whether this involves adding the
@@ -297,6 +310,9 @@ def calculate_subsystem_fragment_ids(ss):
297310
self.procinfos[i_proc].fhicl_used,
298311
)
299312

313+
self.print_log("d", "Bookkeeping: max_event_size_bytes substitution took %.4f s" % (time.time() - _bk_section_start))
314+
_bk_section_start = time.time()
315+
300316
# Check for places where Fragment IDs need to be filled in
301317

302318
for i_proc in range(len(self.procinfos)):
@@ -320,6 +336,9 @@ def calculate_subsystem_fragment_ids(ss):
320336
self.procinfos[i_proc].fhicl_used,
321337
)
322338

339+
self.print_log("d", "Bookkeeping: fragment IDs fill-in took %.4f s" % (time.time() - _bk_section_start))
340+
_bk_section_start = time.time()
341+
323342
# Construct the host map string needed in the sources and destinations
324343
# tables in artdaq process FHiCL
325344

@@ -600,6 +619,9 @@ def get_router_process_identifier(procinfo):
600619
)
601620
)
602621

622+
self.print_log("d", "Bookkeeping: host map + sources/destinations setup took %.4f s" % (time.time() - _bk_section_start))
623+
_bk_section_start = time.time()
624+
603625
for i_proc in range(len(self.procinfos)):
604626

605627
for tablename in ["sources", "destinations"]:
@@ -669,6 +691,9 @@ def determine_if_inter_subsystem_transfer(
669691
self.procinfos[i_proc], tablename, searchstart
670692
)
671693

694+
self.print_log("d", "Bookkeeping: sources/destinations table construction took %.4f s" % (time.time() - _bk_section_start))
695+
_bk_section_start = time.time()
696+
672697
nonsending_boardreaders = []
673698
for i_proc in range(len(self.procinfos)):
674699

@@ -689,6 +714,9 @@ def determine_if_inter_subsystem_transfer(
689714
):
690715
nonsending_boardreaders.append(procinfo.label)
691716

717+
self.print_log("d", "Bookkeeping: nonsending boardreaders identification took %.4f s" % (time.time() - _bk_section_start))
718+
_bk_section_start = time.time()
719+
692720
for i_proc in range(len(self.procinfos)):
693721
if (
694722
"DataLogger" in self.procinfos[i_proc].name
@@ -726,6 +754,9 @@ def determine_if_inter_subsystem_transfer(
726754
self.procinfos[i_proc].fhicl_used,
727755
)
728756

757+
self.print_log("d", "Bookkeeping: per-procinfo parameter updates took %.4f s" % (time.time() - _bk_section_start))
758+
_bk_section_start = time.time()
759+
729760
# JCF, Apr-17-2019
730761

731762
# For this next pass over the artdaq processes, we'll bookkeep the
@@ -776,6 +807,9 @@ def determine_if_inter_subsystem_transfer(
776807
for procinfo in self.procinfos:
777808
private_networks_seen[procinfo.label] = host_networks[procinfo.host]
778809

810+
self.print_log("d", "Bookkeeping: private network discovery took %.4f s" % (time.time() - _bk_section_start))
811+
_bk_section_start = time.time()
812+
779813
assert (
780814
not self.disable_private_network_bookkeeping or len(private_networks_seen) == 0
781815
), "See Aug-15-2019 comment in bookkeeping.py"
@@ -1020,6 +1054,9 @@ def bookkeep_table_for_router_process(
10201054
+ self.procinfos[i_proc].fhicl_used[table_end:]
10211055
)
10221056

1057+
self.print_log("d", "Bookkeeping: subsystem routing/multicast bookkeeping took %.4f s" % (time.time() - _bk_section_start))
1058+
_bk_section_start = time.time()
1059+
10231060
# Hoist invariant computation out of the per-process loop
10241061
_routing_manager_subsystems = set(
10251062
rm.subsystem
@@ -1116,6 +1153,9 @@ def bookkeep_table_for_router_process(
11161153
i_proc, di_subsystem, "routing_token_config", "Dispatcher"
11171154
)
11181155

1156+
self.print_log("d", "Bookkeeping: router process table bookkeeping took %.4f s" % (time.time() - _bk_section_start))
1157+
_bk_section_start = time.time()
1158+
11191159
firstLoggerRank = 9999999
11201160

11211161
for procinfo in self.procinfos:
@@ -1298,6 +1338,9 @@ def art_analyzer_count(procinfo):
12981338
procinfo.fhicl_used,
12991339
)
13001340

1341+
self.print_log("d", "Bookkeeping: firstLoggerRank + data_dir + overwrites + init_fragment_count took %.4f s" % (time.time() - _bk_section_start))
1342+
self.print_log("d", "Bookkeeping: total time %.4f s" % (time.time() - _bk_start))
1343+
13011344

13021345
def bookkeeping_for_fhicl_documents_artdaq_v4_base(self):
13031346
pass

0 commit comments

Comments
 (0)