Paul Eggert wrote:
> The other, in lib/textstyle.in.h, 
> seems to be a performance bug - at least, the description of FLUSH_ALL 
> doesn't explain the sometimes-severe performance issues involved, which 
> leads me to be puzzled about what's intended.

The comments:

  /* Flushes buffers in the current process and attempts to flush the buffers
     in the kernel.
     Use this value so that some other process (or the kernel itself)
     may write to the same target.  */
  FLUSH_ALL = 2

Let's take an example: Assume a log file contains styled log lines,
i.e. text with ANSI (or HTML) sequences for switching the colour. In
situations where it is known that several processes are writing to the
same file, it is highly desirable that output from process A is finished
in the log file before output from process B begins — otherwise the
file will contain text from process A with colour attributes from process B
or vice versa. FLUSH_ALL is designed to minimized this styling garbage.

There are two alternatives, FLUSH_THIS_PROCESS and FLUSH_THIS_STREAM, that
have smaller scope and are, accordingly, more efficient.

But I wouldn't call it a performance bug. Just like when the user runs a
command "factor 100000000000000000000000000000000000001" it's slow, but
it's not a bug: it does exactly what the user has requested.

Bruno




Reply via email to