-
Notifications
You must be signed in to change notification settings - Fork 17
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
Missing ConfigureAwait(false) #16
Comments
Since the stream provider runs in Orleans context as part of grain code ( If you think there's a specific place in which it should be used, please let us know. |
A great. Didn't know that. After reading the explanation makes total sense. But I think when you call out into the kafka infra you explicitely want to use i.ex. the IO thread pool and only when you callback into the greans you want to schedule on the turn based one. But I'm not familiar enough with the orleans scheduler. Thoughts?
|
I read the doco twice now. After reading a second time I realized the best practice applies to the user code inside a grain. Does this also hold up for the infrastructure pieces? I doubt that you want to bombard the grain scheduler with IO calls. Same applied for schedulers which are dispatcher-aware (like WPF), you want to offload the heavy lifting in the infra to the IO scheduler and only join back when the continuations call into the grains again. But I might be wrong
|
OK, so to make it more clear: // this code runs on Scheduler X - within some X context
What that means is that even if you are using Re libraries: indeed, a good practice in the library code is to call
Now the question in this Kafka provider is what is the library and what is "your code that does require to be run single threaded" (what is user code and what are "infrastructure pieces"). Another option is to make that call with Frankly, I would stay on the safe side and if in doubt, NOT use Bottom line - I totally agree with @danielmarbach: Hope that makes sense. |
Gabi, You mentioned a couple of reasons in favor of using ConfigureAwait(false) in pure library code. I can think of a reason against: when a silo is under heavy load, using two schedulers that employ a total number threads greater than the number of cpu cores will cause context switches and a lower total throughput. From our experience with our legacy asp.net stack when our production servers exceed 20%-30% cpu usage we're starting to see various timeout issues. Our hope is that our new Orleans stack will be able to sustain higher loads, if we stick to Orleans' scheduler, prevent thread starvations and reduce context switches. In light of that, do you think we're going overboard trying to stick with Orleans' scheduler? Do you believe reduced context switches aren't worth reduced parallelism and higher latency? |
Great question! Interestingly, you wrote:
Surprisingly, it is actually the other way around! Reduced parallelism (sometimes, not always but sometimes), results in lower latency! Example: You can also take a look in our technical report (http://research.microsoft.com/pubs/210931/Orleans-MSR-TR-2014-41.pdf) Section 5.1, Figure 5. It only discusses throughput, but is related to our discussion here. So bottom line: And just to restate the obvious here (for "liability reason", so I am not quoted latter on that Orleans "is so complicated"): our whole discussion here is since you guys in Gigya are super advanced users of Orleans. Our main target user is not an expert in Distributed Computing or Multi Threaded architectures, and for him the default out-of-the-box Orleans setting of single threaded Orleans scheduler in grains "just works", with great performance, and he does not need to even know about the existence of Sorry for such long answers. I like to be un-ambiguous. |
Gabi, thanks for taking the time to explain everything. No need to apologize for the long answers, they are very informative and the clarity is worth it! We'll follow through with your suggestion both here and on our Kafka client. When developing the stream provider we've relied on the Orleans docs page about tasks. Maybe it's worth to add this explanation to that page, or maybe create some advanced concepts page for it? |
Sure, I will add a comment there about using configureAwait(false) in libraries. |
I have added a section "Dealing with libraries" to http://dotnet.github.io/orleans/Advanced-Concepts/External-Tasks-and-Grains. Hopefully it will be more straightforward now. You have no idea (or maybe you do) how lucky you/we are to have |
It wouldn't hurt to add ConfigureAwait(false) to each awat statement in the production code.
https://msdn.microsoft.com/en-us/magazine/jj991977.aspx
The text was updated successfully, but these errors were encountered: