Editorials

Fast Path Async Method Optimization

“Heavy Heap Allocation is like drinking alcohol; it’s not the drinking that hurts; it’s the hangover that hurts.”, Lucian Wischik, Microsoft Channel9. What does that have to do with Fast Path async optimization? The final goal of Fast Path optimization is to reduce the number of objects stored on the Heap, thus reducing the amount of work necessary by the Garbage Collector.

Lucian does a great job of helping us understand the concept of the async “Fast Path” when writing your own Async methods.

Generally, anync methods are not a big issue. However, when you begin calling async methods heavily it can become a BIG deal because of allocations on the Heap and the garbage collection necessary to resolve those allocations as they expire. Async methods require a number of allocations to the heap in order to handle the communications resulting on a heavier load on the Garbage Colleciton cycle.

The short story is that you can write your async methods using a technique called fast path. Fast path is a technique that will bypass creating objects if they are not necessary in order to fulfill the call.

Lucian gives a number of examples. One example that stood out fore me is a method that aquires a range of integers to be used in some fashion. The first call creates a buffer list of integers. Following invocations do not require the heavy lifting until the range of integers have been consumed.

Be sure to take a look at Lucian’s video explaining the Fast Path method for optimizing your Fast Path async methods; it only takes about 20 minutes, and is quite helpful.

Cheers,

Ben