-
Notifications
You must be signed in to change notification settings - Fork 50
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
Spinloop relaxation instruction #15
Comments
If we can get a rough sketch and some performance information then this is worth polling at the meeting. |
There's a writeup from Intel here: https://software.intel.com/en-us/articles/benefitting-power-and-performance-sleep-loops. Numbers at the end, though exactly how much they mean is a little vague because the paper mixes the discussion of PAUSE with a discussion of backoff. Generally it appears to be seen as a substantial benefit for hot spinloops because it lowers power consumption and relinquishes processor resources such as holds on the bus. On ARM this is the YIELD instruction (since ARMv6K). On POWER this is provided by different instructions in different subarchitectures, see eg https://stackoverflow.com/questions/5425506/equivalent-of-x86-pause-instruction-for-ppc/7588941#7588941. Apparently some C/C++ compilers provide _mm_pause() as an intrinsic to allow the compiler to emit this instruction. |
Oh, and as for a sketch, this would be an operand-free instruction, call it PAUSE or YIELD, that acts as a nop and has at most a performance impact. It would always be correct for a compiler to generate no code for the instruction. |
Oops, maybe better to put my comment from #11 here: There wasn't a poll about this in the CG meeting, but there seemed to be interest in exploring adding a yield operation (as opposed to pause). This would be defined in the spec as being a no-op, but would be a hint to implementations to yield execution to another thread. |
Hi! I'm looking at spin loop relaxation in Unity and without explicit instruction support in wasm it's tricky to get right. We either go with something like What are the chances of getting something like Cheers, ps. Let me know if you want me to open a WebAssembly/design issue on this instead. |
fwiw I like the old rust naming of this as it's very explicit - |
I think adding a |
No objections here - we previously had a short discussion in the in-person meeting where I advanced the opinion that this should be a hint on a loop or branch opcode, but given that it seems to be exposed as a separate instruction both above and below us in the compilation chain, that's probably not a good idea. One drop of bikeshedding - |
Maybe |
Oops, I forgot that our "nop" instruction is called |
In the old discussion the best suggestion was probably |
(Just to weigh in on the bikeshedding of the name). I think the name should connote its rough hardware effect rather than its use, because people end up finding new uses for things in the future. Yet, the Intel instruction to which this will map is called "pause" and its documentation reads:
|
This instruction was originally discussed in WebAssembly/threads#15, but did not make it into the original threads spec.
This instruction was originally discussed in WebAssembly/threads#15, but did not make it into the original threads spec.
(Forked from issue #11)
One operation that never made it into ES was an instruction to relax in a spinloop (ie, the PAUSE instruction in x86, IIRC). It was in the very earliest drafts of the spec but I think that, more than anything, it was considered very low-level for ES and something that would create controversy. (I experimented with a related idea, a micro-wait primitive with a back-off scheme, and I called that "pause" too, but it's not what I'm talking about here.)
I know that PAUSE is important for performance on x86. I don't know if ARM has anything similar in eg its event instructions (WFE). I don't know if it's a good idea to push this through for the MVP since we won't be able to remove it again if it turns out to be the wrong thing.
The text was updated successfully, but these errors were encountered: