Uh oh!
There was an error while loading. Please reload this page.
MINOR: [C++] Use [] instead of exception-throwing at(i) in concatenate.cc - #35422
Conversation
felipecrv
commented
May 4, 2023
felipecrv
commented
May 8, 2023
Rebased and pushed again to see if all CI can pass now. |
pitrou
commented
May 9, 2023
This PR is ok but I'm not sure |
mapleFU
commented
May 9, 2023
staticvoidVectorIndex(benchmark::State& state) {
// Code inside this loop is measured repeatedly
std::vector<int64_t> range_vec(10000, 0);
for (auto _ : state) {
// Make sure the variable is not optimized away by compilerfor (int i = 0; i < 10000; ++i) {
int64_t v = range_vec[i];
benchmark::DoNotOptimize(v);
}
}
}
// Register the function as a benchmarkBENCHMARK(VectorIndex);
staticvoidVectorAt(benchmark::State& state) {
// Code inside this loop is measured repeatedly
std::vector<int64_t> range_vec(10000, 0);
for (auto _ : state) {
// Make sure the variable is not optimized away by compilerfor (int i = 0; i < 10000; ++i) {
int64_t v = range_vec.at(i);
benchmark::DoNotOptimize(v);
}
}
}
BENCHMARK(VectorAt);With release(-O2) on my MacOS: |
felipecrv
commented
May 10, 2023
@pitrou C++ lore.
We return a bad |
pitrou
commented
May 10, 2023
Ah, that's a good point. |
pitrou
commented
May 10, 2023
The "AMD64 Conda C++" CI failure seems unexpected, can you take a look? |
@pitrou I only found unreleated issues, but one of them is being fixed in mapleFU's PR. When that is merged I will rebase and force-push here. |
6ac6380 to
6ab2bfdComparefelipecrv
commented
May 12, 2023
I pushed a commit here to test a fix for parquet CI tests. If it passes, I will create a separate issue/PR for it. |
Uh oh!
There was an error while loading. Please reload this page.
pitrou
commented
May 16, 2023
Can you rebase on git main so as to get a slightly less failing CI? :-) |
felipecrv
commented
May 16, 2023
I'm waiting for @mapleFU's PR to be merged. |
663fd5f to
ff22339CompareThe access is safe because array is previously resized to buffers.size()
pitrou
commented
May 22, 2023
CI failures are unrelated, will merge. |
ursabot
commented
May 30, 2023
Benchmark runs are scheduled for baseline = 584dc7b and contender = 2216a0a. 2216a0a is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
Rationale for this change
vector::atperforms bounds checking and can throw an exception [1]. Its use is discouraged and in this specific case, the access is provably safe because array is previously resized tobuffers.size().[1] https://en.cppreference.com/w/cpp/container/vector/at
What changes are included in this PR?
Use of
operator[]instead ofat().Are these changes tested?
By the existing concatenation tests.