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
A simple protocol for derivations to report progress #896
Comments
Instead of a directory, could we pass the builder script more pipes beyond the standard streams? That kinda feels cleaner to me though I could be convinced otherwise. |
Indeed a pipe would be more efficient and easier to implement. |
Sure, I don't feel very strongly about filename, format, or whether it's a pipe or not! I just think having something like this would be helpful.
|
Yeah, a pipe, but I see a catch: AFAIK most packages use plain make that does no progress reporting at all. Maybe with a nontrivial patch to our default make... |
@vcunat the way I was thinking about that: some tools will be easier to plug into progress than others, but we could still express textual progress with make: "configuring -> building -> installing -> testing", and we could reserve a special "I have no clue" value for the progress bar so it doesn't give false precision for cases like that. The way I envision it:
Where
The
The
|
Older closely related work: https://github.com/qknight/nix-build-view |
BTW, if we monitored the usr+sys time used by each build user, that might be a pretty stable value on comparable HW, not much affected by waiting on I/O, number of threads available, etc. These might be also collected on Hydra so that client could fetch the time estimate. |
IMO the data structure should be a tree of fixed-finite progresses, and the protocol a stack. So the generic builder script would do |
@Ericson2314 what would that be used for? Are people likely to care about that level of detail? Also, packages don't ever download things in Nix. I'd rather not make it too complicated and get most of the benefit with the least effort. |
@copumpkin I guess it doesn't seem to complicated to me :)? Think how often we template together builder script, (generic stuff, haskell and other languages). The template script cannot know the final number of steps but the templating processes is already a "tree of delegations" matching my scheme. |
Sketch it out in a bit more detail then? It's just not clear to me what types of scenarios this would help with over the basic proposal. |
Here's one:
|
Nix itself can reuse the tree-based logic for combing the progress of multiple derivations being built at a time. |
Also recursive make :-) But I'm not really convinced that allowing nesting would help much to get more precise idea about the progress. |
But |
Now what would be complicated is trying to properly support parallelism. Then the push-pop protocol won't work any more, but I'm happy to kick the bucket on that :). |
Ultimately it just seems like you'd get 90% of the benefit without nesting, If we maintain the tree after the build to get fine-grained stats about I also want to consider the difficulty implementing progress reporting On Thu, May 5, 2016 at 12:14 John Ericson notifications@github.com wrote:
|
I just don't see how it would work otherwise. What number of steps can we pre-compute that isn't just just the number of phases? But yeah for hydra, or for more advanced future front-ends, would be where this shine the most. |
@Ericson2314 CMake already computes its own progress, using whatever mechanisms it has. curl can output progress, as can git and other VCSes. I'm basically saying let individual builders figure out how to deal with their own notions of progress, and we just feed those back to Nix. For things where that's hard, I'm just saying "let's not bother trying to compute a percentage", rather than "let's figure out how to make it work" |
@Ericson2314 anyway, if you're willing to implement your idea please don't let me dissuade you, but I don't want the perfect to be the enemy of the good here. I personally don't want to be figuring out how to do progress reporting for things that haven't supported it in the past; I'd rather just figure out the simplest way to pass some notion of progress (or even cop out if we can't compute a number) to our users so that we can cut down on the painfully noisy builds that plague Nix today. |
More importantly, this is still extensible – if we figure out some way to measure progress for some class of hierarchical builds, we can plug that layer into those builders. |
Yeah I'd be willing to implement this. Ignoring messages for now, pipe protocol represents:
For a single status bar, I'd do "rational number interpretation" where the subtree adds to 1 and sibling checkpoints have the same weight. For example Might even be easier to do messages "out of band" on a separate pipe --- they need not correspond to checkpoints. |
Is that logic ultimately just going to emit a fraction? If so, why does it need to be built into Nix as opposed to Nix just consuming the fraction it outputs, and people layering it into their builders, as @vcunat was suggesting? Like I could still envision Nix consuming a simple "[number or ?] [status]" format, and then some builders pulling in your nested progress helpers (which then live in nixpkgs) if they can support nested progress. Or do you envision Nix actually doing something useful with that nesting information? |
I think an easy first step would be to:
Once these are done, granularity can be made finer by introspecting build systems. |
Just for reference: https://lastlog.de/blog/posts/nix-build-view_using_ncurses.html |
IIRC an important argument was that the UI would better be completely decoupled from nix itself. (Dbus was also suggested as a standard way to publish similar kinds of information.) |
I would really like to see this; in rough order of priority, what I care about is:
If I have time over the holidays I might have a go at @stapelberg 's idea. |
dbus would be a non-starter for any non-Linux platform |
Continuing from the analysis I did in #1297 (comment), I've come to the conclusion that Cap'n Proto is probably the right choice for this, since:
This may seem like overengineering, since a FIFO could in theory suffice (assuming that there is something like |
My main concern is adding a fairly meaty dependency to Nix for something that doesn't really need to be very complicated. I'm wary of bringing in a big fancy framework "just in case" someone thinks of something a build might want to report. I mostly think we should stick to the traditional derivation outputs mechanism for most things builds will produce, and then do as little work as we can to add progress to that. |
Pipes: I'm not that sure about speed, but libuv uses "named pipes" on Windows, so there's probably at least one way there. I don't think we need to worry much about the progress-reporting feature on Windows (or even its speed there). The format can probably be made so simple that (de)serialization can be just written by hand. |
Yeah, we were just talking about simple JSON over a pipe on IRC. Seems like it would cover most common cases and make it fairly easy to extend, while still being shell-friendly. |
@edolstra I wouldn't mind putting together an attempt at the simplest progress reporting mechanism I can think of. My main concern is a good way to do fancy terminal updates without bringing in new dependencies. Do you have a preference for how to do fancy terminal stuff in Nix today? I guess now that |
Commit 4af2611 adds support for derivations to use the Nix 1.12 progress mechanism. Thus
A GUI or a full-screen TUI can be implemented by subclassing @copumpkin Just ANSI escape codes. |
BTW, builders send progress updates to Nix by writing them to stderr as |
That is awesome, thanks! I don't feel super strongly about pipe vs stderr but the latter would reduce potential ambiguity. Only one real comment on the current design: Adding an optional nesting option (start with a parent ID) would allow us to talk about e.g., "compiling" as a high-level activity, with individual components as sub-activities. It might also improve uniformity of the code, since stepping higher up, you can think of all of an individual build's activities as sub-activities on the build itself. Otherwise, this looks great! |
@copumpkin I've added nesting (not exposed to builders though, but used to expose the relationship between top-level activities such as substituting and lower-level activities like downloading). Also, builders can now update the "phase" they're in (0ac35b6). So, for example, in stdenv's
|
@edolstra that's awesome! |
@edolstra are you leaning towards leaving these messages in stderr, or do you think the pipe is the way to go? I don't feel strongly |
I would use an additional file descriptor, which avoids anything else getting in the way along with any need for edit Oh, I should have scrolled up. Nothing that's not been said before! |
How do I see a demo of the progress bar? I have built Nix from the tip of master but I am not sure what commands/options are needed to see the progress messages. |
The progress bar is only enabled for the
This works only as root because progress messages aren't tunneled over the nix-daemon client connection. (I'm working on that right now.) I also use
or with
|
Any progress on this? Being able to see how many derivations |
@canndrew this is already essentially possible, just not neatly integrated. On my chromebook, which has to build everything from source (armv7) I usually do this so I have an idea of how long it'll take: just run (edit: shorter equivalent command) |
Closing this since Nix 2 has a progress indication mechanism. |
While watching several simultaneous curl downloads in a fixed-output derivation compete for my terminal real estate to report their progress, a thought occurred to me: we all agree that Nix build output is generally too noisy, but we also like to see progress. I love seeing some of the other package managers and their fancy orderly progress reporting.
So how about we do this:
nix-support/progress
. In there it should find some predefined format: perhaps<numeric progress out of 100> <short status description if applicable>
or something similar. It can either poll or use fancier file watching mechanisms depending on the platform.progress
file, updated in an orderly fashion using fancier terminal tricks. If there is no progress file, you just see a notice that the build is happening.The text was updated successfully, but these errors were encountered: