Performance: Garbage collection modes.

30 במרץ 2009

4 תגובות

There are allots of improvements that can be done within application’s configuration file the only catch with it – you have to know that it’s exists. In this post I will show how to improve garbage collection performance according to application’s type.

There are 3 modes of garbage collection that can be defined in a configuration file:

  • Workstation mode with enabled Concurrent flag
  • Workstation mode with disabled Concurrent flag
  • Server mode

Workstation mode with enabled Concurrent flag

This mode is designed to get a better responsiveness of an application’s UI and the price for the responsiveness is more CPU and memory usage.

By default this mode is enabled in Windows Forms applications, Console Applications and Windows Services .

Workstation mode with disabled Concurrent flag

This mode is optimized for height throughput applications running on single CPU computers although it is stops current thread when GC is active. Therefore it is not a best choice for an applications with UI present.

To configure this mode following must be inserted at configuration file:

<configuration>
<runtime>
<gcConcurrent enabled="false"/>
</runtime>
</configuration>

Server mode

In the Server GC mode, GC heap and GC thread are created for each CPU available, making application’s throughput and scalability higher. This mode is available only on multiprocessors systems and it is default at ASP.NET applications.

To configure this mode following must be inserted at configuration file:

<configuration>
<runtime>
<gcServer enabled="true"/>
</runtime>
</configuration>

Summary

In the age of parallel processing when most computers are already have at least two CPUs might be a good idea to test application’s performance with GC mode set to Server mode. Good example for such applications is WCF services host, which in many cases is Console application or Windows Service. In a upcoming Parallel Extensions Library the Server GC mode is a recommended mode by Microsoft for a better performance.

For a dipper exploration of GC principles and modes please refer to a Maoni’s posts.

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. (*) שדות חובה מסומנים

4 תגובות

  1. Gilad Lavian30 במרץ 2009 ב 12:20

    Great post!
    I also enjoyed reading Maoni’s posts.

    Thanks.

    להגיב
  2. Rotem Bloom31 במרץ 2009 ב 8:21

    אחלה של פוסט, תודה על השיתוף.
    לפי מה שאני זוכר אי אפשר לשנות את הקונפיגורציה הזאת בזמן ריצה זה נכון?
    תודה רתם

    להגיב
  3. Frolov Yevgeni31 במרץ 2009 ב 8:52

    No, Rotem, there is a way to check if GC currently in Server GC mode by checking following property in System.Runtime namespace, but not to set it:
    GCSettings.IsServerGC – it is a boolean get property…

    להגיב
  4. Avi Pinto23 במאי 2009 ב 23:44

    מעניין, תודה

    להגיב