English 中文(简体)
如何减少在GC中花费的时间
原标题:How to reduce time spent in GC

I m 创立一个桌面应用程序,其运行可达到几秒。 显然,有必要尽量减少这一行动的时间。 这一行动非常容易地平行(个别的次任务),每个次任务在一只透视线上需要大约50万次。 由于在GC中花费了40-50%的时间,每个子公司要花4-5倍的时间才能有效取消速度。

因此,我需要让理事会减少工作。 我的第一项想法是试图找到哪一类物品收集得最多的是垃圾,但我认识到,尽管我经常记得情况,但我从未像这样寻找过这种方式。 通常看一看蒸.,或看管线之间的差别,但显示的是活着的物体,而不是这些射线之间制造和处置的物体。 因此,这是我的第一个问题:最容易找到哪类建筑和收集的垃圾? 我试图寻找方法点,看看某些建筑商是否经常被可疑,但以数百万计制造的所有物体只是小块建筑。 如果我正确理解情况的话,这些都不应对GC产生影响?

该算法产生了数十万个个人结果点目标。 当然,由于这些是行动的产出,因此这些是 t。 但是,这给我带来了第二个问题:在GC中花费的时间主要取决于物体总数还是主要取决于实际收集的物体的数量? 我是否应该试图限制结果物体的数量,而是使用较少但更大的结果物体?

Edit: I found the time spent in GC by using the VS 2010 concurrency visualizer. Also, in the parallel piece of code most sections of blocked threads were waiting for gc

Edit(以英语发言):我应当澄清,业绩问题在于,执行情况实际上在GC工作站上连续进行。 例如,见该员额所述业绩问题。

我可以不谈一下阻碍我read子的垃圾收集器(我认为我不想让服务器上台,正确吗?) 因此,为了加快这一行动,我需要减少援引GC的次数。 大部分时间被浪费,实际上被其他read所阻断,等待着一个read子去做GC。

问题回答

个人而言,如果你的任务只需要50万头才能执行,那么read子制造的间接费用就会比你的实际工作需要更多的时间,你似乎看到了这些时间。 因此,你可能无法走得太远。

关于了解其中的内容,我使用的最佳工具是ANTS简介(理论和业绩)。 你们可以从那里看到物体的记忆,以及时间点和“处决次数”之间的差别,这些差异应当使你们知道。

或许,你应当研究一下在你的目标之间增加点击。

因此,你不是要创建新的要点,而是在清单/数字中进行计算,而是试图分配固定的点数,然后不断重新使用点数。 这样,你就只能一次分配物体,进行计算,然后回去。 如果你能够完全重新利用阵列,你将获益于热切,你将不遭受任何GC。

These result point objects. As in the standard struct Point? Can t say from here, but have you tried pre-allocating the space for them. Most of your GC calls could be allocating memory to them, that s a lot of effort, doing them in larger blocks, or even in one go if the amount can be calculated should give you a boost.

Another option might be trundling in to unsafe code, given you can gain that permission on the workstation. Don t know hoe you have your points layed out, but might be some future in just allocating a block of memory and then ripping through it with pointer arithmetic.





相关问题
Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How do I compare two decimals to 10 decimal places?

I m using decimal type (.net), and I want to see if two numbers are equal. But I only want to be accurate to 10 decimal places. For example take these three numbers. I want them all to be equal. 0....

Exception practices when creating a SynchronizationContext?

I m creating an STA version of the SynchronizationContext for use in Windows Workflow 4.0. I m wondering what to do about exceptions when Post-ing callbacks. The SynchronizationContext can be used ...

Show running instance in single instance application

I am building an application with C#. I managed to turn this into a single instance application by checking if the same process is already running. Process[] pname = Process.GetProcessesByName("...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签