You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@datafusion.apache.org by "parthchandra (via GitHub)" <gi...@apache.org> on 2024/07/26 00:53:51 UTC
[PR] perf: decimal decode improvements [datafusion-comet]
parthchandra opened a new pull request, #727:
URL: https://github.com/apache/datafusion-comet/pull/727
## Which issue does this PR close?
Part of [#679](https://github.com/apache/datafusion-comet/issues/679) and [#670](https://github.com/apache/datafusion-comet/issues/670)
.
## Rationale for this change
profiler output shows that with decimal128 enabled we have a bottleneck in `comet::common::bit::memcpy`.
In addition when decimal128 is not enabled we use the `Int32ToDecimal64ColumnReader` reader for decimals with precision lower than 9. This results in a conversion call to `comet::parquet::read::values::copy_i32_to_i64` which shows up in the hot path.
## What changes are included in this PR?
This PR changes the method to use `copy_nonoverlapped` for speed
This PR attempts to use the `Int32ColumnReader` so that we do not incur any conversion costs.
## How are these changes tested?
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
-->
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: decimal decode improvements [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove merged PR #727:
URL: https://github.com/apache/datafusion-comet/pull/727
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: decimal decode improvements [datafusion-comet]
Posted by "andygrove (via GitHub)" <gi...@apache.org>.
andygrove commented on PR #727:
URL: https://github.com/apache/datafusion-comet/pull/727#issuecomment-2260659529
@parthchandra The `memcpy` changes LGTM. Did you want to make this PR ready for review with just that change?
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: decimal decode improvements [datafusion-comet]
Posted by "kazuyukitanimura (via GitHub)" <gi...@apache.org>.
kazuyukitanimura commented on code in PR #727:
URL: https://github.com/apache/datafusion-comet/pull/727#discussion_r1698869304
##########
native/core/src/common/bit.rs:
##########
@@ -145,7 +145,9 @@ macro_rules! read_num_be_bytes {
#[inline]
pub fn memcpy(source: &[u8], target: &mut [u8]) {
debug_assert!(target.len() >= source.len(), "Copying from source to target is not possible. Source has {} bytes but target has {} bytes", source.len(), target.len());
- target[..source.len()].copy_from_slice(source)
+ // Originally `target[..source.len()].copy_from_slice(source)`
+ // We use the unsafe copy method to avoid some expensive bounds checking/
+ unsafe { std::ptr::copy_nonoverlapping(source.as_ptr(), target.as_mut_ptr(), source.len()) }
Review Comment:
`copy_from_slice` is `copy_nonoverlapping` with the `if self.len() != src.len()` check.
Do you have any benchmark results to show the difference by any chance?
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: decimal decode improvements [datafusion-comet]
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on code in PR #727:
URL: https://github.com/apache/datafusion-comet/pull/727#discussion_r1699268566
##########
native/core/src/common/bit.rs:
##########
@@ -145,7 +145,9 @@ macro_rules! read_num_be_bytes {
#[inline]
pub fn memcpy(source: &[u8], target: &mut [u8]) {
debug_assert!(target.len() >= source.len(), "Copying from source to target is not possible. Source has {} bytes but target has {} bytes", source.len(), target.len());
- target[..source.len()].copy_from_slice(source)
+ // Originally `target[..source.len()].copy_from_slice(source)`
+ // We use the unsafe copy method to avoid some expensive bounds checking/
+ unsafe { std::ptr::copy_nonoverlapping(source.as_ptr(), target.as_mut_ptr(), source.len()) }
Review Comment:
Before this
`scan decimal (spark) : 1.0x`
`scan decimal (Comet, decimal 128) : 0.4x`
After
`scan decimal (Comet, decimal 128) : 0.5x`
So a small improvement.
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org
Re: [PR] perf: decimal decode improvements [datafusion-comet]
Posted by "parthchandra (via GitHub)" <gi...@apache.org>.
parthchandra commented on PR #727:
URL: https://github.com/apache/datafusion-comet/pull/727#issuecomment-2260895855
@andygrove @kazuyukitanimura this is ready for review.
--
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@datafusion.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscribe@datafusion.apache.org
For additional commands, e-mail: github-help@datafusion.apache.org