Bug 19182 - Error messages seem to be printed slower
Summary: Error messages seem to be printed slower
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 minor
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
 
Reported: 2004-12-28 20:32 UTC by Erik Schnetter
Modified: 2005-01-16 17:55 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2004-12-28 20:47:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Schnetter 2004-12-28 20:32:05 UTC
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.
Comment 1 Andrew Pinski 2004-12-28 20:45:08 UTC
They seem quick to me.
Comment 2 Andrew Pinski 2004-12-28 20:47:27 UTC
But seems slower than the C or C++ or java.
Java is more compariable in this case as it also outputs the context.
Comment 3 Tobias Schlüter 2004-12-28 21:41:05 UTC
Does changing fputc to putc in line 95 of error.c enhance your 'experience'?
Comment 4 Erik Schnetter 2004-12-28 22:31:47 UTC
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. 
Comment 5 Andrew Pinski 2004-12-28 22:34:56 UTC
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

Comment 6 Tobias Schlüter 2005-01-04 23:55:43 UTC
Patch here: http://gcc.gnu.org/ml/fortran/2005-01/msg00027.html
Comment 7 Tobias Schlüter 2005-01-08 00:05:04 UTC
New patch here: http://gcc.gnu.org/ml/fortran/2005-01/msg00060.html
Comment 8 GCC Commits 2005-01-16 17:44:23 UTC
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

Comment 9 Tobias Schlüter 2005-01-16 17:51:24 UTC
I believe this is fixed.  Re-open if you disagree.