emilk commented on PR #6901: URL: https://github.com/apache/arrow-rs/pull/6901#issuecomment-2553166620
I'll try to get you some benchmarks. The main thing we want to avoid is doing the same bounds checks _twice_: first before calling into `slice`, and then once more inside of `slice`. One can hope that the optimizer can remove the second bounds check, but that will only happen if the inliner is good enough (and these functions aren't even marked as `#[inline]`). After making this PR I started thinking though - and alternative is to add an API like this: ``` fn try_slice(&self, offset: usize, len: usize) -> Option<Self> ``` that returns `None` in case of out-of-bounds. That way the bounds-check is only done once, though lack of inlining may still hurt perf. And yes, we have a weird usecase. We are generating code for arrow-deserialization, and the code is not pretty 😓 I'm looking deeper now to see if we can avoid all of this… converting to draft in the meantime. -- 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]
