-
Notifications
You must be signed in to change notification settings - Fork 5
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
Interleaving of code hints with function bodies #22
Comments
This concern has been raised before. My opinion is that this is not really an issue, because branch hints are quite rare in actual codebases. You can search on github for The situation is different for JIT-compiled code, but in that case the code is not downloaded at all, so it's not a problem. An intermediate case could be hints generated from PGO. I don't really know how many branches would be annotated as a result of PGO on an average, but even assuming a worst case scenario, the numbers are not too bad: I just did some quick math using two wasm modules i have laying around: a 5.5MB one compiled from C++, and a 18MB one compiled from Go. Counting the number of branch instructions with A more realistic ratio is probably 1 in 10 hinted branches or even less, so it seems to me that the overhead is quite negligible. (For my estimation I considered the size of a hint to be 4 bytes, plus 4 bytes for each hinted function) |
I generally agree and I'm not too worried about this section's size. I'm not sure branch hints would be useful for baseline compilation, because, at least Wizard's baseline compiler will always emit machine code in bytecode order, since it's single pass. So I see branch hinting as info primarily useful to the optimizing compiler. |
The code section can be really large in modules. In SpiderMonkey, we compile functions in the code section in parallel and kick off the tasks as soon as we get them off the network. So minimizing the information needed before being able to compile the first function is helpful.
If we expect many hints to be provided for the functions, then downloading and decoding the whole branch hint section before getting to the first function in the code section could delay compilation. It could be useful if the branch hints were inside the code section so that we only need to decode the hints for each function immediately before the function is compiled.
That would involve changing the code section, making this not a custom section anymore. I'm not sure if this was discussed previously and I forgot about it.
The text was updated successfully, but these errors were encountered: