You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "etseidl (via GitHub)" <gi...@apache.org> on 2024/08/23 21:42:35 UTC

[PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

etseidl opened a new pull request, #6297:
URL: https://github.com/apache/arrow-rs/pull/6297

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #6296.
   
   # Rationale for this change
    
   See issue.
   
   # What changes are included in this PR?
   
   Changes `pad_nulls` for `FixedLenByteArrayBuffer` as described in the issue. Benchmarking seems to indicate that using the new approach for `byte_length > 4` is optimal. The loop is better for `byte_length <= 4` because the compiler will eliminate the loop via unrolling.
   
   This PR does include extensive changes to the `arrow_reader` bench to allow benchmarking these changes.
   
   # Are there any user-facing changes?
   No
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!---
   If there are any breaking changes to public APIs, please add the `breaking change` label.
   -->
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6297:
URL: https://github.com/apache/arrow-rs/pull/6297#issuecomment-2359322989

   I am depressed about the large review backlog in this crate. We are looking for more help from the community reviewing PRs -- see https://github.com/apache/arrow-rs/issues/6418 for more


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #6297:
URL: https://github.com/apache/arrow-rs/pull/6297#issuecomment-2307853546

   Benchmark results for these changes (pad loop is as in master branch):
   ```
   group                                                                                                      pad_loop                               pad_nulls_vec2
   -----                                                                                                      --------                               --------------
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Decimal128Array/byte_stream_split encoded, optional, half NULLs    1.45    558.3±4.21µs        ? ?/sec    1.00    385.9±3.98µs        ? ?/sec
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Decimal128Array/plain encoded, optional, half NULLs                1.67    422.5±4.04µs        ? ?/sec    1.00    253.3±4.98µs        ? ?/sec
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Float16Array/byte_stream_split encoded, optional, half NULLs       1.03    119.9±0.74µs        ? ?/sec    1.00    116.5±1.73µs        ? ?/sec
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Float16Array/plain encoded, optional, half NULLs                   1.04    105.7±1.24µs        ? ?/sec    1.00    101.2±1.09µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(16)/byte_stream_split encoded, optional, half NULLs                   1.63    440.0±1.65µs        ? ?/sec    1.00    269.5±1.76µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(16)/plain encoded, optional, half NULLs                               2.17    297.8±3.19µs        ? ?/sec    1.00    137.1±3.25µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(2)/byte_stream_split encoded, optional, half NULLs                    1.07    108.4±4.14µs        ? ?/sec    1.00    101.2±1.03µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(2)/plain encoded, optional, half NULLs                                1.00     86.8±1.53µs        ? ?/sec    1.00     86.8±1.62µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(4)/byte_stream_split encoded, optional, half NULLs                    1.01    148.4±1.92µs        ? ?/sec    1.00    146.9±1.62µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(4)/plain encoded, optional, half NULLs                                1.02    117.0±0.40µs        ? ?/sec    1.00    115.2±1.27µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(8)/byte_stream_split encoded, optional, half NULLs                    1.33    241.4±2.93µs        ? ?/sec    1.00    181.5±2.62µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(8)/plain encoded, optional, half NULLs                                1.49    174.5±3.44µs        ? ?/sec    1.00    116.9±1.26µs        ? ?/sec
   ```


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #6297:
URL: https://github.com/apache/arrow-rs/pull/6297#issuecomment-2307885503

   I must have hallucinated last night...turns out `copy_from_slice` actually is a bit faster for the long arrays. Master vs https://github.com/apache/arrow-rs/pull/6297/commits/1a1e967c4704fd5d67ccc5054d4673805a994656
   
   <details>
   
   ```
   group                                                                                                      pad_loop                               pad_nulls_slice
   -----                                                                                                      --------                               ---------------
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Decimal128Array/byte_stream_split encoded, optional, half NULLs    1.52    558.3±4.21µs        ? ?/sec    1.00    367.8±3.17µs        ? ?/sec
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Decimal128Array/plain encoded, optional, half NULLs                1.85    422.5±4.04µs        ? ?/sec    1.00    228.8±3.73µs        ? ?/sec
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Float16Array/byte_stream_split encoded, optional, half NULLs       1.07    119.9±0.74µs        ? ?/sec    1.00    112.3±1.55µs        ? ?/sec
   arrow_array_reader/FIXED_LEN_BYTE_ARRAY/Float16Array/plain encoded, optional, half NULLs                   1.16    105.7±1.24µs        ? ?/sec    1.00     91.3±0.85µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(16)/byte_stream_split encoded, optional, half NULLs                   1.69    440.0±1.65µs        ? ?/sec    1.00    259.7±2.18µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(16)/plain encoded, optional, half NULLs                               2.36    297.8±3.19µs        ? ?/sec    1.00    126.3±1.59µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(2)/byte_stream_split encoded, optional, half NULLs                    1.20    108.4±4.14µs        ? ?/sec    1.00     90.6±0.81µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(2)/plain encoded, optional, half NULLs                                1.16     86.8±1.53µs        ? ?/sec    1.00     74.9±0.63µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(4)/byte_stream_split encoded, optional, half NULLs                    1.06    148.4±1.92µs        ? ?/sec    1.00    140.4±2.67µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(4)/plain encoded, optional, half NULLs                                1.08    117.0±0.40µs        ? ?/sec    1.00    108.0±1.19µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(8)/byte_stream_split encoded, optional, half NULLs                    1.39    241.4±2.93µs        ? ?/sec    1.00    173.1±2.77µs        ? ?/sec
   arrow_array_reader/FixedLenByteArray(8)/plain encoded, optional, half NULLs                                1.60    174.5±3.44µs        ? ?/sec    1.00    109.0±1.27µs        ? ?/sec
   ```
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #6297:
URL: https://github.com/apache/arrow-rs/pull/6297#issuecomment-2315457527

   > > I must have hallucinated last night...turns out copy_from_slice actually is a bit faster for the long arrays.
   > 
   > Sorry I didn't follow all the nance of the results here. It seems like you have concluded that which approach is faster is a result of what the target architecture is?
   
   Sorry, I tend to ramble...I concluded that `copy_from_slice` is the way to go since it's better on modern CPUs. I only added the mac results to show I hadn't imagined the other approach being faster when I did my initial testing. 😅 
   
   > 
   > If this is the case, I think my preference would be go with the simplest code (e.g. `copy_from_slice`?) otherwise we run the risk of over fitting / over optimizing for some specific conditions)
   
   agreed!
   
   


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #6297:
URL: https://github.com/apache/arrow-rs/pull/6297#issuecomment-2315038508

   > I must have hallucinated last night...turns out copy_from_slice actually is a bit faster for the long arrays. 
   
   Sorry I didn't follow all the nance of the results here. It seems like you have concluded that which approach is faster is a result of what the target architecture is?
   
   If this is the case, I think my preference would be go with the simplest code (e.g. `copy_from_slice`?) otherwise we run the risk of over fitting / over optimizing for some specific conditions)


-- 
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-unsubscribe@arrow.apache.org

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


Re: [PR] Speed up `pad_nulls` for `FixedLenByteArrayBuffer` [arrow-rs]

Posted by "wiedld (via GitHub)" <gi...@apache.org>.
wiedld commented on PR #6297:
URL: https://github.com/apache/arrow-rs/pull/6297#issuecomment-2378428187

   I'm starting to review this one. Just give me a little bit to dig into the decoding.


-- 
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-unsubscribe@arrow.apache.org

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