Commit graph

9 commits

Author SHA1 Message Date
Avery Pennarun
048df77aa6 redo-log: don't show status line until >1.0 seconds after starting.
For very short builds, it looks nicer to not flicker the status line
for a split second.
2018-11-19 15:42:05 -05:00
Avery Pennarun
d82326a39d Add --color and --no-color options.
By default, we auto-detect color mode (if it's a tty, color default on,
else off).  But you can force it either way.
2018-11-19 11:22:53 -05:00
Avery Pennarun
f49d311471 redo-log: --debug-pids works properly again.
Pretty-printing from redo-log was accidentally using the redo-log pid
instead of the pid parsed from the raw logs.
2018-11-19 11:00:47 -05:00
Avery Pennarun
bc632982fc Split --raw-logs into --no-pretty and --no-log options.
--no-log: don't capture logs or run redo-log (same as pre-redo-log redo)
  --no-pretty: don't pretty-print logs, print @@REDO lines.

The latter is an option to both redo and redo-log.
2018-11-19 10:55:56 -05:00
Avery Pennarun
8b5a567b2e redo-log: prioritize the "foreground" process.
When running a parallel build, redo-log -f (which is auto-started by
redo) tries to traverse through the logs depth first, in the order
parent processes started subprocesses.  This works pretty well, but if
its dependencies are locked, a process might have to give up its
jobserver token while other stuff builds its dependencies.  After the
dependency finishes, the parent might not be able to get a token for
quite some time, and the logs will appear to stop.

To prevent this from happening, we can instantiate up to one "cheater"
token, only in the foreground process (the one locked by redo-log -f),
which will allow it to continue running, albeit a bit slowly (since it
only has one token out of possibly many).  When the process finishes,
we then destroy the fake token.  It gets a little complicated; see
explanation at the top of jwack.py.
2018-11-17 11:13:20 -05:00
Avery Pennarun
e10bd1a9eb redo-log: correctly indent first level of recursion.
We don't want to print "-" at all, but that doesn't mean we should
always omit indentation for the first level.
2018-11-17 10:27:44 -05:00
Avery Pennarun
5c4f710f4e Raw logs contain @@REDO lines instead of formatted data.
This makes them more reliable to parse.  redo-log can parse each line,
format and print it, then recurse if necessary.  This got a little ugly
because I wanted 'redo --raw-logs' to work, which we want to format the
output nicely, but not call redo-log.

(As a result, --raw-logs has a different meaning to redo and
redo-log, which is kinda dumb.  I should fix that.)

As an added bonus, redo-log now handles indenting of recursive logs, so
if the build was a -> a/b -> a/b/c, and you look at the log for a/b, it
can still start at the top level indentation.
2018-11-17 10:27:44 -05:00
Avery Pennarun
e1f30c2765 redo-log: status line should use actual terminal width.
This lets us pack more onto on line if the terminal is wider, and
operate correctly if it's narrower.
2018-11-17 10:27:44 -05:00
Avery Pennarun
b2411fe483 redo-log: capture and linearize the output of redo builds.
redo now saves the stderr from every .do script, for every target, into
a file in the .redo directory.  That means you can look up the logs
from the most recent build of any target using the new redo-log
command, for example:

	redo-log -r all

The default is to show logs non-recursively, that is, it'll show when a
target does redo-ifchange on another target, but it won't recurse into
the logs for the latter target.  With -r (recursive), it does.  With -u
(unchanged), it does even if redo-ifchange discovered that the target
was already up-to-date; in that case, it prints the logs of the *most
recent* time the target was generated.

With --no-details, redo-log will show only the 'redo' lines, not the
other log messages.  For very noisy build systems (like recursing into
a 'make' instance) this can be helpful to get an overview of what
happened, without all the cruft.

You can use the -f (follow) option like tail -f, to follow a build
that's currently in progress until it finishes.  redo itself spins up a
copy of redo-log -r -f while it runs, so you can see what's going on.

Still broken in this version:

- No man page or new tests yet.

- ANSI colors don't yet work (unless you use --raw-logs, which gives
  the old-style behaviour).

- You can't redirect the output of a sub-redo to a file or a
  pipe right now, because redo-log is eating it.

- The regex for matching 'redo' lines in the log is very gross.
  Instead, we should put the raw log files in a more machine-parseable
  format, and redo-log should turn that into human-readable format.

- redo-log tries to "linearize" the logs, which makes them
  comprehensible even for a large parallel build.  It recursively shows
  log messages for each target in depth-first tree order (by tracing
  into a new target every time it sees a 'redo' line).  This works
  really well, but in some specific cases, the "topmost" redo instance
  can get stuck waiting for a jwack token, which makes it look like the
  whole build has stalled, when really redo-log is just waiting a long
  time for a particular subprocess to be able to continue.  We'll need to
  add a specific workaround for that.
2018-11-17 10:27:43 -05:00