From 90c3bd7fa799ccce3d61d0be6c528db4e6b66b6e Mon Sep 17 00:00:00 2001 From: Weston Pace Date: Tue, 11 Jul 2023 16:05:49 -0700 Subject: [PATCH 1/2] Added documentation for ACERO_ALIGNMENT_HANDLING --- docs/source/cpp/env_vars.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/source/cpp/env_vars.rst b/docs/source/cpp/env_vars.rst index 06fd73ffd0d9..63335afd2d1b 100644 --- a/docs/source/cpp/env_vars.rst +++ b/docs/source/cpp/env_vars.rst @@ -26,6 +26,28 @@ Arrow C++ at runtime. Many of these variables are inspected only once per process (for example, when the Arrow C++ DLL is loaded), so you cannot assume that changing their value later will have an effect. +.. envvar:: ACERO_ALIGNMENT_HANDLING + + Arrow C++'s Acero module performs computation on streams of data. This + computation may involve a form of "type punning" that is technically + undefined behavior if the underlying array is not properly aligned. On + most modern CPUs this is not an issue, but some older CPUs may crash or + suffer poor performance. For this reason it is recommended that all + incoming array buffers are properly aligned. + + The value of this environment variable controls what will happen when + Acero detects an unaligned buffer. + + - ``warn`` a warning is emitted + - ``ignore`` nothing, alignment checking is disabled + - ``reallocate`` the buffer is reallocated to a properly aligned address + - ``error`` the operation will fail with an error + + The default behavior is ``warn``. On modern hardware it is usually safe + to change this to ``ignore``. Changing to ``reallocate`` is the safest + option but this will have a significant performance impact as the buffer + will need to be copied. + .. envvar:: ARROW_DEBUG_MEMORY_POOL Enable rudimentary memory checks to guard against buffer overflows. From df536f33dd5fd02119b482f1a534543d21ec1e7f Mon Sep 17 00:00:00 2001 From: Weston Pace Date: Thu, 13 Jul 2023 06:19:18 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Antoine Pitrou --- docs/source/cpp/env_vars.rst | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/source/cpp/env_vars.rst b/docs/source/cpp/env_vars.rst index 63335afd2d1b..e8490735926c 100644 --- a/docs/source/cpp/env_vars.rst +++ b/docs/source/cpp/env_vars.rst @@ -33,15 +33,16 @@ that changing their value later will have an effect. undefined behavior if the underlying array is not properly aligned. On most modern CPUs this is not an issue, but some older CPUs may crash or suffer poor performance. For this reason it is recommended that all - incoming array buffers are properly aligned. + incoming array buffers are properly aligned, but some data sources + such as :ref:`Flight ` may produce unaligned buffers. The value of this environment variable controls what will happen when - Acero detects an unaligned buffer. + Acero detects an unaligned buffer: - - ``warn`` a warning is emitted - - ``ignore`` nothing, alignment checking is disabled - - ``reallocate`` the buffer is reallocated to a properly aligned address - - ``error`` the operation will fail with an error + - ``warn``: a warning is emitted + - ``ignore``: nothing, alignment checking is disabled + - ``reallocate``: the buffer is reallocated to a properly aligned address + - ``error``: the operation fails with an error The default behavior is ``warn``. On modern hardware it is usually safe to change this to ``ignore``. Changing to ``reallocate`` is the safest