Tuesday, March 26, 2013

C# 4.5 and CLR Revolution

C# Generation Next


CLR Inside

Courtsey Maoni Stephen's White paper
http://blogs.msdn.com/b/dotnet/archive/2012/07/20/the-net-framework-4-5-includes-new-garbage-collector-enhancements-for-client-and-server-apps.aspx


1. Background Server Garbage Collection

Before version 4, the .NET Framework provided a concurrent GC mode that performed full GCs concurrently with user code (vs. blocking, which pauses all user threads), thus reducing pause time for full GCs. This mode was available only for workstation GC.

In the .NET Framework 4, we delivered an improved version called the background workstation garbage collection, which reduced latency but only benefited client apps.

In the .NET Framework 4.5, we have delivered background server garbage collection, which is typically used for server apps. As a result, all apps now have background GC available to them, regardless of which GC they use.

Backgorund GC Operation


  • They apply only to generation 2 GCs.
  • They don't compact the heap.
  • Generation 0 and 1 GCs do not happen concurrently with background GC, but they suspend all user and background GC threads


  • 2. GC Collect Inversely Proportional to Throughoutput Balanced LOH

    More GC collect less throughoutput.Vice versa

    Common Root Cause for above IMBALANCE GC HEAP
    For server GC, GC trigger when heap runs out of allocation.

    1 Logical processors have 1 heap.

    In one application server there are many worker processors which spuns many threads and these threads in turns consume memory.

    In the .net framework 4, small object heap memory allocation is balanced where as LOH is not balanced due to which the GC triggers lot.

    In the .net framework 4.5,SOH and LOH are balanced hence it triggers less GC.



    3.Support Large Dataset >2GB

    We can now able to process array with large dataset. It is configured using .Previously it was throwing OutofMemory exception due to 32 bit nature of OS/Framework.



    4. Reuse free available memory after GC collect.

    In earlier releases of the .NET Framework, once a memory block was rejected as a candidate for an allocation, it was removed as a candidate for subsequent allocations.

    In the .NET Framework 4.5, we now retain free memory blocks as candidates for allocation requests until they are used. The new algorithm uses LOH space much more efficiently, leading to decreased fragmentation and memory use.



    5. SustainLowLatency- Avoid Full blocking of GC

    While the SustainedLowLatency setting is in effect, generation 0, generation 1, and background generation 2 collections still occur and do not typically cause noticeable pause times. A blocking generation 2 collection happens only if the machine is low in memory or if the app induces a GC by calling GC.Collect().



    6. NUMA-Non uniform Memory Access, Black box for me.

    Unable to understand the basic fundamentals of it. If someone can flash few reference to help me understand this. Regret for Ignorance on this subject.






    No comments :