Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status table #1020

Closed
wants to merge 17 commits into from
Closed

Status table #1020

wants to merge 17 commits into from

Conversation

moroten
Copy link
Contributor

@moroten moroten commented Sep 15, 2015

This series of commits creates a new status output, inspired by https://buckbuild.com/static/buck-build-15fps.gif at https://buckbuild.com/. I've tried to make the console work well when resizing. It does not fill the whole console window, by purpose, so that the user can see the latest output above the currently running tasks.

Estimating the time left is of the simplest kind without using the .ninja_log.

Use NINJA_STATUS_TABLE as well as NINJA_STATUS to configure the top status line in the table.

It has not been tested for user input during pool=console. I've been running an earlier draft for a while on a quite big project (50 MB ninja file) for a few months now, on Windows. Only basic tests has been performed on Linux, building Ninja itself.

> ninja.exe all
[38/55] LINK ninja.exe
Generating code
Finished generating code
[50/55] 26.7 elapsed,  2.7 left
 5.8s CXX build\test.obj
 4.2s CXX build\manifest_parser_test.obj
 1.0s CXX build\ninja_test.obj
 0.8s CXX build\edit_distance_test.obj
 0.8s CXX build\state_test.obj
 0.1s CXX build\hash_collision_bench.obj

See also https://groups.google.com/d/msg/ninja-build/lK5YVv5Y4T4/fjqQAjoJKrsJ

@sgraham
Copy link
Contributor

sgraham commented Sep 15, 2015

Cool, I like the output. :)

Minor build issue on VS2015:
d:\src\ninja\src\build.cc(327): warning C4457: declaration of 'edge' hides function parameter

I'm not sure about console_height/2 for the limit, but it also seems heavy to add another config parameter for that, so maybe it's fine.

@moroten
Copy link
Contributor Author

moroten commented Sep 16, 2015

I did try console_height/4 (above), but I thought the stdout/stderr above was too small when getting compiler errors.

@moroten
Copy link
Contributor Author

moroten commented Sep 16, 2015

I replaced the edge variable with cur_edge. Thanks for spotting.

