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

Check likely/unlikely hinting #5309

Closed
paulbiss opened this issue May 7, 2015 · 7 comments
Closed

Check likely/unlikely hinting #5309

paulbiss opened this issue May 7, 2015 · 7 comments

Comments

@paulbiss
Copy link
Contributor

paulbiss commented May 7, 2015

Measure branch prediction and cache line packing effects of the LIKELY() and UNLIKELY() macros in HHVM sources to ensure these are providing the correct predictions. There are a lot of these (~2000) so this could take a long time to do. (This may be too tedious to do during lockdown).

@jwatzman
Copy link
Contributor

jwatzman commented May 8, 2015

I'm not super convinced this is something we can do a lot with, and seems better left for the JIT team?

@paulbiss
Copy link
Contributor Author

paulbiss commented May 8, 2015

I'm not super optimistic that they're going to be able to do much with it either. There are somewhere around 860 of them under hphp (and more littered elsewhere in dependent libraries), and the only thing we know for sure is that removing all of them is a regression.

The effect of any one of these would be unlikely to be measurable, and nearly all of them were placed based solely on intuition.

@jwatzman
Copy link
Contributor

Doing something completely unrelated, I came across this in the Linux kernel: https://github.com/torvalds/linux/blob/v4.0/include/linux/compiler.h#L111-L136

Basically, we could make our LIKELY/UNLIKELY macros actually record the result of the branch in some debug mode, so we could check our intuition, see what the distribution is, etc. Still some work in recording, printing, etc this data, as well as reading the data and playing with the results, but there's probably stuff to look at here.

@paulbiss
Copy link
Contributor Author

I like this idea!

@Orvid Orvid closed this as completed Jul 27, 2016
@jwatzman
Copy link
Contributor

If you don't mind, I still think this is worth doing, unless it's been done internally (which I wouldn't have heard about)? I may come back to it at a hackathon or something for fun.

@jwatzman jwatzman reopened this Jul 28, 2016
@Orvid
Copy link
Contributor

Orvid commented Jul 28, 2016

I just went through and closed all of the lockdown issues, which is where this came from :P

@Orvid
Copy link
Contributor

Orvid commented Sep 30, 2016

There are some automated tools that, with some modification, would do this far better and easier than manual review, so this is a task best discussed internally.

@Orvid Orvid closed this as completed Sep 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants