[PATCH] LLD: Use std::vector to store SimpleReferences instead of linked list.
Duncan P. N. Exon Smith
dexonsmith at apple.com
Tue Mar 17 10:19:40 PDT 2015
> On 2015-Mar-15, at 23:07, Rui Ueyama <ruiu at google.com> wrote:
> I think SmallVector guarantees the array it contains is contiguous in memory. That data structure does not work well with BumpPtrAllocator because garbage after extending the array is not reclaimed until the whole buffer is discarded. That makes memory consumption of a small vector from O(n) to O(n^2).
> That being said, that behavior might be acceptable if we rarely extend SmallVectors.
This sounds dangerous.
> So, maybe it's not a bad idea, but I don't know if it's good enough to add an additional parameter to SmallVector's constructor.
If anything, what you want is a recycling allocator. If you just have one
vector, then you still get N^2 memory usage, but if you have at least O(N)
vectors, it should be amortized O(N) memory per vector. (I don't know
whether that's true for this problem.)
But I'm not sure what the benefit is anyway. Has anyone actually observed
a memory issue here?
> On Sun, Mar 15, 2015 at 10:49 PM, Yaron Keren <yaron.keren at gmail.com> wrote:
> This may mean we need teach SmallVector to accept allocator like other ADT.
> EMAIL PREFERENCES
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
More information about the llvm-commits