Warn on long presubmits, like on long hooks

Presubmits when uploading occasionally take a very long time - over a
minute - and after the fact there is no easy way to know why. This makes
fixes to slow presubmits take longer.

This change builds on crrev.com/c/2532895 to print a message when any
individual presubmit function takes longer than ten seconds. During
normal usage this is a NOP but it will presumably find the long poles
when presubmits are running particularly slowly.

This is similar to gclient runhooks where any hooks that take longer
than ten seconds have their run time printed.

Change-Id: If57ed35d7a7d221f6380e9b97cf72af56f75e441
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2911594
Reviewed-by: Dirk Pranke <dpranke@google.com>
Commit-Queue: Bruce Dawson <brucedawson@chromium.org>
changes/94/2911594/6
Bruce Dawson 4 years ago committed by LUCI CQ
parent f0bcfdd702
commit 2bdc49fadc

@ -1678,8 +1678,11 @@ class PresubmitExecuter(object):
e_value),
e_tb)
elapsed_time = time_time() - start_time
if elapsed_time > 10.0:
sys.stdout.write(
'%s took %.1fs to run.\n' % (function_name, elapsed_time))
if sink:
elapsed_time = time_time() - start_time
status = rdb_wrapper.STATUS_PASS
if any(r.fatal for r in result):
status = rdb_wrapper.STATUS_FAIL

Loading…
Cancel
Save