-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Remove o == this
check from generated equals
?
#1633
Comments
Thanks for the pointer! I watched the video, and I admit I was confused for a while about exactly what the "Guava generator" was that is referred to. I think it is actually the Guava Eclipse Plugin, which is not produced by the team responsible for Guava, though AutoValue is. It's certainly interesting to wonder whether the I think most of the time when you care about the performance of Still, it might be worth thinking about some sort of heuristic. For example, only do the |
I have idly wondered before whether AutoValue, protobuf, etc. might be able to optimize the order in which they compare fields, like by comparing all primitives before any objects. Really, the ideal is probably for the code author to design the class such that the fields that are most likely to differ come first (though that's a bit of an odd thing to encode into the API :))... or maybe for profile-guided optimization to pick the ordering. But that's hard when the gains are diffuse—and maybe small even in total. |
It appears that most cases
o == this
check actually degrades performance because of branch prediction algorithms. It might be worth considering to remove it from auto-value templates. Sorry for linking to YT, but there's no article anywhere - at least I couldn't find any.Please see https://www.youtube.com/watch?v=kuzjX_efuDs.
The text was updated successfully, but these errors were encountered: