Welcome to MSDN Blogs Sign in | Join | Help

Server, Workstation and Concurrent GC

One common question I see asked is the differences between server and workstation GC, and how Concurrent GC fits in.

Server GC is only available on multi-proc machines. It creates one GC heap (and thus one GC thread) for each processor, which are collected in parallel. This GC mode maximizes throughput (number of requests per second) and shows good scalability (performance really shines with 4 or more processors).

Workstation is the default GC mode. On a single-proc machine, it’s the only option.

Concurrent GC is used in Workstation mode on a multi-proc machine. It performs full collections (generation 2) concurrently with the running program, minimizing the pause time. This mode is particularly useful for applications with graphical user interfaces or applications where responsiveness is essential.

How do I choose a GC mode?

In v1.0 and v1.1 (pre-SP1), server mode can only be used if the runtime is hosted in an unmanaged application (for example, ASP.NET hosts web applications in server mode). Concurrent mode can be specified in the machine or application’s configuration file. If neither is chosen, or if on a single-proc machine, Workstation is the default.

Note: Server mode automatically disables Concurrent GC.

To set GC mode to Concurrent:

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

To set GC mode to Server (unmanaged C++):

HRESULT CorBindToRuntimeEx( LPWSTR pwszVersion,
  LPWSTR pwszBuildFlavor, // use “svr” for server mode,
  // “wks” or NULL for workstation
  DWORD flags,
  REFCLSID rclsid,
  REFIID riid,
  LPVOID* ppv );

One of the most popular feature requests was the ability to specify the GC mode in a non-hosted managed application. In Whidbey (v2.0) and v1.1 SP1, we added a new feature that allows you to specify the GC mode in the application’s config file:

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

Note: if the application is hosted, the host’s GC mode overrides the config file.

How do I tell which GC mode my app is using?

In v1.0 and v1.1 of the CLR, the GC was contained in two core DLLs: mscorwks.dll and mscorsvr.dll. If the application is running in server mode, then mscorsvr.dll is loaded, otherwise, mscorwks.dll is loaded. The only way to tell which is loaded is to look at the list of running processes.

Remember, on a single proc-machine, it’s Workstation. On a multi-proc where throughput is important, use Server. If there's user interaction, choose Concurrent.

Edit: Minor corrections.

Edit: Fixed case in XML tags. Thanks Tyler!

Published Wednesday, September 08, 2004 11:48 AM by clyon
Filed under: ,

Comments

# How I Learned to Stop Worrying and Love the GC

Wednesday, September 08, 2004 3:06 PM by .Net Security Blog

# re: Server, Workstation and Concurrent GC

Friday, September 10, 2004 6:33 AM by Hernan de Lahitte
Cool. I was waiting for this setting for my Managed Win32 Service. I will be looking forward to your blog posts!

# Server GC Misconceptions

Friday, September 10, 2004 8:19 PM by Chris Lyon's WebLog

# Garbage Collector Deathmatch -

Monday, January 31, 2005 7:27 AM by JCooney.NET

# re: Garbage Collector Deathmatch -

Monday, January 31, 2005 7:27 AM by JCooney.NET
Hi Joseph, here's 2 more blog entries by Chris Lyon (he's a .NET GC Tester) you could take a look at that I spotted over the weekend, relating to the two GCs in .NET 1.x.

# How To Tell Which GC Mode Your Application Is Using

Friday, February 04, 2005 5:05 PM by Chris Lyon's WebLog

# Server GC Misconceptions

Thursday, March 17, 2005 7:51 PM by Chris Lyon's WebLog

# Special threads in CLR

Tuesday, July 05, 2005 1:05 PM by Yun Jin's WebLog
Question: How many threads does a typical managed process have when it just starts to run?&amp;nbsp;&amp;nbsp;...

# Special threads in CLR

Tuesday, July 05, 2005 1:09 PM by Yun Jin's WebLog
Question: How many threads does a typical managed process have when it just starts to run?&amp;nbsp;&amp;nbsp;...

# Special threads in CLR

Tuesday, July 12, 2005 2:32 PM by Yun Jin's WebLog
Question: How many threads does a typical managed process have when it just starts to run?&amp;nbsp;&amp;nbsp;...

# How many threads does a typical managed process have when it just starts to run?

Thursday, August 18, 2005 12:33 PM by C#, VS Deployment and all geek talk

# Special threads in CLR

Sunday, August 28, 2005 3:44 PM by Yun Jin's WebLog
Question: How many threads does a typical managed process have when it just starts to run?&amp;nbsp;&amp;nbsp;...

# Improve load test performance on multi-processor machines

Wednesday, June 14, 2006 10:09 AM by Sean Lumley's Blog
This post is about improving the performance of a load test when running the test on a multi-processor...

# Improve load test performance on multi-processor machines

Friday, December 15, 2006 12:16 PM by Sean Lumley's Blog

This post is about improving the performance of a load test when running the test on a multi-processor

# New In Orcas Part 3: GC Latency Modes

Monday, March 12, 2007 3:15 PM by Chris Lyon's WebLog

As you may know, there are different GC modes to choose from depending on the type of application you’re

# .NET Garbage Collector PopQuiz - Followup at Sanal Kiler

PingBack from http://sanal.org/?p=309

# .NET Garbage Collector PopQuiz - Followup

Tuesday, April 17, 2007 5:14 AM by If broken it is, fix it you should

It was really exciting to see that so many people answered the .NET GC PopQuiz , especially seeing that

# re: Server, Workstation and Concurrent GC

Sunday, May 13, 2007 1:37 PM by chew

Hi Chris,

I've a doubt on GC Server throughput. If I've 4 processors and I've an application running 4 threads, each on one processor, how does my application performance benefits from GC Server mode?

chew

# re: Server, Workstation and Concurrent GC

Monday, May 14, 2007 10:41 AM by clyon

Hi Chew

On a 4-proc machine, Server GC will give you 4 GC Heaps, each with its own GC thread.  In general, this will improve throughput since you'll have 4 times the number of threads collecting garbage than one.

However, depending on your application and its environment, Server GC may not be the most optimal solution for you.  See Maoni's blog entry here:

http://blogs.msdn.com/maoni/archive/2006/02/28/workstation-gc-for-server-applications.aspx

-Chris

# re: Server, Workstation and Concurrent GC

Monday, May 14, 2007 9:28 PM by chew

Hi Chris,

I've posted the same question at maoni's blog. I thought I'll post it here again. Hope you don't mind. Do you think the used of GC in .Net has robbed its suitability in high performance computing applications, considering the fact that GC will suspend all managed threads and perform compacting of memory?

chew

# re: Server, Workstation and Concurrent GC

Tuesday, May 15, 2007 11:29 AM by clyon

Hi Chew

I don't think .NET is unsuitable for all high performance applications, although as you pointed out, managed memory environments are not always suitable for applications with hard real-time requirements.  We on the GC team are always working hard to enhance performance and reliablity of the GC and improve the user experience.  

We have added new features in Orcas that reduce GC intrusiveness for blocks of performance-sensitive code (see http://blogs.msdn.com/clyon/archive/2007/03/12/new-in-orcas-part-3-gc-latency-modes.aspx).  Rest assured, performance is one of the GC team's top priority.

# On Measuring Performance

Thursday, December 27, 2007 3:05 PM by All Your Base Are Belong To Us

To rephrase this post (or rant) in a nutshell: Measuring performance is not as simple as people think

Anonymous comments are disabled
 
Page view tracker