tustvold commented on code in PR #5922:
URL: https://github.com/apache/arrow-rs/pull/5922#discussion_r1650031093


##########
arrow-array/src/array/byte_view_array.rs:
##########
@@ -238,8 +241,18 @@ impl<T: ByteViewType + ?Sized> GenericByteViewArray<T> {
     }
 
     /// Returns the element at index `i`
+    ///
+    ///
     /// # Safety
     /// Caller is responsible for ensuring that the index is within the bounds 
of the array
+    // 
+    // This function can't be inlined, ow it causes the caller function to run 
out of registers and cause register spilling.
+    // Basically you can't just call `l_full_data = left.value_unchecked(...)`,
+    // the compiler tries to inline the `value_unchecked` function, which 
introduces many unnecessary variables on stack.
+    // Looking at the assembly, the auto-inlined version run out of the 
registers, which causes register spilling, which then causes unnecessary memory 
access.
+    //
+    // TLDR: don't change it, unless you have examined the assembly output.

Review Comment:
   This feels like an issue with the caller of value_unchecked and not the 
nature of inlining this method? In particular I wonder if the issue is compare 
/ compare_unchecked is getting inlined. A lot of the comparison kernel 
implementations use `inline(never)` for this reason



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to