You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C++][Parquet] Non-dictionary BinaryArray reads from Parquet format have slowed down since 0.11.x #22788
In doing some benchmarking, I have found that binary reads seem to be slower from Arrow 0.11.1 to master branch. It would be a good idea to do some basic profiling to see where we might improve our memory allocation strategy (or whatever the bottleneck turns out to be)
Wes McKinney / @wesm:
OK, I think to make things faster we need to be more careful about pre-allocating with BinaryBuilder and calling BaseBinaryBuilder<T>::UnsafeAppend instead of Append. It's a bit tricky because we have ChunkedBinaryBuilder in the mix, so we may have to manage the creation of chunks in the Parquet value decoder. I think this is worth the effort given how much of a hot path this is for reading Parquet files. I'll spend a little time on it tomorrow
Wes McKinney / @wesm:
So on closer inspection, in v0.11.1 we weren't yet handling chunked binary reads at all, so the comparison is not really apples to oranges. v0.12.x was the first release series to include chunking support, so could be the more appropriate comparison.
This performance issue is really vexing. We also changed jemalloc versions between 0.12.x and 0.15.x so I wonder if the allocator version could be impacting performance
So it seems like the difference in jemalloc versions may be accounting for some of the performance difference. The other thing that strikes me is that the UBSAN changes (SafeLoadAs) are likely introducing performance degradation because the Parquet BYTE_ARRAY encoding results in mostly unaligned lengths.
Antoine Pitrou / @pitrou:
Have you tried to measure the same jemalloc version for the two Arrow versions (or, conversely, the two jemalloc versions for the same Arrow version)?
Micah Kornfield / @emkornfield:
For SafeLoadAs, you could try changing the implementation to dereference instead of memcpy, which should be equivalent to the old code (assuming it is getting inlined correctly). IIRC, we saw very comparable numbers for the existing parquet benchmarks when I made those changes.
Wes McKinney / @wesm:
After reverting the jemalloc version, the benchmarks show that master is faster than v0.12.1, which is certainly what I was hoping for after all the work we put in refactoring stuff the last few months. So the SafeLoadAs issue is no longer a concern
Activity
asfimport commentedon Sep 3, 2019
Wes McKinney / @wesm:
I updated the results plot to use gcc 8.3 in both v0.11.1 and master branch as of 9/2/2019
asfimport commentedon Sep 3, 2019
Wes McKinney / @wesm:
The dreaded
\_\_memmove_avx_unaligned_ermshas showed up again. I'll have a poke at this to see what could be doneasfimport commentedon Sep 3, 2019
Wes McKinney / @wesm:
OK, I think to make things faster we need to be more careful about pre-allocating with
BinaryBuilderand callingBaseBinaryBuilder<T>::UnsafeAppendinstead ofAppend. It's a bit tricky because we haveChunkedBinaryBuilderin the mix, so we may have to manage the creation of chunks in the Parquet value decoder. I think this is worth the effort given how much of a hot path this is for reading Parquet files. I'll spend a little time on it tomorrowasfimport commentedon Sep 4, 2019
Wes McKinney / @wesm:
So on closer inspection, in v0.11.1 we weren't yet handling chunked binary reads at all, so the comparison is not really apples to oranges. v0.12.x was the first release series to include chunking support, so could be the more appropriate comparison.
This performance issue is really vexing. We also changed jemalloc versions between 0.12.x and 0.15.x so I wonder if the allocator version could be impacting performance
asfimport commentedon Sep 4, 2019
Wes McKinney / @wesm:
Further down the rabbit hole
0.12.1 perf profile
master / my ARROW-6417 branch
Furthermore, jemalloc is show up as taking a lot more time on 5.2.x versus the older version we had before
master
0.12.1
So it seems like the difference in jemalloc versions may be accounting for some of the performance difference. The other thing that strikes me is that the UBSAN changes (
SafeLoadAs) are likely introducing performance degradation because the Parquet BYTE_ARRAY encoding results in mostly unaligned lengths.cc @pitrou [~emkornfield@gmail.com] for any thoughts...
asfimport commentedon Sep 5, 2019
Antoine Pitrou / @pitrou:
Have you tried to measure the same jemalloc version for the two Arrow versions (or, conversely, the two jemalloc versions for the same Arrow version)?
asfimport commentedon Sep 5, 2019
Wes McKinney / @wesm:
I will try that next. I'm going to merge my current patch in the meantime and leave this JIRA open
asfimport commentedon Sep 5, 2019
Micah Kornfield / @emkornfield:
For SafeLoadAs, you could try changing the implementation to dereference instead of memcpy, which should be equivalent to the old code (assuming it is getting inlined correctly). IIRC, we saw very comparable numbers for the existing parquet benchmarks when I made those changes.
asfimport commentedon Sep 5, 2019
Wes McKinney / @wesm:
OK, it appears that the jemalloc version is causing the perf difference
current master branch with vendored jemalloc version (4.something with patches)
master with jemalloc 5.2.0
To reproduce these results yourself
Get the old jemalloc tarball from here https://github.com/apache/arrow/tree/maint-0.12.x/cpp/thirdparty/jemalloc
Set
$ARROW_JEMALLOC_URLto the path of that before buildingUse this branch which has the old EP configuration https://github.com/wesm/arrow/tree/use-old-jemalloc
Here's the benchmark script that I'm running above
https://gist.github.com/wesm/7e5ae1d41981cfdd20415faf71e5f57e
I'm interested if other benchmarks are affected or if this is a peculiarity of this particular benchmark
asfimport commentedon Sep 5, 2019
Wes McKinney / @wesm:
The benchmark results in arrow-builder-benchmark are pretty damning...
master
master with the older jemalloc
So it seems that performance in realloc-heavy workloads is degraded
asfimport commentedon Sep 5, 2019
Wes McKinney / @wesm:
I opened an issue with jemalloc to see if we're doing something wrong jemalloc/jemalloc#1621
asfimport commentedon Sep 5, 2019
Antoine Pitrou / @pitrou:
Wow that's massive.
Re
SafeLoadAs, I'm with Micah: it shouldn't make a difference on a x86 CPU with a decent compiler. Worth checking anyway.asfimport commentedon Sep 5, 2019
Antoine Pitrou / @pitrou:
FTR, similar issues with jemalloc seem to have happened in the past, I wonder if it's a regression:
jemalloc/jemalloc#335
jemalloc/jemalloc#126
asfimport commentedon Sep 5, 2019
Wes McKinney / @wesm:
After reverting the jemalloc version, the benchmarks show that master is faster than v0.12.1, which is certainly what I was hoping for after all the work we put in refactoring stuff the last few months. So the SafeLoadAs issue is no longer a concern
asfimport commentedon Oct 14, 2019
Wes McKinney / @wesm:
This was fixed in 0.15.0 by the jemalloc toolchain work and other optimizations