(Is git-rebase the method to use on GitHub? Where can I see the differences between the versions? I'm used to Gerrit where I rebase all the time.)

@nicolasdespres
Copy link
Contributor

I like this output too.

I am wondering how we could make it fit in a larger patch addressing most of the issues referenced by #746.

@nicolasdespres
Copy link
Contributor

It would be nice to have enough tools inside Ninja to be able to implement such output as an external filter command.

@wjakob
Copy link

wjakob commented Oct 25, 2016

This looks very interesting. How would this visualization behave when compiling on a machine with many cores that are becoming increasingly common? The latest Xeon Phi machines boot up with 256 virtualized cores, which means that it won't generally be possible to even fit that many lines on a screen.

@moroten
Copy link
Contributor Author

moroten commented Oct 26, 2016

In src/line_printer.cc:88, LinePrinter::PrintTemporaryElide(), the code states lines_above_us = max(1, console_height / 2). The status table will never fill more than half of your console, it adds ... at the end if any lines were cropped.

Fredrik Medley and others added 7 commits October 5, 2018 21:36
GetFullPathName previously failed silently on long path names resulting
in uninitialized path result.

Signed-off-by: Fredrik Medley <[email protected]>
The goal with this commit is to get the smart terminal to work with
msys2 bash, but keeping the rest as in the msvc version. This way,
subprocesses are spawned the same way, not using 'sh -c', in both
msys2 and msvc so the build.ninja files can be reused.

Signed-off-by: Fredrik Medley <[email protected]>
The msys2 system sends the Ctrl+C signal through the posix layer.
Therefore, create a dummy posix thread that is waiting for the signals
and forwards them to the Win32 interruption handling function.

Signed-off-by: Fredrik Medley <[email protected]>
The elapsed time resolution of milliseconds is probably only useful for
debugging or profiling, in which case the .ninja_log can be used instead.
Therefore, print the elapsed time in minutes and seconds instead.

Signed-off-by: Fredrik Medley <[email protected]>
Use the %l (sorry for not finding any other letter) to print the estimated
time left in the status.

Signed-off-by: Fredrik Medley <[email protected]>
Instead of just printing status on one line, allow printing status in a
full table. To not hide any upcoming output of error message etc., the
status table must never cover the whole terminal. Also handle resizing the
window in a good way.

Signed-off-by: Fredrik Medley <[email protected]>
Sort the table with the slowest command at the top. It is probably more
interesting to follow up the slow commands than the fast ones.

Another possibility is to replace finished rows with new commands, but
then there will just be a mixture of slow and fast ones all over the
place.

Signed-off-by: Fredrik Medley <[email protected]>
Enable the table with all running threads by default. It will still only
be enabled for smart consoles.

Signed-off-by: Fredrik Medley <[email protected]>
moroten and others added 8 commits October 5, 2018 22:13
A timeout can be used to continuously update information for the user or
potentially abort jobs that are running forever.

Signed-off-by: Fredrik Medley <[email protected]>
Signed-off-by: Fredrik Medley <[email protected]>
In the smart console, the status line is continuously overwritten. When
ninja is done, the console is left empty. Clarify that everything went
well by writing '[STATUS] Finished' on the last line.

Signed-off-by: Fredrik Medley <[email protected]>
The estimation does still not estimate time left by using the log file,
the estimate is just presented on top of the table.

Signed-off-by: Fredrik Medley <[email protected]>
The temporary lines just overwrite each other in a speed impossible to
read. Assume the user wanted to see them, so print all commands in a
normal manner.

Signed-off-by: Fredrik Medley <[email protected]>
A build log on a dumb terminal can be big, even for a fast build. Reduce
the output on dumb terminal by printing less frequent if
NINJA_STATUS_SLEEP is set.
@Sarcasm
Copy link

Sarcasm commented Feb 4, 2019

Just a few comments, as I have been using these patches for about 10 months now, and like to share my interest in it.
I find it very useful!

Most notably, I can see which files are taking most of the time to build, and how long that is.
That makes me want to fix the issues with this files, as compilation time in C++ can be quite painful.

I've got some issue with it:

  • I have yet to see a correct estimate for the time left
  • at the end of compilation, there if very often some empty lines after the prompt, which is unusual compared to any other shell commands, event ncurses-based applications, and annoying because when there are compilation errors you often need to scroll the output

@mathstuf
Copy link
Contributor

mathstuf commented Feb 4, 2019

at the end of compilation, there if very often some empty lines after the prompt, which is unusual compared to any other shell commands, event ncurses-based applications, and annoying because when there are compilation errors you often need to scroll the output

I suspect this PR is not using the alternate window effectively (though I've not looked or tested the code). A screenshot would help.

@Sarcasm
Copy link

Sarcasm commented Feb 4, 2019

Before starting ninja, cursor it at the bottom of the window:

image

After ninja ran, the cursor is not at the bottom, there is a few rows left at the bottom of the window:

image

@mathstuf
Copy link
Contributor

mathstuf commented Feb 4, 2019

Using the alternate window should fix that, but you might also lose the [6/6] Finished line as well if it weren't echoed again upon switching back to the primary window. Compiler warnings/errors may also need special handling.

@Sarcasm
Copy link

Sarcasm commented Feb 4, 2019

What's this "alternate window" thing?

@mathstuf
Copy link
Contributor

mathstuf commented Feb 4, 2019

@Sarcasm
Copy link

Sarcasm commented Feb 4, 2019

Ok thanks, indeed, that could be it.

@Sarcasm
Copy link

Sarcasm commented Feb 4, 2019

Tried it, but we lose the ninja output on termination, which is not nice.
Also, when ninja runs, what was there before is cleared, which is also unusual.

I feel like maybe it will be the best to not clear out on exit, but just to leave the last few lines.
It could be nice as so that we have the elapsed time still visible eventually, and maybe the time of the last command.

To get an idea, I killed ninja with SIGSEGV so that it does not do the cleanup.
This leave the cursor to the desired position.

image

@moroten
Copy link
Contributor Author

moroten commented Feb 19, 2019

Thank you all for the feedback. Sorry for the late reply.

I saw a PR which always printed the longest running edge instead of just the latest started or latest finished. That behaviour is probably enough for my use case. Then I can see what commands are slow, even though the exact elapsed time is not there. (Looked around but could not find that PR again.)

Anyway, I'm switching to Bazel since so I will not maintain this PR any more. Please feel free to take it over (copy it?) or just close it.

@jonesmz

This comment was marked as abuse.

@jhasse jhasse closed this Aug 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants