I don't know the Arrow and parquet-cpp codebases but this is exactly what
we did in Impala to solve similar issues and we haven't had any performance
problems with it - it should get compiled to a single load/store on x86-64.

On Fri, May 17, 2019 at 12:22 PM Micah Kornfield <emkornfi...@gmail.com>
wrote:

> I recently ran UBSan over parquet and arrow code bases and there are quite
> a few unaligned pointer warnings (we do reinterpret casts on integer types
> without checking alignment).  Most of them are in Arrow itself, which
> parquet calls into.
>
> Is this something the community would like to fix?
>
> I imagine adding a helper method something like:
>
> template<T>
> T LoadUnaligned(T* pointer_to_t) {
>   T aligned;
>   memcpy(&aligned, t, sizeof(T));
>   return aligned;
> }
>
> I believe clang/GCC/MSVC should be good enough to recognize that an
> unaligned load can replace the memcpy and inline it.  But hopefully archery
> will be able to catch any performance regressions if this isn't the case.
>
> Thoughts?
>
> Thanks,
> Micah
>

Reply via email to