[PATCH] D54388: [llvm-exegesis] InstructionBenchmarkClustering::rangeQuery(): use llvm::SmallVector<size_t, 0> for storage.
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 11 23:16:16 PST 2018
lebedev.ri added inline comments.
================
Comment at: tools/llvm-exegesis/lib/Clustering.cpp:38
InstructionBenchmarkClustering::rangeQuery(const size_t Q) const {
- std::vector<size_t> Neighbors;
+ llvm::SmallVector<size_t, 0> Neighbors;
const auto &QMeasurements = Points_[Q].Measurements;
----------------
MaskRay wrote:
> The size of `Neighbors` is bound by the number of points. The vector can be reserved before the loop calling `rangeQuery` and passed as a parameter into `rangeQuery`.
Good point.
That is the **upper** bound, not in all cases that will be actual size of the vector.
Given that you have accepted D54390, such optimization can be safely made
but only *after* D54390 (and it can be replaced by a `std::vector`),
but i really really don't want to change/reorder patches,
because that would require to re-do all of the benchmarks/measurements.
So i will add a new patch with that fix.
Repository:
rL LLVM
https://reviews.llvm.org/D54388
More information about the llvm-commits
mailing list