Conversation
|
@shindere needs to know about this proposal. |
|
Yes, thanks!
In short: I am fully in favour of this proposal. Actually, I had the
smae idea, with the very same source of inspiration (Linux Kernel),
but my plan was to propose it after the makefiles had been merged
to minimize the number of changes.
I am supposed to be on vacation until January 9th and I would like to be
given an opportunity to review this before it gets merged so can this
please wait until I'm back?
Thanks!
|
|
Two questions:
|
|
I am generally in favor, this makes the logs much more readable.
At the moment,
I did a quick benchmark of trunk This PR |
|
I’m also for this! For the slowdown, I think it may be possible to avoid the call to |
|
I just pushed a version that uses @shindere : glad you like the idea. My next wish is a less verbose output from ocamltest... @nojb: the code that sets OCAMLC and OCAMLOPT could also set OCAMLC_NAME and OCAMLOPT_NAME variables (e.g. to |
|
Xavier Leroy (2023/01/02 00:54 -0800):
I just pushed a version that uses `$(info ...)` instead of ***@***.*** "..."`, it should run faster. Thanks a lot @dra27 for the suggestion!
@shindere : glad you like the idea. My next wish is a less verbose
output from ocamltest...
You mean all the time, or you mean when run by the CI? In the latter case
I have a branch that suppresses the output of ocamltest whn run by the
testsuite to just print the report, because I had the understanding that
this was what you were actually looking for. It had a bug which I never
understood so I never finished but if you like the idea I can definitely
give it one more try next week.
@nojb: the code that sets OCAMLC and OCAMLOPT could also set
OCAMLC_NAME and OCAMLOPT_NAME variables (e.g. to `OCAMLC` or
`OCAMLC.OPT`), which could then be used when printing the command.
That looks cool. The variable could even be called `COMPILER_NAME` so
that the same code could be used for printing, no matter which compiler.
One other possibility would be to distinguish, in this variable,
`boot/ocamlc` from `./ocamlc` to make it clear whether it's the boot
compiler which is used, or not.
One further generalisation step would be to use e.g. `COMMAND`,
`INPUT_FILE` and `OUTPUT_FILE`, although the two last ones could also be
just `$<` and `$@` and in this case we would use the same display code
for all the commmands, which would make it easier to get a
by-construction guarantee that the printing format is consistent accross
all the invoked commands.
|
I played around with the PR and did what seems to me like some improvements (as well as adapting more of the build system), see xavierleroy#1. |
I mean when run by and the current output should be explicitly requested with a |
|
I don't have a development environment handy to test this at the moment, but if there are a lot of generated files then you may be able to speedup the Windows build by using the GNU Make |
|
There aren't too many generated files, fortunately (at least in the main build). Alas, |
|
Just started to review this. Many thanks for the cool work. The result Quick question: how important is the vertical alignment of filenames
Am I correct that, in its present state, the PR does not provide any way to In the implementation I have in mind, we would have a Is the idea okay and, if yes, shall I try to add it to the present PR or rather to How about the |
Not important to me.
I think there will always be "raw" commands that occur too rarely to get a special output. It's OK, especially if they fit on one line, which is the case for
Correct. But there's always
Because there will always be "raw" commands, your "V=0" mode will not suppress all output, and it's better to rely on |
It wasn't problematic, but we were doing it for |
|
Nicolás Ojeda Bär (2023/01/11 09:14 -0800):
> See also `ln` commands for which @nojb removed the nice output recently, as it was problematic (I guess).
It wasn't problematic, but we were doing it for `ln` and not for
`mkdir`, `cp`, etc; we should do it either for all of them or none of
them, and it wasn't clear if it was worth doing it for these commands
by the reasons mentioned.
To me, it wouldn't hurt to do it for such commands and would make things
clearer. It's not a lot of noise and still it can be precious, whereas
not having it can be problematic.
|
|
Xavier Leroy (2023/01/11 09:03 -0800):
> Quick question: how important is the vertical alignment of filenames to you (poor ;-) ) sighted people?
Not important to me.
OK so if this is not retained in future changes you won't complain,
IIUC.
> How about the mkdir command? Shoudln't it get a nice output, too?
I think there will always be "raw" commands that occur too rarely to
get a special output. It's OK, especially if they fit on one line,
which is the case for `mkdir` commands. See also `ln` commands for
which @nojb removed the nice output recently, as it was problematic (I
guess).
My preference would be to have something homogenous but it does not need
to happen in this PR.
> Am I correct that, in its present state, the PR does not provide any way to
> see the details of a command?
Correct. But there's always `make -n`.
Will that really produce the very same output as we got before? I'm
indoubt but again, no problem, I'll reivew the current PR as it is and
submit adjustements once it's merged.
> In the implementation I have in mind, we would have a V variable to
> control the verbosity. Basically, make V=0 would be equivalent to make -s and would
> let one verify that the build does not yield any unexpected message (the
> output of Make V=0 should be empty), make V=1 would print the nice new
> messages and make V=2 would print the commands in full details as before.
Because there will always be "raw" commands,
I don't see this as a fatality. I do think it's possible to have control
over all the commands, especially after the refactoring.
your "V=0" mode will not suppress all output,
Let's bet. :-)
and it's better to rely on `make -s`.
Incidnetally, here is the output of `make -s` on latest trunk:
```
File "../../stdlib/stdlib.mli", line 1500, characters 15-28:
1500 | module Stack = Stdlib__Stack
^^^^^^^^^^^^^
Alert unsynchronized_accesses: module Stdlib__Stack
Unsynchronized accesses to stacks are a programming error.
```
There's something similar to your "V=1" and "V=2" in the Coq
makefiles, if I remember correctly.
I am pretty sure all of us have the same source of inspiration, namely
the Linux kernel, so what you write does not surprise me so much.
|
|
Xavier Leroy (2022/12/30 09:23 -0800):
Q: But if a command fails, I may need to see it in full!
A: Most of the time, we look at the error messages from the compiler,
not at the command itself. But in the rare case where you need to see
the command in full, there's a simple trick. After the failure,
just do `make -n | head`. With the `-n` option, commands are printed
in full even when preceded by `@`. If you're in a sequential
build, the command that failed is the first command to do again, so it
should be the first line of the `make -n` output. If you're in a
parallel build, you can reproduce the failure with `make`, then see
the command with `make -n | head`.
The limit to this trick is that `-n` is dry-run so the commands are
indeed printed, but not executed. So it may indeed work to run `make -n`
just after having run `make`, but oneshould keep in mind that this can
nnot be generalized, as sometimes executing a command really makes a
difference for the rest of the build and which commands will be executed
afterwards.
It would also possible to have a make variable that controls whether
to abbreviate commands or leave them printed in full. But I
don't know how to do this without some duplication and extra
`if...else...endif` in the Makefiles.
This has been implemented at the top of the `less-verbose-logs` branch
of `shindere/ocaml`: `make V=1` prints the commands the new way
(default) whereas `make V=2` prints the commands as they were printed
before this PR. Could this please be cherry-picked into this PR?
With the above mentionned PR, I was able to get a diff of build logs
before and after the PR (see attached - [buildlog-patch.patch](https://github.com/ocaml/ocaml/files/10424363/buildlog-patch.patch))
|
|
Gabriel Scherer (2022/12/30 13:21 -0800):
1. The "how to see the full command for reproducing a failure?"
question is important. You answer in this PR, but could you put the
answer in HACKING.adoc as well to make it easy to find again in the
future?
This point from @gasche has not been addressed yet and, at the moment,
thePR does not have a Changes entry.
|
I'm a computer scientist: I don't know this "2" thing you're using, only "0" and "1" :-) More seriously, according to Stackoverflow wisdom, CMake, uses |
|
Xavier Leroy (2023/01/16 06:19 -0800):
> This has been implemented at the top of the `less-verbose-logs` branch
> of `shindere/ocaml`: `make V=1` prints the commands the new way
> (default) whereas `make V=2` prints the commands as they were printed
> before this PR.
I'm a computer scientist: I don't know this "2" thing you're using,
only "0" and "1" :-)
I'll tell you about the wonders of Peano numbers next time we have a
coffee together. You'll see, you're gonna be amazed!
More seriously, according to Stackoverflow wisdom, CMake, uses `make
VERBOSE=1` and GNU autotools `make V=1` to select verbose output. I
strongly suggest we use one of these two conventions.
Here is the relevant bit of output of Linux's `make help`:
```
make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build
make V=2 [targets] 2 => give reason for rebuild of target
```
My understanding of this is that it gives a point to each of us. One
point to you because it distinguishes `V=0` from `make -s`. One point
for me because they do use more than two values.
I can just say that what I proposed seems the more coherent to me: it
would make sense to me that `V=0` is an equivalent to `make -s` and it
is actually very easy to implement by modifying `MAKEFLAGS`; `V=1` what
we have and then we have 2 for all commands, why not 3 to mean `run the
commands in verbose mode`.
It may be interesting to hear the opinions of others. Finally between V
and VERBOSE I'd go for the first one which is more concise. And please,
fellfree to modify the commit directly and to take the authorship.
|
My opinion: I haven't looked at this and don't plan to, but it looks like there is a general consensus in favor of the change as, broadly, originally proposed, and less consensus on the proposed addition of an explicit verbosity setting. My recommendation would be to first merge the change at the scope of the original proposal, and split the verbosity setting patches to a follow-up PR where you can discuss more if you want. (Re. V versus VERBOSE: in general I'm in favor of longer options because they are nicer on the reader, and I read more than I write. This being said, I guess I'm the sort of people who does not mind seeing long commands in the build logs.) |
|
For the flag, my vote goes to |
|
Wouldn't it be nice, finally, to use floating pointnumbers? That way we
would have a main verbosity number which would be the integral part, and
then we could use the numbers after the dot to encode the verbosity of
different components and subcommands, which would give us all the
control and flexibility we can drema of.
Plus, it would be future proof because, if real numbers turn out to not
be enough to encode a verbosity setting, then we coudl very easily say
that the numbers we use are actually complex numbers.
|
There’s no major reason not to have both? I keep meaning to add that in testsuite/Makefile for |
|
David Allsopp (2023/01/16 08:46 -0800):
> Re. V versus VERBOSE: in general I'm in favor of longer options because they are nicer on the reader, and I read more than I write
There’s no major reason not to have both? I keep meaning to add that
in testsuite/Makefile for `KEEP_TEST_DIR_ON_SUCCESS` as my usage of it
always begins with `grep KEEP Makefile` to remind me what the full
name of the variable is…
I really like the good intentions behind the proposal. No sarcasm
intended, I do like that. I'm just not sure whether it's a wise way to
go because it will likely create code duplication and/or questions about
which varialbe has the priority if they happen to contradict each
other...
|
Print concise summaries instead of full commands for some of the most verbose commands. For example, print ``` OCAMLC lambda/switch.ml ``` instead of ``` ./boot/ocamlrun ./boot/ocamlc -nostdlib -I ./boot -use-prims runtime/primitives -g -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48 -warn-error +a -bin-annot -strict-formats -I lambda -I utils -I parsing -I typing -I bytecomp -I file_formats -I lambda -I middle_end -I middle_end/closure -I middle_end/flambda -I middle_end/flambda/base_types -I asmcomp -I driver -I toplevel -I tools -c lambda/switch.ml ``` and ``` CC runtime/addrmap.c -> runtime/addrmap.b.o ``` instead of ``` gcc -c -O2 -fno-strict-aliasing -fwrapv -pthread -g -Wall -Werror -fno-common -fexcess-precision=standard -fno-tree-vrp -ffunction-sections -I./runtime -D_FILE_OFFSET_BITS=64 -DCAMLDLLIMPORT= -DIN_CAML_RUNTIME -o runtime/addrmap.b.o runtime/addrmap.c ``` This is work in progress; many Makefiles haven't been touched yet.
This saves the cost of spawning a shell just to write a message, cost that is significant under Cygwin. Suggested by @dra27. This commit changes only the `@echo` introduced by the previous commit. The same trick is applicable to other `@echo` occurrences, however.
868c09e to
228b288
Compare
|
I rebased this patch on top of
Planning to merge tomorrow... |
|
Many thanks. I just find it very odd that `V=0` means something
different from silence but AIUI I'm the only one seeing things that way.
|
Thanks! |
It's still time to make small wishes for 2022. One of mine is less verbose build logs.
The output of
makelooks almost decent when each command fits on one line, as Stuart Feldman envisioned it, and looks like complete gobbledygook otherwise. Unfortunately, OCaml, like all serious projects, has very long build commands, what with all these-Iand-woptions.But there's a trick! The Makefile can run commands silently after printing a short meaningful summary:
I think the Linux kernel build does this (or did it 25 years ago when I last built my own kernels). I learned this trick from Coq, and use it with pleasure in CompCert.
This draft PR applies this trick to (parts of most of) the Makefiles of OCaml. For example, it prints
OCAMLC lambda/switch.mlinstead of
./boot/ocamlrun ./boot/ocamlc -nostdlib -I ./boot -use-prims runtime/primitives -g -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48 -warn-error +a -bin-annot -strict-formats -I lambda -I utils -I parsing -I typing -I bytecomp -I file_formats -I lambda -I middle_end -I middle_end/closure -I middle_end/flambda -I middle_end/flambda/base_types -I asmcomp -I driver -I toplevel -I tools -c lambda/switch.mland
CC runtime/addrmap.c -> runtime/addrmap.b.oinstead of
gcc -c -O2 -fno-strict-aliasing -fwrapv -pthread -g -Wall -Werror -fno-common -fexcess-precision=standard -fno-tree-vrp -ffunction-sections -I./runtime -D_FILE_OFFSET_BITS=64 -DCAMLDLLIMPORT= -DIN_CAML_RUNTIME -o runtime/addrmap.b.o runtime/addrmap.cThe general format is
COMMAND inputfileif there's no ambiguity about the output file, orCOMMAND inputfile -> outputfileotherwise. The format is open to discussions; my only demand is that every output fits on a single line.I attach a full build log for reference: log4.gz
Currently, only the generic compile rules are modified; other rules such as linking steps still print in full. And some Makefiles remain to be adjusted. Yet, the log file is already 3 times shorter (340 k instead of 1M).
As usual, I'll now switch to Q&A mode to speed up discussions.
Q: But if a command fails, I may need to see it in full!
A: Most of the time, we look at the error messages from the compiler, not at the command itself. But in the rare case where you need to see the command in full, there's a simple trick. After the failure, just do
make -n | head. With the-noption, commands are printed in full even when preceded by@. If you're in a sequential build, the command that failed is the first command to re-execute, so it should be the first line of themake -noutput. If you're in a parallel build, you can reproduce the failure withmake, then see the command withmake -n | head.It would also possible to have a make variable that controls whether to abbreviate commands or leave them printed in full. But I don't know how to do this without some duplication and extra
if...else...endifin the Makefiles.Q: Why do you care? Do you really read the build logs?
A: I too often have to search through build logs from CI, yes. Smaller logs will be a relief for all our CI systems. Apart from this, the fast scrolling of huge build commands in a terminal or Emacs buffer does make me uncomfortable, indeed.