[PATCH] D112175: [NFC] Add llvm::StaticVector ADT
James Player via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 12:11:01 PDT 2022
jplayer-nv added a comment.
Just to give a concrete example of what I believe to be the benefit behind `StaticVector`, I ran this contrived test pitting `SmallVector<uint64_t,N>` vs `StaticVector<uint64_t,N>` (with a few tweaks to ensure the `push_back` param is passsed by value like in `SmallVector`):
TYPED_TEST(StaticVsSmall, TimedStaticVector) {
const size_t N = this->NumBuiltinElts(this->TheStaticVector);
for (int I = 0; I < OutterLimit; ++I) {
this->TheStaticVector.clear();
for (int J = 0; J < N; ++J) {
this->TheStaticVector.push_back(I + J);
}
}
}
TYPED_TEST(StaticVsSmall, TimedSmallVector) {
const size_t N = this->NumBuiltinElts(this->TheSmallVector);
for (int I = 0; I < OutterLimit; ++I) {
this->TheSmallVector.clear();
for (int J = 0; J < N; ++J) {
this->TheSmallVector.push_back(I + J);
}
}
}
My local results are:
[ RUN ] StaticVsSmall/0.TimedStaticVector
[ OK ] StaticVsSmall/0.TimedStaticVector (371 ms)
[ RUN ] StaticVsSmall/0.TimedSmallVector
[ OK ] StaticVsSmall/0.TimedSmallVector (596 ms)
Which demonstrates that simple insertions are significantly faster (almost 38%) with the `StaticVector` compared to a `SmallVector` which stays within its small buffer limit.
I would think it interesting to speed up `SmallSet` insertions by retargeting the small storage to a `StaticVector`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112175/new/
https://reviews.llvm.org/D112175
More information about the llvm-commits
mailing list