gpt4 book ai didi

c# - .Net4 中的 GC : Specifying gcServer and gcConcurrent together

转载 作者:可可西里 更新时间:2023-11-01 08:25:57 24 4
gpt4 key购买 nike

我正在调整我们的服务器性能,并尝试指定以下配置,并将 GCLatencyMode 设置为 LowLatency

<startup> 
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
<runtime>
<gcServer enabled="true"/>
<gcConcurrent enabled="false"/>
</runtime>

这提高了我的性能,直到一位同事指出这两个设置在 .Net 4 中是互斥的,我才感到非常高兴。

那么这将解析到什么配置?当然,GCSettings.IsServerGC 返回 true,将 gcConcurrent 设置为 false 会带来非常明显的性能提升。

(我将我正在分析的代码编译成一个测试工具,所以虽然它通常是由 IIS 托管的服务器,但我的所有计时都在控制台应用程序上)

最佳答案

我在这里找到了你的答案: Latency Modes

Default Garbage Collection Modes


If the LatencyMode property is not specified, the default mode is concurrent workstation garbage collection. The mode is dependent on the value of two runtime configuration settings:

<gcConcurrent>

If enabled, this setting specifies that the common language runtime runs workstation garbage collection on a separate thread to support concurrent operations. This setting is enabled by default.

<gcServer>

If enabled, this setting specifies that the common language runtime runs server garbage collection; otherwise, it runs workstation garbage collection. You can enable server garbage collection only on computers with two or more processors. It is not enabled by default. If this setting is enabled, gcConcurrent is automatically disabled.

The default values for GCLatencyMode are as follows:

Interactive when gcConcurrent is enabled and gcServer is disabled.

Batch when gcConcurrent is disabled, or gcServer is enabled.

因此,当启用 gcServer 时,gcConcurrent 会自动禁用。无需将 gcConcurrent 设置为禁用。 GCLatencymode 以批处理模式运行,这说明了性能提升。

关于c# - .Net4 中的 GC : Specifying gcServer and gcConcurrent together,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19998598/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com