[PATCH] D90884: [SmallVector] Add a default small size.

Sean Silva via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 5 14:46:24 PST 2020


silvas added a comment.

In D90884#2377497 <https://reviews.llvm.org/D90884#2377497>, @mehdi_amini wrote:

> Seems like it'll always have a default payload equivalent of 6 pointers? Maybe you can document this? Also that makes the vector 72B, which isn't cache line aligned, should we make it 64 or 128 instead?

Usually SmallVector's are on the stack, so all cache lines are expected to be touched anyway. So I don't see much value in considering cache line sizes for the default size.

The default payload is not 6 pointers in all cases. E.g. for smaller types on 64-bit platforms, we will use a 32-bit size/capacity, which on 64-bit platforms results in a header that is 2 pointer in size, resulting in a 4 pointer inline storage.

> I'm not sure it makes sense to every get a default of a very small N in general. I guess a default like here makes sense for smaller object, what about `static_assert` if `sizeof(T)>sizeof(void*)`?

SmallVector is definitely used for many types that are larger than `void*`, so we don't want to prohibit that with a `static_assert`.

SmallVector with a very small N is still advantageous over std::vector because SmallVector has a POD optimization.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90884/new/

https://reviews.llvm.org/D90884



More information about the llvm-commits mailing list