Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we use "workstation" garbage collection or "server" garbage collection?

People also ask

What is server garbage collection?

Server garbage collection is designed for server applications and creates a separate managed heap and a corresponding garbage collection thread for each logical CPU. Threads run on highest priority making it faster but more resource intensive.

What is Microsoft GC?

In the common language runtime (CLR), the garbage collector (GC) serves as an automatic memory manager. The garbage collector manages the allocation and release of memory for an application. For developers working with managed code, this means that you don't have to write code to perform memory management tasks.


It's not explained very well, but as far as I can tell, the server mode is synchronous per core, while the workstation mode is asynchronous.

In other words, the workstation mode is intended for a small number of long running applications that need consistent performance. The garbage collection tries to "stay out of the way" but, as a result, is less efficient on average.

The server mode is intended for applications where each "job" is relatively short lived and handled by a single core (edit: think multi threaded web server). The idea is that each "job" gets all the cpu power, and gets done quickly, but that occasionally the core stops handling requests and cleans up memory. So in this case the hope is that GC is more efficient on average, but the core is unavailable while its running, so the application needs to be able to adapt to that.

In your case it sounds like, because you have a single application whose threads are relatively coupled, you're fitting better into the model expected by the first mode rather than the second.

But that's all just after-the-fact justification. Measure your system's performance (as ammoQ said, not your GC performance, but how well you application behaves) and use what you measure to be best.


.NET 4.5 introduces concurrent server garbage collection.

http://msdn.microsoft.com/en-us/library/ee787088.aspx

specify <gcServer enabled="true"/> 
specify <gcConcurrent enabled="true"/> (this is the default so can be omitted)

And there is the new SustainedLowLatencyMode;

In the .NET Framework 4.5, SustainedLowLatency mode is available for both workstation and server GC. To turn it on, set the GCSettings.LatencyMode property to GCLatencyMode.SustainedLowLatency.


Server: Your program is the only significant application on the machine and needs the lowest possible latency for GCs.

Workstation: You have a UI or share the machine with other important process