With --debug-locks, print a message when we stop to wait on a lock.
Helps in seeing why a particular process might be stopped, and in detecting potential reasons that parallelism might be reduced.
This commit is contained in:
parent
675a5106d2
commit
f70c028a8a
2 changed files with 19 additions and 5 deletions
17
builder.py
17
builder.py
|
|
@ -1,6 +1,6 @@
|
||||||
import sys, os, errno, stat
|
import sys, os, errno, stat
|
||||||
import vars, jwack, state
|
import vars, jwack, state
|
||||||
from helpers import log, log_, debug2, err, unlink, close_on_exec
|
from helpers import log, log_, debug2, err, warn, unlink, close_on_exec
|
||||||
|
|
||||||
|
|
||||||
def _possible_do_files(t):
|
def _possible_do_files(t):
|
||||||
|
|
@ -231,9 +231,12 @@ def main(targets, shouldbuildfunc):
|
||||||
BuildJob(t, f, lock, shouldbuildfunc, done).start()
|
BuildJob(t, f, lock, shouldbuildfunc, done).start()
|
||||||
|
|
||||||
# Now we've built all the "easy" ones. Go back and just wait on the
|
# Now we've built all the "easy" ones. Go back and just wait on the
|
||||||
# remaining ones one by one. This is non-optimal; we could go faster if
|
# remaining ones one by one. There's no reason to do it any more
|
||||||
# we could wait on multiple locks at once. But it should
|
# efficiently, because if these targets were previously locked, that
|
||||||
# be rare enough that it doesn't matter, and the logic is easier this way.
|
# means someone else was building them; thus, we probably won't need to
|
||||||
|
# do anything. The only exception is if we're invoked as redo instead
|
||||||
|
# of redo-ifchange; then we have to redo it even if someone else already
|
||||||
|
# did. But that should be rare.
|
||||||
while locked or jwack.running():
|
while locked or jwack.running():
|
||||||
state.commit()
|
state.commit()
|
||||||
jwack.wait_all()
|
jwack.wait_all()
|
||||||
|
|
@ -248,7 +251,11 @@ def main(targets, shouldbuildfunc):
|
||||||
break
|
break
|
||||||
fid,t = locked.pop(0)
|
fid,t = locked.pop(0)
|
||||||
lock = state.Lock(fid)
|
lock = state.Lock(fid)
|
||||||
lock.waitlock()
|
lock.trylock()
|
||||||
|
if not lock.owned:
|
||||||
|
if vars.DEBUG_LOCKS and len(locked) >= 1:
|
||||||
|
warn('%s (WAITING)\n' % _nice(t))
|
||||||
|
lock.waitlock()
|
||||||
assert(lock.owned)
|
assert(lock.owned)
|
||||||
if vars.DEBUG_LOCKS:
|
if vars.DEBUG_LOCKS:
|
||||||
log('%s (...unlocked!)\n' % _nice(t))
|
log('%s (...unlocked!)\n' % _nice(t))
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,20 @@ def _cerr(s):
|
||||||
def _bwerr(s):
|
def _bwerr(s):
|
||||||
log_('redo: %s%s' % (vars.DEPTH, s))
|
log_('redo: %s%s' % (vars.DEPTH, s))
|
||||||
|
|
||||||
|
def _cwarn(s):
|
||||||
|
log_('\x1b[33mredo: %s\x1b[1m%s\x1b[m' % (vars.DEPTH, s))
|
||||||
|
def _bwwarn(s):
|
||||||
|
log_('redo: %s%s' % (vars.DEPTH, s))
|
||||||
|
|
||||||
|
|
||||||
if os.isatty(2):
|
if os.isatty(2):
|
||||||
log = _clog
|
log = _clog
|
||||||
err = _cerr
|
err = _cerr
|
||||||
|
warn = _cwarn
|
||||||
else:
|
else:
|
||||||
log = _bwlog
|
log = _bwlog
|
||||||
err = _bwerr
|
err = _bwerr
|
||||||
|
warn = _bwwarn
|
||||||
|
|
||||||
|
|
||||||
def debug(s):
|
def debug(s):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue