-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for PR 40537 (hint_core_should_pause) #41196
Comments
Reposting my comment from #41207: the I'd much prefer |
I like the Would it be a good time to propose stabilization after some name bikeshedding? |
@rfcbot fcp merge Sounds like a great issue to consider for stabilization! Proposed name
|
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once these reviewers reach consensus, this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
To be clear I also don't have much of a preference on names, @stjepang's preference of |
|
I am on board with stabilizing a function with this behavior. But in general, the more a function's behavior may be confusing, the more careful we need to be in selecting a name.
I also sort of like the naming that WebKit uses --
|
👍 to |
Looking at this again, I prefer It could also work as |
"Processor" sounds kinda wrong in this context IMO, since the word is so often used for the whole package with multiple cores, caches, etc, while the instruction applies to a "core" or "thread". |
|
Isn't |
Oh, right. |
I think that we should be cognisant of the case where someone imports both the processor and the thread yield functions at the same time. How would someone differentiate these functions? Additionally, what this function does isn't quite a "yield;" on x86 specifically, it simply delays the execution of the next instruction by a small amount to avoid a memory order violation, reducing power consumption but not really reducing execution time. It's less the program "yielding" to the CPU and more the program telling the CPU "I'm just going to loop again, so, take your time." Additionally, the thread version of a yield will definitely yield, whereas this will simply do nothing on architectures which have no such function. It makes a lot more sense to call this a hint than a yield. |
Also this is a general question, but how reasonable would it be for the compiler itself to notice these cases and simply insert the instruction into busy loops? For example, something like |
@clarcharr
I don't think the compiler can automatically decide when and where to insert the instruction into a loop. This is something only the programmer knows, really. Inserting the instruction into a loop is a very delicate matter. Consider how if self.counter <= 10 {
cpu_relax(4 << self.counter);
} else {
thread_yield();
} Here, There's no recipe for how to properly use the instruction. You just have to carefully tweak the parameters, profile the program, and see what works best. There's no other way. :) |
I'm not familiar with this function, but after spending a few minutes reading up on it, I believe |
From the Intel Optimization Manual, section 8.4.7:
The instruction's original function (hint to avoid memory order violation) has been extended quite a bit. So yes, it does yield resources. |
I'm going to go ahead an check @BurntSushi's checkbox as it's been awhile and I think he's quite busy! |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period is now complete. |
I marginally prefer |
…sfackler Stabilize spin_loop_hint Stabilize `spin_loop_hint` in release `1.23.0`. I've also renamed feature `hint_core_should_pause` to `spin_loop_hint`. cc rust-lang#41196
In #43751, there has been some talk of stabilizing module (just a reminder: this feature is currently in beta, scheduled for stabilization in 1.24) |
This feature was stabilized. Let's close the issue. |
Tracking #40537 (comment)
The text was updated successfully, but these errors were encountered: