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 ...
随机推荐
- 为何gpio_to_irq不能静态使用?【转】
之前在调试传感器模块的时候发现,在结构体声明的时候irq成员使用gpio_to_irq会报错,而动态使用的话就没有问题.就对gpio_to_irq为什么不能静态使用产生了疑问.恰巧最近又有朋友遇到了同 ...
- Java中获取包含变量的配置文件config.properties内容
应用场景 有些时候项目中会用到很多路径,并且很可能多个路径在同一个根目录下,那为了方便配置的修改,达到只修改根目录即可达到一改全改的效果,此时就会想到要是有变量就好了: 另外有时候路径中的文件名是不确 ...
- pyqt5-组件
组件(widgets)是构建一个应用的基础模块.PyQt5有广泛的各式各样的组件,包含:复选按钮(QCheckBox),切换按钮(ToggleButton),滑块条(QSlider),进度条(Prog ...
- norbert-构建服务器集群感知的 Java 应用程序
http://www.ibm.com/developerworks/cn/java/j-zookeeper/index.html
- 【LOJ】#2526. 「HAOI2018」苹果树
题解 这计数题多水啊我怎么调了那么久啊 我不想老年化啊QAQ (注意这里的二叉树带标号) 考虑\(g[i]\)表示\(i\)个点二叉树所有节点的深度和,\(f[i]\)表示\(i\)个点的二叉树两两节 ...
- Going Home
题意:n个人,进n个房子,每走一格花费1美元,每个房子只能进一人,求所有人进房子的最小花费. 就是推箱子 箱子最短行走距离 这题无法用bfs做 ! 用最小花费最大流 通过EK,Dinic,ISAP ...
- 前馈神经网络练习:使用tensorflow进行葡萄酒种类识别
数据处理 样本数据描述 样本数据集是double类型的178 * 14矩阵,第一列表示酒所属类别,后面13列分别表示当前样本的13个属性: 1) Alcohol 2) Malic acid 3) As ...
- Java中public、protected、default和private的区别
public: 具有最大的访问权限,可以访问任何一个在classpath下的类.接口.异常等.它往往用于对外的情况,也就是对象或类对外的一种接口的形式. protected: 主要的作用就是用来保护子 ...
- 011.Zabbix的拓扑创建
一 Map简介 Map的作用是将各种设备用网络拓扑图的方式展示,在Zabbix中,拓扑的展示通过手动方式添加. 二 Map的添加 2.1 添加Map的背景图 #在添加Map之前可谓Map添加一个背景图 ...
- 005.SMB之user级别配置
一 配置文件修改 注意: 1 share级别权限访问即,无需要用户名和密码才能访问. 2 新版samba4已取消share级别,可默认采用user级别. 1.1 全局配置文件修改 [global] w ...