[llvm-commits] [llvm] r82434 - /llvm/trunk/include/llvm/Support/FormattedStream.h
Daniel Dunbar
daniel at zuster.org
Mon Sep 21 17:57:42 PDT 2009
On Mon, Sep 21, 2009 at 4:21 PM, Dan Gohman <gohman at apple.com> wrote:
> Hi Daniel,
>
> With this change, errs() is now becoming buffered, which is
> very inconvenient.
Only if you write to it via a formatted ostream. And 10x slowdown is
also inconvenient... :)
Let's talk about this in person, I'm fairly skeptical that the "right"
solution is having formatted ostream mutate the buffering on the
underlying stream *ever*.
- Daniel
> On Sep 20, 2009, at 8:56 PM, Daniel Dunbar wrote:
>
>> Author: ddunbar
>> Date: Sun Sep 20 22:56:00 2009
>> New Revision: 82434
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=82434&view=rev
>> Log:
>> Don't allow formatted_ostream to be unbuffered, even if its underlying
>> buffer
>> is.
>> - The problem is that formatted_ostream forces its underlying buffer to be
>> unbuffered, so if some client happens to wrap a formatted_ostream around
>> something, but still use the underlying stream, then we can end up
>> writing on
>> a fully unbuffered output (which was never intended to be unbuffered).
>>
>> - This makes clang (and presumably llvm-gcc) -emit-llvm -S a mere 10x
>> faster.
>>
>> Modified:
>> llvm/trunk/include/llvm/Support/FormattedStream.h
>>
>> Modified: llvm/trunk/include/llvm/Support/FormattedStream.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FormattedStream.h?rev=82434&r1=82433&r2=82434&view=diff
>>
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Support/FormattedStream.h (original)
>> +++ llvm/trunk/include/llvm/Support/FormattedStream.h Sun Sep 20 22:56:00
>> 2009
>> @@ -105,10 +105,15 @@
>> // own buffering, and it doesn't need or want TheStream to do another
>> // layer of buffering underneath. Resize the buffer to what TheStream
>> // had been using, and tell TheStream not to do its own buffering.
>> + //
>> + // If the underlying stream is unbuffered, just use its preferred
>> buffer
>> + // size. We can't treat this as an honest wish for unbuffered
>> output,
>> + // because it could very well be a stream we previously forced to
>> be
>> + // unbuffered.
>> if (size_t BufferSize = TheStream->GetBufferSize())
>> SetBufferSize(BufferSize);
>> else
>> - SetUnbuffered();
>> + SetBuffered();
>> TheStream->SetUnbuffered();
>>
>> Scanned = 0;
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
More information about the llvm-commits
mailing list