You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/12/09 00:20:34 UTC

[GitHub] [arrow-datafusion] comphead opened a new pull request, #4560: Write faster kernel for is_distinct

comphead opened a new pull request, #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560

   # 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 #4482.
   
   # Rationale for this change
   See #4482 
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # 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)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   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 `api 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


[GitHub] [arrow-datafusion] alamb commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344215044

   @tustvold  do you have any additional suggestions for speeding up this kernel?


-- 
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


[GitHub] [arrow-datafusion] Dandandan commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
Dandandan commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344860319

   Ah on further look - I think it might not be correct for when the left and/or right side doesn't contain a null bitmap.


-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344643540

   >  Yes, I believe there is a ticket already to add it
   
   https://github.com/apache/arrow-rs/issues/960


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1345182817

   Agreed, I got the boolean expression wrong, I think the corrected form I posted is correct, and would require handling the single buffer case?


-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1353533903

   > Do we need to move the is distinct and is not distinct to arrow-rs?
   
   I agree -- we should move the kernel to arrow and that work is tracked by https://github.com/apache/arrow-rs/issues/960 (which is also referenced in the code) https://github.com/apache/arrow-datafusion/pull/4560/files#diff-133624520f20c20b33c2c54ec6ae565f09b058ef317ede0e768bd23bae30941dR26


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on a diff in pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on code in PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#discussion_r1047821803


##########
datafusion/physical-expr/src/expressions/binary/kernels_arrow.rs:
##########
@@ -515,4 +513,40 @@ mod tests {
         let err = modulus_decimal_scalar(&left_decimal_array, 0).unwrap_err();
         assert_eq!("Arrow error: Divide by zero error", err.to_string());
     }
+
+    #[test]
+    fn is_distinct_from_nulls() -> Result<()> {

Review Comment:
   :+1:



-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1346615315

   Thank you @comphead 
   
   Here is what I recommend:
   1. Add tests to this PR (or point at other pre-existing tests) that show it works correctly with `NULL` values
   2. Merge this PR and we can file a ticket to switch to the arrow-rs kernel if/when that is available.
   


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1349906330

   Avg time now **70s**
   
   @alamb added tests for nulls
   @tustvold iterating through `.values()` is significantly faster than accessing `value_unchecked(i)`
   @Dandandan you mentioned null bitmap is optional, is it for some specific primitiveArray types?


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1352554241

   @liukun4515 thats a great question and the ticket still exists https://github.com/apache/arrow-rs/issues/960
   But it requires a bit more work on arrow side, planning to take care on this ticket


-- 
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


[GitHub] [arrow-datafusion] liukun4515 commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
liukun4515 commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1352487618

   Do we need to move the `is distinct` and `is not distinct` to arrow-rs? 
   cc @alamb @alamb 


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344873446

   > please correct me if I'm wrong but current implementation in datafusion also lacks null bitmap?
   
   The iterators consult the bitmap and return `Option<T>` and so the `x == y` is actually comparing `Option` and not the bare values.
   
   > I think it might not be correct for when the left or right side doesn't contain a null bitmap.
   
   Assuming `*out & (left | right)`  is correct (which I _think_ it is) if either side is missing a null bitmap it simplifies to `*out & (left | TRUE)` i.e. `*out`.


-- 
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


[GitHub] [arrow-datafusion] Dandandan commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
Dandandan commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1352121111

   Nice, thank you @comphead !


-- 
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


[GitHub] [arrow-datafusion] alamb merged pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb merged PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1345348792

   @Dandandan when you say null bitmap,  do you mean this structure
   https://github.com/apache/arrow-datafusion/blob/master/datafusion/common/src/from_slice.rs#L105?
   
   


-- 
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


[GitHub] [arrow-datafusion] Dandandan commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
Dandandan commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344855803

   Looks correct to me and a really clever implementation!


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344393843

   It needs proper testing but the following I think is correct
   
   ```
   pub(crate) fn is_distinct_from<A>(left: A, right: A) -> Result<BooleanArray>
   where
       A: ArrayAccessor,
       A::Item: PartialEq,
   {
       let ld = left.data();
       let rd = right.data();
       assert_eq!(ld.len(), rd.len());
   
       let mut distinct = MutableBuffer::collect_bool(left.len(), |i| unsafe {
           // SAFETY: i in range 0..len
           left.value_unchecked(i) != right.value_unchecked(i)
       });
   
       if let (Some(l), Some(r)) = (ld.null_buffer(), rd.null_buffer()) {
           let left = BitChunks::new(l.as_slice(), ld.offset(), ld.len());
           let right = BitChunks::new(r.as_slice(), rd.offset(), rd.len());
   
           // Pad to multiple of u64
           distinct.resize(bit_util::ceil(ld.len(), 8), 0);
   
           // Distinct so long as one or both are valid
           distinct
               .typed_data_mut::<u64>()
               .iter_mut()
               .zip(left)
               .zip(right)
               .for_each(|((out, left), right)| *out = *out & (left | right))
       }
   
       let builder = ArrayDataBuilder::new(DataType::Boolean)
           .len(left.len())
           .add_buffer(distinct.into());
   
       Ok(BooleanArray::from(unsafe { builder.build_unchecked() }))
   }
   ```
   
   I'll work on getting it added to arrow-rs


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344643258

   > Yes, I believe there is a ticket already to add it
   
   Thanks, please ping the arrow-rs ticket for tracking and we close this issue once adopt arrow-rs new implementation


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1351741474

   Thanks @alamb Added 1 more test to cover ```
   Arrow arrays will only contain a null bitmap if they have a non-zero null count, otherwise it will be empty. No null buffer means all positions are valid, i.e. non-null.``` 
   
   For bench I'll create a separate PR


-- 
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


[GitHub] [arrow-datafusion] Dandandan commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
Dandandan commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1345182062

   > > please correct me if I'm wrong but current implementation in datafusion also lacks null bitmap?
   > 
   > The iterators consult the bitmap and return `Option<T>` and so the `x == y` is actually comparing `Option` and not the bare values.
   > 
   > > I think it might not be correct for when the left or right side doesn't contain a null bitmap.
   > 
   > Assuming `*out & (left | right)` is correct (which I _think_ it is) if either side is missing a null bitmap it simplifies to `*out & (left | TRUE)` i.e. `*out`.
   > 
   > Edit: I think it might need to be `(*out & left & right) | (left ^ right)` 🤔
   
   The main thing I think is wrong is that `left.value_unchecked(i) != right.value_unchecked(I)` might return true or false regardless of validity for each `i`. If only the left side contains a bitmap, it should also consider this left bitmap for the results (always distinct if left side is null value regardless of values or distinct if valid and having different values)`.


-- 
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


[GitHub] [arrow-datafusion] Dandandan commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
Dandandan commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1345371014

   > 
   
   I mean the validity/null data structure that can optionally be present in arrow arrays. This uses a bitmap to encode false/true values (not valid / valid).
   
   You can see it is accessed as `.null_buffer()` from the code from @tustvold .


-- 
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


[GitHub] [arrow-datafusion] Dandandan commented on a diff in pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
Dandandan commented on code in PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#discussion_r1044424248


##########
datafusion/physical-expr/src/expressions/binary/kernels_arrow.rs:
##########
@@ -55,11 +55,58 @@ pub(crate) fn is_distinct_from<T>(
 where
     T: ArrowNumericType,
 {
-    Ok(left
-        .iter()
-        .zip(right.iter())
-        .map(|(x, y)| Some(x != y))
-        .collect())
+    let array_len = left.data().len().min(right.data().len());
+    let mut arr = vec![false; array_len].into_boxed_slice();
+
+    let left_values = left.values();

Review Comment:
   It should also look at the null bitmap (if available).



-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344620606

   Thanks @tustvold @Dandandan for the feedback. The same 1B perf test for the code above is **90s**.
   
   Will `is_distinct_from<A>/is_not_distinct_from<A>` be a part of arrow-rs and datafusion adopts it with new arrow-rs version? 
   


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344624268

   Yes, I believe there is a ticket already to add it


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1344862892

   > Ah on further look - I think it might not be correct for when the left or right side doesn't contain a null bitmap.
   
   @Dandandan please correct me if I'm wrong but current implementation in datafusion also lacks null bitmap?


-- 
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


[GitHub] [arrow-datafusion] ursabot commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
ursabot commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1352123362

   Benchmark runs are scheduled for baseline = 40e6a67604514124332bf132020a026bbe5b5903 and contender = 454203174a49ac8f36fc64da59f43d20c1400348. 454203174a49ac8f36fc64da59f43d20c1400348 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
   Conbench compare runs links:
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] [ec2-t3-xlarge-us-east-2](https://conbench.ursa.dev/compare/runs/cd60e9f4966d42199acc32987c515dc3...358b1912cf88474ba545bab17b551b8e/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] [test-mac-arm](https://conbench.ursa.dev/compare/runs/bb7edd0c83fd46ba8bde76e5eb8cbd55...9c80207f9a104b1cb749445553a85af1/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] [ursa-i9-9960x](https://conbench.ursa.dev/compare/runs/169e796ec820431d91cbb9c02a86bbf1...387162958c664b43a78a0377ac613f38/)
   [Skipped :warning: Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] [ursa-thinkcentre-m75q](https://conbench.ursa.dev/compare/runs/df1c189de11b47a2952623dd8ef2d3d1...a8329820b7a242df92adf394943b4d90/)
   Buildkite builds:
   Supported benchmarks:
   ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
   test-mac-arm: Supported benchmark langs: C++, Python, R
   ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
   ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java
   


-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1352118183

   Thanks @comphead 


-- 
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


[GitHub] [arrow-datafusion] comphead commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
comphead commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1343632676

   Hi @Dandandan 
   
   This change includes optimization for `is_distinct/is_not_distinct`.
   
   1B array processed with avg **170s** before, and **80s** now.
   
   Also using our own conversion to `BooleanArray` instead of `BooleanArray::from_slice`, as their implementation likely loses ticks on derefencing in loop. This part allowed to save 20s. Perhaps we can fix it in arrow-rs as well.
   


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1346622521

   Some example cases to try out might be:
   
   * NULL is distinct from the 0 value
   * NULL is not distinct from NULL even if the value in the corresponding null slots are distinct
   * NULL is distinct from an array containing no nulls


-- 
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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on code in PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#discussion_r1048318618


##########
datafusion/physical-expr/src/expressions/binary/kernels_arrow.rs:
##########
@@ -482,4 +513,40 @@ mod tests {
         let err = modulus_decimal_scalar(&left_decimal_array, 0).unwrap_err();
         assert_eq!("Arrow error: Divide by zero error", err.to_string());
     }
+
+    #[test]
+    fn is_distinct_from_nulls() -> Result<()> {
+        let left_int_array =
+            create_int_array(&[Some(0), Some(0), None, Some(3), Some(0), Some(0)]);
+        let right_int_array =
+            create_int_array(&[Some(0), None, None, None, Some(0), None]);
+
+        // is_distinct: left distinct right
+        let result = is_distinct_from(&left_int_array, &right_int_array)?;
+        assert_eq!(
+            BooleanArray::from(vec![
+                Some(false),
+                Some(true),
+                Some(false),
+                Some(true),
+                Some(false),
+                Some(true)
+            ]),
+            result
+        );
+        // is_distinct: left distinct right

Review Comment:
   ```suggestion
           // is_not_distinct: left distinct right
   ```



-- 
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


[GitHub] [arrow-datafusion] alamb commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
alamb commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1350915531

   I think this PR is ready to merge. Please let me know if there any concerns with doing so otherwise I will do so tomorrow


-- 
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


[GitHub] [arrow-datafusion] tustvold commented on pull request #4560: Write faster kernel for is_distinct

Posted by GitBox <gi...@apache.org>.
tustvold commented on PR #4560:
URL: https://github.com/apache/arrow-datafusion/pull/4560#issuecomment-1349929493

   > iterating through .values() is significantly faster than accessing value_unchecked(i)
   
   Yeah, I've seen this before. Last time it required some hackery with `inline(never)` to make it do the right thing. It is frustrating playing LLVM bingo :laughing: 
   
   > Avg time now 70s
   
   Very cool, perhaps you could add the benchmark code so that we can catch regressions in this? I'm also curious if this benchmark contains any null values?


-- 
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