Does 'async' throttle memory or require more memory?


#1

Correct me if I’m wrong but using ‘async’ everywhere in WinRT must buffer objects from the stack onto the heap (like in a closure) that otherwise could have been processed on the stack? If true this is fine for some tasks but why would such a slow practice become a requirement? I remember WP7 running very fast on slower single-core hardware. In fact better then WP8.1 on dual-core hardware in many cases. The Silverlight frameworks used ‘callback’ systems and thus performance could be better controlled is my guess (because of memory usage / bandwidth). It feels like memory performance got bottlenecked because of this async stuff being used on everything. Does ‘async’ throttle memory or require more memory?


#2

Generally, I think there should be no noticeable difference.

async is used for operations that can take a fairly long amount of time, so adding a small slowdown should not affect performance measurably.

That being said, there are cases where async can negatively affect performance, especially when you have an operation that is sometimes asynchronous, but most of the time is synchronous. To improve that, C# 7.0 is adding support ValueTask<T>, which avoids allocations in the synchronous case. Though I don’t know if there are any plans to use that in WinRT.


#3

async is used for operations that can take a fairly long amount of time, so adding a small slowdown should not affect performance measurably.

This isn’t rly true in many cases. If I keep micro allocating memory for operations that normally wouldn’t do so, I get nondeterministic GC collections / operations. Which would be bad for Xbox One games for example. While a callback system allows for more control over allocation (if the framework also takes this into account).

To me WinRT is relying on the GC in a bad way for its frameworks. IDK why else it would be running slower then WP7 did. From what you’ve said it seems to give weight to this assumption.

Anyway just avoid using async in games I guess. Normally games have there own async methods of doing things… I really don’t like this one async model fits all idea. Its impractical and an artificial limitation in WinRT (while its nice it exists for many apps). At least it looks like there may be some kind of workaround in C# 7.


.NET Foundation Website | Blog | Projects | Code of Conduct