jorgecarleitao commented on a change in pull request #9301: URL: https://github.com/apache/arrow/pull/9301#discussion_r563267292
########## File path: rust/arrow/src/datatypes.rs ########## @@ -357,10 +373,12 @@ impl JsonSerializable for u16 { } impl ArrowNativeType for u16 { + #[inline] fn from_usize(v: usize) -> Option<Self> { num::FromPrimitive::from_usize(v) } + #[inline] Review comment: Yep, it took me 3hs to find out why there was an 100% degradation without inlines. :( My findings is that the compiler is being unable to optimize certain operations inside iterators when they are not `inlined`. I even copy-pasted `memory.rs`, `bytes.rs`, `buffer.rs` and `bit_utils` to a separate repo/lib to compare the performance on the same code, and the only difference between then was `usize::try_from(u32)` vs `u32.to_usize` (via `ArrowNativeType`). I think that we should re-visit all these functions in `ArrowNativeType`. It is not clear why they should be there. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org