Delphi XE2 compiler performance
原文: http://blog.barrkel.com/2011/10/delphi-xe2-compiler-performance.html
Delphi XE2 compiler performance
Delphi XE2 introduced namespaces across the runtime library. This stressed unit name lookup inside the compiler, and led to some severe performance regressions in certain cases. So during the runup to the XE2 release, I fired up a profiler and started investigating. It turns out there were numerous situations where lookups were being performed repeatedly with the same arguments, and logically the results should have been consistent across these repeated calls. A relatively cheap and easy fix seemed to be memoization. So I added a caching infrastructure to the compiler and used the profiler to guide me where to inject it.
For the most part - particularly for full builds - the cache works really well. But I've had some reports of bugs that I suspected were caused by the cache hanging on to function results slightly too long, and upon investigation, this turned out to be true. The problem with caches is usually in invalidation; if you don't invalidate the cache soon enough and in all required situations, you end up serving stale results. So there are a few bugs lurking in the Delphi compiler here, which I'm seeking out and squashing.
Some good news, however; I had anticipated that this might be the case, so I added a super secret switch that enables diagnosing a probable cache failure: caches can be selectively disabled, and if a problem goes away with the cache disabled, it's probably because of stale results.
Caches can be disabled by setting an environment variable:
DCC_CACHE_DISABLE='SearchUnitNameInNS,FileSystem,UnitFindByAlias,GetUnitOf'
The above environment variable setting disables all the compiler's caches. By including fewer than the four separate cache names, the problem can iteratively be narrowed down to a specific cache.
I've just been fixing one bug caused by the cache that brought home how needed it is. The project is large; almost 2 million lines. An initial build with the cache enabled takes about a minute on my machine; the bug exhibits itself in later incremental compiles when modifying the source code and pressing F9, producing spurious errors. However, once I disabled the cache (or rather, I recompiled the compiler with cache sanity checking enabled, which still filled out the cache, but also invoked the underlying logic, and simply compared the results to verify the cache), the build time took nearly 3 hours!
Note: invalidation is most likely to be a problem on incremental compiles, rather than full rebuilds, especially from within the IDE. The reason is that the compiler may have lots of stale data for one half of an incremental compile that it later decides is out of date (e.g. a dependency changed); this can leave a bunch of stale entries in the cache for all the memoized function calls that occurred in the first half of the compile. The cache is strictly per-compile; it keeps no data across multiple compilations, even partial compilations.
Delphi XE2 compiler performance的更多相关文章
- Delphi XE2有什么新功能
具体内容见PDF Delphi XE2有什么新功能Delphi XE2提供(offers)了令人兴奋(exciting)的新功能,让您能够建立高度可视化的,在Windows,Mac和iOS上的业务应用 ...
- Delphi XE2及以后的版本编译后的程序大小问题
说说Delphi XE2及以后的版本编译后的程序大小问题. 其实最终得到的程序并不大,由于编译器的变化,XE2里Debug版程序比Release版程序大很多,要减小程序体积,就使用Release版.下 ...
- 恢复Delphi XE2的Library Path
Delphi XE2好好的,手贱乱删,结果新建一个工程都不能编译了,出现:DELPHI X2 [DCC Fatal Error] KjcxClient.dpr(1): F1027 Unit not f ...
- 问题-delphi XE2 Stack Overflow- save your work and restart CodeGear
问题现象:某一天,启动DLEPHI XE2 后,新建一个工程,双击一个事件,“Stack Overflow- save your work and restart CodeGear delphi xe ...
- Delphi XE2 升级项目编译ralease版本,无法添加UAC解决方法
我今天把一个原来是Delphi2007的工程升级到了Delphi XE2,在编译ralease版本时候,发现无法添加UAC,我觉得可能是升级的原因,随后我用XE2新建了一个工程,但是在编译raleas ...
- 关于Delphi XE2的FMX的一点点研究之消息篇
Delphi XE2出来了一阵子了,里面比较抢眼的东西,除了VCLStyle这个换肤的东西之外,另外最让人眼亮的应该是FMX这个东西了.万一的博客上都连载了一票的关于FMX的使用心得了.我还是没咋去关 ...
- Delphi.XE2破解方法
我安装的是Delphi.XE2.RTM.v16.0.4256.43595.Lite.v5.0 ,安装完后打开显示是15天试用. 退出XE2后把C:\Program Files\Embarcadero\ ...
- Delphi XE2 编译ralease版本,无法添加UAC解决方法
我今天把一个原来是Delphi2007的工程升级到了Delphi XE2,在编译ralease版本时候,发现无法添加UAC,我觉得可能是升级的原因,随后我用XE2新建了一个工程,但是在编译raleas ...
- Delphi XE2 新增 System.Zip 单元,压缩和解压缩文件
Delphi XE2 新增 System.Zip 单元, 可用一句话压缩整个文件夹了 单元内主要就是 TZipFile 类, 最方便使用的是它的类方法: TZipFile.ExtractZipFile ...
随机推荐
- springcloud配置详解
Spring Boot的配置参考Spring Boot系列文章,这里只对Spring Cloud用到的配置解释. spring.application.name:配置应用名称,在注册中心中显示的服务注 ...
- 基于Apache在本地配置多个虚拟主机站点
简单的说,打开httpd.conf 在最后加入如下内容: <VirtualHost 127.0.0.2:80> DocumentRoot d:/AppServ/www2 Ser ...
- linux:查询软件是否安装以及删除
参考网址:http://blog.sina.com.cn/s/blog_6d59e57d0102x21u.html 查询java是否安装 rpm -qa |grep java 批量卸载所有带有Java ...
- Android SO文件的兼容和适配
开发Android应用时,有时候Java层的编码不能满足实现需求,就需要到C/C++实现后生成SO文件,再用System.loadLibrary()加载进行调用,这里成为JNI层的实现.常见的场景如: ...
- C#, CLR, and .NET Framework versions
- MyEclipse、IDEA常用快捷键
一.MyEclipse快捷键 1. ctrl+shift+r:打开资源这可能是所有快捷键组合中最省时间的了.这组快捷键可以让你打开你的工作区中任何一个文件,而你只需要按下文件名或mask名中的前几个字 ...
- 【LOJ】#2080. 「JSOI2016」病毒感染
题解 那个限制表示一回头要治完前面的所有病人 我们处理一个g[i][j]表示治疗i到j的病人至少会死多少病人 \(g[i][j] = g[i + 1][j] + sum[i + 1,j] + min( ...
- 如何快速的打开当前文件夹的dos命令窗口
一.常规方法: 1.使用 “window + R” 组合键,输入cmd回车.如下图所示: 2.如果你要定位到指定的文件夹,那么需要用cd等命令来处理.如下图所示: 二.快速方法: 按住“shift”键 ...
- 发送统计邮件shell脚本
#!/bin/bash#作者:Presley#时间:2018.07.16#监控阿里云aaa库的py_weixin_product_close_rating_info 和 py_weixin_produ ...
- sed匹配多行替换
sed -i '/aaa/{:a;n;s/123/xyz/g;/eee/!ba}' yourfile 如题:aaa123123123123123eee怎么匹配aaa~eee(开始结束字符串确定),然后 ...