Commits


Yibo Cai authored and GitHub committed b0422f8df0c
ARROW-16850: [C++] Copy CSV data field and end chars separately (#13394) It's a finding when evaluating Arm Statistical Profiling Extension(SPE) on Neoverse-N1 with Arrow CSV writer benchmark. With SPE, we are able to locate precisely the machine code causing heavy cache miss or the exact branch suffering from high misprediction rate. CSV writer benchmark reveals relatively high branch misprediction rate inside glibc `memcpy` function. The branch is comparing the buffer size against 8, and to run different copying code per comparison result. Arrow CSV writer populates one column at once. In the inner loop, it does two `memcpy`. First one is to copy the field value(string) from Arrow string array. Then it does another copy to append the delimiter or end-of-line(if last column), which is at most 2 chars. Data in same column is normally of similar size, but as we are copying a very short delimiter after each data field, looks it makes CPU harder to predict the correct code path in `memcpy` as input data size varies quickly. This PR adds a trivial `CopyEndChars` routine to copy only the delimiter and end-of-line. It improves performance significantly on Arm Neoverse-N1. Skylake also sees mild improvement. Lead-authored-by: Yibo Cai <yibo.cai@arm.com> Co-authored-by: Antoine Pitrou <pitrou@free.fr> Signed-off-by: Antoine Pitrou <antoine@python.org>