When I compare the speed of the screen output of, say, gcc and gfortran, then it seems to me as if gfortran produced its output much more slowly. gcc's output seems to appear line by line, whereas gfortran's output seems to appear character by character. This could be caused by gfortran flushing after every character instead of after every line or something similar. I'm wondering, does gfortran do something special when it outputs diagnostic messages? There has to be some difference -- gfortran's messages do look different, as gfortran tries to print a cute "pointer" indicating the offending column, which gcc does not.
They seem quick to me.
But seems slower than the C or C++ or java. Java is more compariable in this case as it also outputs the context.
Does changing fputc to putc in line 95 of error.c enhance your 'experience'?
I didn't try the putc vs. fputc change, but the patch below makes all the difference: $ cvs diff -u error.c Index: error.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/fortran/error.c,v retrieving revision 1.8 diff -u -r1.8 error.c --- error.c 16 Sep 2004 16:00:41 -0000 1.8 +++ error.c 28 Dec 2004 22:26:52 -0000 @@ -74,6 +74,13 @@ static void error_char (char c) { + static int bufset = 0; + if (! bufset) + { + setvbuf (stderr, 0, _IOLBF, 0); + bufset = 1; + } + if (buffer_flag) { if (use_warning_buffer) The call to setvbuf switches to line buffering, meaning that stderr is flushed only after every line and not after every character. I assume that cc1 (as opposed to f951) switches to line buffered stderr at some time, or else outputs its error messages in some other way which is equivalent to some internal buffering. f951 outputs its messages character by character, which leads to an unnecessary overhead.
Subject: Re: Error messages seem to be printed slower On Dec 28, 2004, at 5:31 PM, schnetter at aei dot mpg dot de wrote: > > The call to setvbuf switches to line buffering, meaning that stderr is > flushed > only after every line and not after every character. I assume that > cc1 (as > opposed to f951) switches to line buffered stderr at some time, or else > outputs its error messages in some other way which is equivalent to > some > internal buffering. f951 outputs its messages character by character, > which > leads to an unnecessary overhead. Actually cc1 just uses fprintf instead of fputc so maybe that is the problem, maybe we should be doing our own buffering. -- Pinski
Patch here: http://gcc.gnu.org/ml/fortran/2005-01/msg00027.html
New patch here: http://gcc.gnu.org/ml/fortran/2005-01/msg00060.html
Subject: Bug 19182 CVSROOT: /cvs/gcc Module name: gcc Changes by: pbrook@gcc.gnu.org 2005-01-16 17:44:17 Modified files: gcc/fortran : ChangeLog error.c Log message: 2005-01-16 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> PR fortran/19182 * error.c (error_char): Line-buffer errors / warnings. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.300&r2=1.301 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/error.c.diff?cvsroot=gcc&r1=1.9&r2=1.10
I believe this is fixed. Re-open if you disagree.