jhorstmann commented on code in PR #2061:
URL: https://github.com/apache/arrow-rs/pull/2061#discussion_r920876190


##########
arrow/src/util/bit_chunk_iterator.rs:
##########
@@ -333,7 +333,7 @@ impl Iterator for BitChunkIterator<'_> {
             // the constructor ensures that bit_offset is in 0..8
             // that means we need to read at most one additional byte to fill 
in the high bits
             let next = unsafe {
-                std::ptr::read_unaligned(raw_data.add(index + 1) as *const u8) 
as u64
+                std::ptr::read_volatile(raw_data.add(index + 1) as *const u8) 
as u64

Review Comment:
   Plain `std::ptr::read` should then work just as well for reading a byte. I'm 
surprised this makes a difference because the compiler should know that bytes 
can't really be unaligned.
   
   The copy inside the implementation of `read_unaligned` is something that the 
compiler will optimize away since the size is statically known. My only guess 
would be that the slightly larger code before optimizations somehow influences 
inlining decisions somewhere else.



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to