-
Notifications
You must be signed in to change notification settings - Fork 847
When using TSContSchedule() and TSContScheduleAPI() set the calling thread as the thread affinity when not already set #6577
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is a good idea. The point of making the API changes is to make sure when writing new plugins, people need to understand there is a change to how threads are been used, and it is deliberately set to have it return null when calling the original api if no affinity thread is set. And even if you wish to set an affinity thread, I don't think using the "this_thread" is a good idea, since you might just end up on a thread you don't want. If you're experiencing errors when migrating, my suggestion is to just change all the calls to TSContSchedule to TSContScheduleOnPool, which accepts the same arguments and functions mostly the same, or we can rename TSContScheduleOnPool to be TSContSchedule again and remove the current TSContSchedule. The underlying logic of picking which thread is being used should be able to handle it.
I don't agree that we expect another API to be called to just to use |
That's why i suggest to remove that API completely and rename |
That should be totally fine IMO, as long as it's documented. Also, not always that a plugin calls |
Well, if you only call |
|
Let's see what @SolidWallOfCode have to say on this problem too, since he made a few important decisions on the original design. |
I don't think so. The plugin call backs run on the same NET threads as the HttpSM. You'd have to switch to a task thread explicitly if you want to. See the traceback below |
|
@sudheerv is correct, plugin hooks are called from It comes down to whether we want to have a simpler API or a clearer one. Removing |
+1 Since, |
|
I must have missed this in the PRs, I think the current behavior is not good. My suggestion would be
I think it's too late to do this for 9, as we should have. Overall I agree with @duke8253 - I just think the timing isn't right to fully change, but we should certainly do that for ATS 10. After pondering I think have an explicit pool or thread will be worth it to improve overall use of scheduled continuations. |
Yeah, I think that sounds reasonable. Thanks Alan! The only minor concern I'd have is replacing Thanks for the feedback and thanks in advance for approving it ;) |
…hread as the thread affinity when not already set
|
Allright, we'll just get rid of |
|
Cherry-picked to v9.0.x branch. |
This implies there's another PR coming, but that's only for 10.0 ? |
Yep |
It is unreasonable to expect TSContSchedule() and TSContScheduleAPI() to explicitly call TSContSetThreadAffinity() to work. The API should automatically handle the case when the thread affinity has not been set already.
This not only is an incompatible change (which I admit is not the unreasonable part given that this is a major release), but, forcing the user to call another API, instead of implicitly handling it doesn't sound reasonable.
Email to dev@