Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize is_distinct_from / is_not_distinct_from #4482

Closed
Dandandan opened this issue Dec 2, 2022 · 2 comments · Fixed by #4560
Closed

Optimize is_distinct_from / is_not_distinct_from #4482

Dandandan opened this issue Dec 2, 2022 · 2 comments · Fixed by #4560
Labels
enhancement New feature or request performance Make DataFusion faster

Comments

@Dandandan
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Currently is_distinct_from and is_not_disctinct_from is written in an unoptimized way:

left
        .iter()
        .zip(right.iter())
        .map(|(x, y)| Some(x != y))
        .collect()

Describe the solution you'd like
Write a faster kernel.

Describe alternatives you've considered

Additional context

@Dandandan Dandandan added enhancement New feature or request performance Make DataFusion faster labels Dec 2, 2022
@comphead
Copy link
Contributor

comphead commented Dec 8, 2022

@Dandandan may I try this?

test to reproduce

    #[test]
    fn bench_is_distinct_from() {
        let max = 1_000_000_000;
        let l_array: &[Option<i128>] = &(0 .. max).map(|v| Some(v)).collect::<Vec<Option<i128>>>();
        let r_array: &[Option<i128>] = &(0 .. max).map(|v| Some(v+1)).collect::<Vec<Option<i128>>>();
        println!("Elapsed: {:.2?}", elapsed);

        let left_array = create_decimal_array(l_array, 10, 1);
        let right_array = create_decimal_array(r_array, 1, 1);

        use std::time::Instant;
        let now = Instant::now();
        is_distinct_from(&left_array, &right_array);
        let elapsed = now.elapsed();
        println!("Elapsed: {:.2?}", elapsed);
    }

1_000_000_000 -> Elapsed: 174.09s Cant say for mem usage for now.
I'll update on rewrite results.

@Dandandan
Copy link
Contributor Author

@Dandandan may I try this?

test to reproduce

    #[test]
    fn bench_is_distinct_from() {
        let max = 1_000_000_000;
        let l_array: &[Option<i128>] = &(0 .. max).map(|v| Some(v)).collect::<Vec<Option<i128>>>();
        let r_array: &[Option<i128>] = &(0 .. max).map(|v| Some(v+1)).collect::<Vec<Option<i128>>>();
        println!("Elapsed: {:.2?}", elapsed);

        let left_array = create_decimal_array(l_array, 10, 1);
        let right_array = create_decimal_array(r_array, 1, 1);

        use std::time::Instant;
        let now = Instant::now();
        is_distinct_from(&left_array, &right_array);
        let elapsed = now.elapsed();
        println!("Elapsed: {:.2?}", elapsed);
    }

1_000_000_000 -> Elapsed: 174.09s Cant say for mem usage for now. I'll update on rewrite results.

Sure, that would be awesome 😎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance Make DataFusion faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants