Skip to content

Improve the performance of early exit evaluation in binary_expr #15631

@alamb

Description

@alamb

Is your feature request related to a problem or challenge?

@acking-you 's wonderful PR #15462 adds short circuiting to boolean operation evaluation which makes evaluating some complex expressions much faster.

However, to do so it uses the count_ones function to check

Image

We have theorized it should be faster to simply check if there are any set bits in the array rather than using count_zeros, however @acking-you found that this is not easy to do as Rust generates very optimized code for count_ones

You can see an example of this analysis
#15462 (comment)

Describe the solution you'd like

Now that we have benchmarks for binary_op it would be great to see if we can optimize this codepath more

Describe alternatives you've considered

Roughly speaking you can run the benchmarks with

cargo bench --profile=profiling  --bench binary_op

And then profile that with your favorite tool

For example, you can use samply like this:

samply record   target/profiling/deps/binary_op-cce23ddc74cdfa3a --bench

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions