Skip to content

Commit

Permalink
Remove eager string formatting in log statements
Browse files Browse the repository at this point in the history
Log message formatting should be left to the logging system instead of
being carried out by users; this is because in many cases, specially in
the lower logging levels like DEBUG, messages will actually be filtered
out and never make it to any of the sinks. This is sadly a very common
mistake one sees in the wild, and can cause real performance issues.

These might have been the slow logging reported in #142, but even if it
isn't the change is beneficial.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
  • Loading branch information
rtobar committed May 5, 2022
1 parent 7db1982 commit 3068a2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
19 changes: 8 additions & 11 deletions daliuge-translator/dlg/dropmake/lg.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ def __init__(self, f, ssid=None):
from_port = lk.get("fromPort", "__None__")
if stream_output_ports.get(from_port, None) == lk["from"]:
lk["is_stream"] = True
logger.debug("Found stream from %s to %s" % (lk["from"], lk["to"]))
logger.debug("Found stream from %s to %s", lk["from"], lk["to"])
else:
lk["is_stream"] = False
if "1" == lk.get("loop_aware", "0"):
Expand Down Expand Up @@ -1277,7 +1277,7 @@ def _link_drops(self, slgn, tlgn, src_drop, tgt_drop, llink):
tup = self._gather_cache[gather_oid]
tup[1].append(sdrop)
logger.debug(
"Hit gather, link is from %s to %s" % (llink["from"], llink["to"])
"Hit gather, link is from %s to %s", llink["from"], llink["to"]
)
return

Expand Down Expand Up @@ -1328,7 +1328,7 @@ def _link_drops(self, slgn, tlgn, src_drop, tgt_drop, llink):
sIdText = slgn._getIdText("outputPorts")
if llink.get("is_stream", False):
logger.debug(
"link stream connection %s to %s" % (sdrop["oid"], tdrop["oid"])
"link stream connection %s to %s", sdrop["oid"], tdrop["oid"]
)
sdrop.addStreamingConsumer(tdrop, IdText=sIdText)
tdrop.addStreamingInput(sdrop, IdText=sIdText)
Expand All @@ -1353,9 +1353,8 @@ def unroll_to_tpl(self):
self.lgn_to_pgn(lgn)

logger.info(
"Unroll progress - lgn_to_pgn done {0} for session {1}".format(
"Unroll progress - lgn_to_pgn done %d for session %s",
len(self._start_list), self._session_id
)
)
self_loop_aware_set = self._loop_aware_set
for lk in self._lg_links:
Expand Down Expand Up @@ -1584,8 +1583,8 @@ def unroll_to_tpl(self):
sIdText = slgn._getIdText("outputPorts")
if llink.get("is_stream", False):
logger.debug(
"link stream connection %s to %s"
% (data_drop["oid"], output_drop["oid"])
"link stream connection %s to %s",
data_drop["oid"], output_drop["oid"]
)
data_drop.addStreamingConsumer(output_drop, IdText=sIdText)
output_drop.addStreamingInput(data_drop, IdText=sIdText)
Expand All @@ -1595,9 +1594,8 @@ def unroll_to_tpl(self):
# print(data_drop['nm'], data_drop['oid'], '-->', output_drop['nm'], output_drop['oid'])

logger.info(
"Unroll progress - links done {0} for session {1}".format(
"Unroll progress - links done %d for session %s",
len(self._lg_links), self._session_id
)
)

# clean up extra drops
Expand All @@ -1620,9 +1618,8 @@ def unroll_to_tpl(self):
# del sl_drop['gather-data_drop']

logger.info(
"Unroll progress - extra drops done for session {0}".format(
"Unroll progress - extra drops done for session %s",
self._session_id
)
)
ret = []
for drop_list in self._drop_dict.values():
Expand Down
2 changes: 1 addition & 1 deletion daliuge-translator/dlg/dropmake/pgt.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def to_pg_spec(self, node_list, ret_str=True, num_islands=1, tpl_nodes_len=0,
The pg_spec template is what needs to be send to a deferred deployemnt
where the daliuge system is started up afer submission (e.g. SLURM)
"""
logger.debug("tpl_nodes_len: %s, node_list: %s" % (tpl_nodes_len, node_list))
logger.debug("tpl_nodes_len: %s, node_list: %s", tpl_nodes_len, node_list)
if tpl_nodes_len > 0: # generate pg_spec template
node_list = range(tpl_nodes_len) # create a fake list for now

Expand Down

0 comments on commit 3068a2f

Please sign in to comment.