[llvm-commits] [llvm] r78924 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp

Daniel Dunbar daniel at zuster.org
Thu Aug 13 12:54:16 PDT 2009


On Thu, Aug 13, 2009 at 11:54 AM, Dan Gohman<gohman at apple.com> wrote:
> On Aug 13, 2009, at 10:55 AM, Daniel Dunbar wrote:
>> On Thu, Aug 13, 2009 at 10:41 AM, Dan Gohman<gohman at apple.com> wrote:
>>
>>> Author: djg
>>>
>>> Date: Thu Aug 13 12:41:40 2009
>>>
>>> New Revision: 78924
>>>
>>>
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=78924&view=rev
>>>
>>> Log:
>>>
>>> Set raw_os_ostream, raw_string_ostream, and raw_svector_ostream to be
>>>
>>> unbuffered. std::ostream does its own buffering, and std::string and
>>>
>>> SmallVector both have allocation strategies intended to handle frequent
>>>
>>> appending.
>>>
>>
>>
>> Eek!
>>
>> Did you profile the effects of this change? I expect that this
>> dramatically slows down these streams. One of the main values of being
>> buffered in raw_ostream is that we hit all the fast paths to quickly
>> output small strings. Making all of these strings unbuffered nullifies
>> several of these optimizations.
>
> Yes, it appears to be a slight win, when it matters. Do you have use
> cases where the optimizations outweigh the cost of an extra malloc+free
> and extra copying?

Ah, right, that makes sense.

I still have on my TODO list to fix the extra malloc + free that gets
incurred when writing to an SmallVector; this is important to
finishing up the Twine work to make getName()/setName() stuff as cheap
as possible.

Once I have that done I'll revisit this.

 - Daniel



More information about the llvm-commits mailing list