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

Try a branchless approach for the union of two sorted arrays (array containers) #506

Open
lemire opened this issue Jul 14, 2021 · 5 comments

Comments

@lemire
Copy link
Member

lemire commented Jul 14, 2021

See blog post Faster sorted array unions by reducing branches

@richardstartin
Copy link
Member

richardstartin commented Jul 14, 2021

It seems to rely on a CMov which requires the user to set -XX:+UseCMoveUnconditionally but it looks worth experimenting with

@lemire
Copy link
Member Author

lemire commented Jul 14, 2021

This fellow seems to report that Java will use conditional moves just fine on its own...

https://ivansmirnov.wordpress.com/2015/06/14/confirmed-openjdk-jit-compiler-emits-efficient-conditional-move-machine-codes/

@lemire
Copy link
Member Author

lemire commented Jul 14, 2021

Note that the evaluation of both paths is without side-effect so I do not expect that conditional moves break the specification.

@richardstartin
Copy link
Member

I was wrong, there is some up to date information on when cmov is used here https://shipilev.net/jvm/anatomy-quarks/30-conditional-moves/

@lemire
Copy link
Member Author

lemire commented Jul 23, 2021

I should say that whether it helps or not is tricky. If the branching is predictable, then it won't help and may even hurt us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants