RednaxelaFX对《Pro .NET Performance》的笔记(3)

RednaxelaFX
RednaxelaFX (Script Ahead, Code Behind)

读过 Pro .NET Performance

Pro .NET Performance
  • 书名: Pro .NET Performance
  • 作者: Sasha Goldshtein/Dima Zurbalev/Ido Flatow
  • 副标题: Optimize Your C# Applications
  • 页数: 372
  • 出版社: Apress
  • 出版年: 2012-9-12
  • 第103页 Suspending Threads for GC

    这段文字只提到了GC(或CLR的其它组件)需要暂停线程时,需要被暂停的线程运行到“safe point”。 MSDN的文档也有提到这点:http://msdn.microsoft.com/en-us/library/678ysw69.aspx 问题是,CLR的各版本里“safe point”到底在哪里? Jeffrey Richter在这篇文章(http://msdn.microsoft.com/en-us/magazine/bb985011.aspx)和《CLR via C#》里提到了hijacking,也提到了safe point,但对后者的描述太模糊。 (话说《CLR via C#》第4版的第580页提到了hijacking,然后说在Chapter 21有讲解,但翻到Chapter 21却没有相关内容。删除了?) 从需要用劫持返回地址(return address hijacking)来实现线程暂停的方式来看,CLRv2的safe point似乎只在函数返回处。 这篇文章对JIT在什么情况下生成Fully Interruptible Code的描述有点意思。 http://www.csharphelp.com/2006/03/c-thread-concepts/ 这篇也先mark下 http://debuggingblog.com/wp/2009/07/07/windbg-extension-sos-in-clr-40net-framework-40-ctp-net-runtime-dll-renamed-and-sos-commands-just-got-richer/ 而Sasha说CLRv4解决了time-to-safepoint问题,看来是在任意循环的末尾都变成safepoint了。 可惜现在没机器来在Windows上跑实验来验证这些了⋯ (当然要留意的是.NET的CLR跟.NET CF的CLR实现细节各种不一样不能混在一起讨论。所以不能拿介绍.NET CF的资料套在这里说。)

    2014-03-26 14:20:45 2人喜欢 回应
  • 第105页 Pausing Threads during the Sweep Phase
    During the sweep phase, not only do references change, but objects move around in memory. This poses a new set of problems for application threads executing concurrently. Among these problems: • Copying an object is not an atomic operation. This means that after part of the object has been copied, the original is still being modified by the application. • Updating references to the object is not an atomic operation. This means that some parts of the application might be using the old object reference and some other parts might be using the new one. Addressing these problems is possible (Azul Pauseless GC for JVM, http://www.azulsystems.com/zing/pgc, is one example), but has not been done in the CLR GC. It is simpler to declare that the sweep phase does not support application threads executing concurrently with the garbage collector.
    引自 Pausing Threads during the Sweep Phase

    哈哈这里居然提到了敝厂的Zing,荣幸荣幸 >_<

    2014-03-26 14:39:16 回应
  • 第277页 JIT Compiler Optimizations

    终于讲到JIT编译器了。Sasha这本书提到的细节还挺多的。

    [.NET Framework Debugging Control] GenerateTrackingInfo=1 AllowOptimize=0
    引自 JIT Compiler Optimizations

    俺以前都不知道可以在ini配置文件里把CLR的JIT优化关掉。

    2014-03-26 14:56:08 回应