[PATCH] D58296: [llvm-objcopy] Make removeSectionReferences batched
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 20 17:13:12 PST 2019
MaskRay added a comment.
> FWIW, this would be the 11th largest file:
================
Comment at: llvm/tools/llvm-objcopy/ELF/Object.cpp:1358
// an error here instead.
+ std::vector<const SectionBase *> RemoveSections;
+ RemoveSections.reserve(std::distance(Iter, std::end(Sections)));
----------------
rupprecht wrote:
> jhenderson wrote:
> > I'm staring at this and thinking that an unordered Set may be a better container for performance here, especially given our use of pointers, making the comparison and hashing operations cheap. It would remove the need for sort and binary_search in favour of a set lookup, which is (usually) constant time.
> >
> > Have I missed something?
> Switched, although it is only a minor improvement:
>
> python -m timeit -n 3 -r 10 -v -s 'import os' 'os.system("llvm-objcopy -j .keep_me /tmp/huge-input.o /tmp/foo.o")'
>
> w/ sorted vector:
> raw times: 4.23 4.14 4.16 4.17 4.27 4.22 4.13 4.14 4.14 4.2
> 3 loops, best of 10: 1.38 sec per loop
>
> w/ unordered_set:
> raw times: 3.83 3.75 3.85 3.77 3.76 3.87 3.81 3.82 3.84 3.83
> 3 loops, best of 10: 1.25 sec per loop
No preference here.. Is `SmallPtrSet<const SectionBase *, ?>` faster?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58296/new/
https://reviews.llvm.org/D58296
More information about the llvm-commits
mailing list