[llvm] r211595 - Pass a unique_ptr<MemoryBuffer> to the constructors in the Binary hierarchy.

Alp Toker alp at nuanti.com
Fri Jul 4 15:37:05 PDT 2014


On 05/07/2014 01:07, Rafael EspĂ­ndola wrote:
>> I agree with that, but reference counting for a few months gives us the
>> clean pass-by-pointer interfaces we want in the long run. I'm not at all a
>> fan of reference counting, but it's a tool we can use to get where we want.
>>
>> Making the switch now sets things up so we can introduce proper ownership
>> with very little code change.
>>
>> So this definitely isn't about reference counting vs. something else -- it's
>> about taking the first step to achieve the design we ultimately want, but
>> always missed out on. My estimate is a 4-6 month timeframe to get there.
> Why that long? Moving from the "sometimes owned" to the "always owned"
> model was less than one week. Is there really that much more code that
> depends on Binary owning the buffer?

I want to make sure we consolidate SourceMgr/SourceManager and similar 
code that might exist in other LLVM subprojects, instead of just adding 
a new one top-down.

We're copying these files multiple times into memory, dozens of 
megabytes per compilation at times because of the basic limitation that 
these components are all trying to own the buffer and not able to share 
it beyond their own lifetime.

It's going to take time to get this down and a lot of the requirements 
will be set by parallelisation of the compilation pipeline, in-memory 
operation etc. work that has barely begun in the 3.5 series.

>
> That would put the reference counted buffers in one or two releases. I
> really don't think we should do that.

Is there any technical reason not to do that? As soon as we have a 
top-level file manager interface it'll become possible to remove the 
reference counting with a small patch, and it lets us develop 
requirements beginning at the core instead of introducing project-wide 
changes.

Even with the patch, nearly all MemoryBuffer users will continue to use 
it the traditional way, with reference counting being handled by the few 
classes that really need ownership sharing/transfer.

If it's the idea of making MemoryBuffer reference counted that's 
jarring, I guess we could wrap it with a FileEntry object that holds a 
single MemoryBuffer, plus file stat info, and deals with transfer and 
gets reference counting, but it feels a bit premature to do that.

I'm fine to remove the reference counting 6 months from now if it hasn't 
worked out, but at this point I think it's the only realistic proposal 
to achieve efficient resource usage.

Alp.

>
> Cheers,
> Rafael

-- 
http://www.nuanti.com
the browser experts




More information about the llvm-commits mailing list