[PATCH] Disable buffering for raw_null_ostream()

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 15:15:25 PDT 2015


Rafael Espíndola <rafael.espindola at gmail.com> writes:
>> Do you expect memcpy to be faster than a virtual call to an empty function?
>> From what I can see with a quick measurement on OS X compiled with
>> Release and *no* assertions it does not seem to be the case.
>
> Good point. I forgot the null implementation was special in that way.
>
>>>> Moreover it kept a shared buffer, and made using nulls() not possible
>>>> in a multi-threaded environment.
>>>
>>> Sorry, I really don't see it. By reading the code it looks like we
>>> will call SetBuffered,  which will call  SetBufferSize(Size), which
>>> will allocate a new buffer.
>>
>> Sure, the problem is not with the class raw_null_ostream itself, it
>> is really with the function “nulls()” which returns a static object.
>> By having it unbuffered, it become immutable and can be shared across threads.
>
> Ah! Thanks.
>
> OK, making it unbuffered LGTM. Like Duncan I have a small preference
> for just using the existing bool.

(resent to correct list)

Did this ever get committed? For the record, it LGTM too.


More information about the llvm-commits mailing list