• <legend id='0mctu'><style id='0mctu'><dir id='0mctu'><q id='0mctu'></q></dir></style></legend>

        <tfoot id='0mctu'></tfoot>

          <bdo id='0mctu'></bdo><ul id='0mctu'></ul>

        <small id='0mctu'></small><noframes id='0mctu'>

      1. <i id='0mctu'><tr id='0mctu'><dt id='0mctu'><q id='0mctu'><span id='0mctu'><b id='0mctu'><form id='0mctu'><ins id='0mctu'></ins><ul id='0mctu'></ul><sub id='0mctu'></sub></form><legend id='0mctu'></legend><bdo id='0mctu'><pre id='0mctu'><center id='0mctu'></center></pre></bdo></b><th id='0mctu'></th></span></q></dt></tr></i><div id='0mctu'><tfoot id='0mctu'></tfoot><dl id='0mctu'><fieldset id='0mctu'></fieldset></dl></div>
      2. 我们应该使用“工作站"吗?垃圾收集或“服务器";垃圾收集?

        时间:2023-09-13

        <small id='nSf4I'></small><noframes id='nSf4I'>

        <legend id='nSf4I'><style id='nSf4I'><dir id='nSf4I'><q id='nSf4I'></q></dir></style></legend>

            • <bdo id='nSf4I'></bdo><ul id='nSf4I'></ul>

                <i id='nSf4I'><tr id='nSf4I'><dt id='nSf4I'><q id='nSf4I'><span id='nSf4I'><b id='nSf4I'><form id='nSf4I'><ins id='nSf4I'></ins><ul id='nSf4I'></ul><sub id='nSf4I'></sub></form><legend id='nSf4I'></legend><bdo id='nSf4I'><pre id='nSf4I'><center id='nSf4I'></center></pre></bdo></b><th id='nSf4I'></th></span></q></dt></tr></i><div id='nSf4I'><tfoot id='nSf4I'></tfoot><dl id='nSf4I'><fieldset id='nSf4I'></fieldset></dl></div>

                  <tbody id='nSf4I'></tbody>
                1. <tfoot id='nSf4I'></tfoot>
                2. 本文介绍了我们应该使用“工作站"吗?垃圾收集或“服务器";垃圾收集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个大型多线程 C# 应用程序在多核 4 路服务器上运行.目前我们正在使用服务器模式".垃圾收集.但是测试表明,工作站模式 GC 更快.

                  I have a large multi-threaded C# application running on a multi-core 4-way server. Currently we're using "server mode" garbage collection. However testing has shown that workstation mode GC is quicker.

                  MSDN 说:

                  使用服务器 API 的托管代码应用程序从使用服务器优化的垃圾收集器 (GC) 而非默认工作站 GC 获得显着优势.

                  Managed code applications that use the server API receive significant benefits from using the server-optimized garbage collector (GC) instead of the default workstation GC.

                  工作站是默认的 GC 模式,也是单处理器计算机上唯一可用的模式.Workstation GC 托管在控制台和 Windows 窗体应用程序中.它与正在运行的程序同时执行完整(第 2 代)收集,从而最大限度地减少延迟.此模式对于客户端应用程序很有用,在这些应用程序中,感知性能通常比原始吞吐量更重要.

                  Workstation is the default GC mode and the only one available on single-processor computers. Workstation GC is hosted in console and Windows Forms applications. It performs full (generation 2) collections concurrently with the running program, thereby minimizing latency. This mode is useful for client applications, where perceived performance is usually more important than raw throughput.

                  服务器 GC 仅在多处理器计算机上可用.它为每个处理器创建一个单独的托管堆和线程,并并行执行集合.在收集期间,所有托管线程都被暂停(运行本机代码的线程仅在本机调用返回时才暂停).这样,服务器 GC 模式可以最大化吞吐量(每秒的请求数),并随着处理器数量的增加而提高性能.性能在配备四个或更多处理器的计算机上尤为突出.

                  The server GC is available only on multiprocessor computers. It creates a separate managed heap and thread for each processor and performs collections in parallel. During collection, all managed threads are paused (threads running native code are paused only when the native call returns). In this way, the server GC mode maximizes throughput (the number of requests per second) and improves performance as the number of processors increases. Performance especially shines on computers with four or more processors.

                  但我们没有看到性能大放异彩!!!!有人有什么建议吗?

                  But we're not seeing performance shine!!!! Has anyone got any advice?

                  推荐答案

                  解释的不是很好,但据我所知,服务器模式是每核同步的,而工作站模式是异步的.

                  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.

                  服务器模式适用于每个作业"相对较短且由单个内核处理的应用程序(想想多线程 Web 服务器).这个想法是每个工作"都获得所有的 cpu 能力,并很快完成,但有时核心会停止处理请求并清理内存.所以在这种情况下,希望 GC 平均效率更高,但核心在运行时不可用,因此应用程序需要能够适应这种情况.

                  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.

                  但这只是事后证明.衡量您的系统性能(正如 ammoQ 所说,不是您的 GC 性能,而是您的应用程序的表现)并使用您衡量的最佳指标.

                  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 中处理我的对象? 下一篇:我可以(并且我曾经想要)在.net 中设置最大堆大小吗?

                  相关文章

                  <small id='A0qhB'></small><noframes id='A0qhB'>

                    1. <tfoot id='A0qhB'></tfoot>

                      <legend id='A0qhB'><style id='A0qhB'><dir id='A0qhB'><q id='A0qhB'></q></dir></style></legend>
                      <i id='A0qhB'><tr id='A0qhB'><dt id='A0qhB'><q id='A0qhB'><span id='A0qhB'><b id='A0qhB'><form id='A0qhB'><ins id='A0qhB'></ins><ul id='A0qhB'></ul><sub id='A0qhB'></sub></form><legend id='A0qhB'></legend><bdo id='A0qhB'><pre id='A0qhB'><center id='A0qhB'></center></pre></bdo></b><th id='A0qhB'></th></span></q></dt></tr></i><div id='A0qhB'><tfoot id='A0qhB'></tfoot><dl id='A0qhB'><fieldset id='A0qhB'></fieldset></dl></div>
                        <bdo id='A0qhB'></bdo><ul id='A0qhB'></ul>