Why has Flex SDK 4.x.x become sluggish (for some) and how you can get it rolling again
Many developers, who upgraded their Flex SDK from 3.x.x to 4.x.x have noticed this – the compiler speed seems to have deteriorated, the project build time has grown enormously. In fact, for large projects, such as the one I am working on, it has become unbearably sluggish. In spite of the incremental compilation and advertised performance tuning, any subtle change means long project rebuilding. In our case, the complete recompile takes almost twice as long with SDK 4.1 compared to SDK 3.5. The compile time of separate modules has grown exponentially. Most curiously, judging from the reactions on the Internet, this frustrating deterioration does not seem to affect all developers. It all looked very weird and puzzling at first.
After having gone through some detective work, I found the culprit. As part of the build process, Flex seems to run recursively through all source directories, hashmapping and timestamping whatever file is in his way. Which is fine, unless your code is part of a SVN repository: every single directory/package of your project thus contains a .svn subfolder with more subfolders and metadata files. Therefore, if you work on large project with lots of packages, Flex SDK 4.x.x (unlike its 3.x.x predecessor) browses and timestamps huge amount of files which technically do not belong to your code at all. The fact that the .svn directories have the hidden flag on does not help a bit. This explains why only part of the developers have been affected – namely, those working on large, complex projects stored in SVN (or possibly CVS or any system which keeps meta data on per-folder basis).
So – what can be done? How the speed of the Flex compiler can be recovered in the SDK 4.x.x? There are several options, and I ultimately went through all of them (well, almost):
- Migrate to different version control system, such as Git – not feasible in our case, generally not cool
- Use only command-line compiler – it’s speed is not affected. But forget auto-build, background error checks…
- Create mirror directory of your project without the SVN meta data and keep it synchronized – very cumbersome
- Use the HellFire Compiler – solves the problem, but it means additional license cost and also does not work as smoothly as one would wish
- File a bug report at Adobe – and wait forever before they even notice
- Download the Flex SDK source code and repair it by yourself
Slowly, we eliminated the first five solutions, before we arrived at the last one. The whole problem can be solved by adding two lines to the /modules/compiler/src/java/flex2/tools/oem/internal/OEMReport.java source file, more precisely to its storeTimestamps(File path) function:
private void storeTimestamps(File path)
{
// the fix is here:
if(path.isHidden())
return;
// end of the fix
timestamps.put(FileUtil.getCanonicalPath(path), path.lastModified());
for (File file : path.listFiles())
{
if (file.isDirectory())
{
storeTimestamps(file);
}
}
}
Edit and build the source – and you get a freshly baked SDK 4.x.x of your own, with the speed of ol’ good SDK 3.x.x.
As the change seems to affect only one .jar file, you can try to replace directly the <sdk>/lib/flex-compiler-oem.jar with my build (based on SDK 4.1, revision 16076), which can be downloaded here.
Sorry, but Your downloaded jar file doesn’t change the compile time in my Air project. It’s the same: 1 min 20 secs. I’m using 6 included libs, which I compiled separately in about 8 secs before compiling the main project. Any idea?
Gert Matern
January 21, 2011 at 10:59 am
And yes, all are svn connected projects.
Gert Matern
January 21, 2011 at 11:00 am
Hi Gert,
it seems the problem occurs only while building the project internally in Eclipse/Flash Builder. Perhaps you’re running the mxmlc.exe via external tools (such as ant)?
Also, you need to restart Flash Builder, as it loads the necessary jars on startup.
Jiri
tobisek
January 24, 2011 at 11:04 pm
Hi Jiri,
I’m using eclipse helios with the flash-builder plugin and the 4.1.0.16076 sdk without modifikations. For compiles I use the project menu/clean. Build Automatically is disabled… And yes, I restarted eclipse before compiling the project. Maybe the sdk is already doing, what your file tries to force and the problem can’t be solved…
Gert
Gert Matern
February 17, 2011 at 9:51 am
[...] http://yerii.wordpress.com/2010/12/15/why-has-flex-sdk-4-x-x-become-sluggish-for-some-and-how-you-ca… [...]
Flex 4.1 SDK Slow Compile Time « The Mini's View
January 26, 2011 at 2:00 am
Hi Jiri
My Flash Builder seemed to be doing nothing (no CPU usage, no disc access) for minutes at a time while displaying Refreshing Workspace.
This really helped me – thanks – I also added the -CLEAN to Flash Builder and the 2 seem to work well together!
Darrell
February 24, 2011 at 5:33 pm
Thank You!
I can confirm this significantly reduced workspace building time on my current project which uses SVN.
I’m even using an Intel x25 SSD boot disk and it was still slow before.
Flash Builder 4.0.1
SDK 4.1
Evan Gifford
February 25, 2011 at 1:16 pm
I was in the same boat dealing with large projects with an svn client. My compile times were on the order of 2-3 minutes for even the slightest change to code. I downloaded your modifed .jar file and BAM, 5 second compile times now.
Thank you so much for this fix!!
Jason Keele
May 17, 2011 at 7:24 pm
Great find! Is it possible for you to make this change for the Flex 4.5.1 SDK? Or outline how to do it?
Thanks
Yonas
June 21, 2011 at 4:23 pm
Please provide proof for your findings.
Elad Elrom
July 7, 2011 at 2:13 pm
Elad, I don’t really mean to convince anyone… This was a painful issue for our team, I found a solution and want to share it with other developers who might face similar problems. You may try it or not – just download the .jar if you want – I don’t really care. And yes, the File::listFiles() in Java returns (at least under Windows 7) all files, including the hidden ones, so the original code obviously is inefficient for SVN.
Jiri
tobisek
July 7, 2011 at 3:01 pm
[...] 首页文章导航技术项目生活咔嚓!关于Flex GalleryHome › 技术 › 加快 FlashBuilder4 的编译速度加快 FlashBuilder4 的编译速度 Posted on 2011/08/12 by Neal Mi — No Comments ↓ 最近搞一个比较大的Flex分析项目,结果FlashBuilder抗不住了,每次编译都极其慢,然后隔三差五的down掉,于是到处google如何加快速度。然后发现了:http://forums.adobe.com/thread/740967http://bugs.adobe.com/jira/browse/SDK-30367http://yerii.wordpress.com/2010/12/15/why-has-flex-sdk-4-x-x-become-sluggish-for-some-and-how-you-ca…正好项目用的是该死的SVN,然后Flex 4 的 OEM编译器还有这个bug,每次编译都去遍历.svn目录。按照上面yerii博文所述,给出不少解决办法:Migrate to different version control system, such as Git – not feasible in our case, generally not cool – 使用其他版本管理系统,比如Git,Mercuial等Use only command-line compiler – it’s speed is not affected. But forget auto-build, background error checks… – 使用命令行编译器Create mirror directory of your project without the SVN meta data and keep it synchronized – very cumbersome – 通过镜像文件夹分离.svn和源码Use the HellFire Compiler – solves the problem, but it means additional license cost and also does not work as smoothly as one would wish – 使用RPC编译器 HellFire CompilerFile a bug report at Adobe – and wait forever before they even notice – 给Adobe提bug,然后等下去Download the Flex SDK source code and repair it by yourself – 下载sdk源码,自己修改。在项目进行到一半的时候,明显 1,2,3,5的办法都十分不靠谱。于是我试了一下 HellFire Compiler , 不过最后放弃了,因为:收钱,59USD各种其他问题,同样让我崩溃。于是别无选择,只能选择解决办法6。最讽刺的是Flex3的编译器没有这个bug,而且Adobe还声称提升25%的编译器性能。。。解决办法6,同样是博文所述,只需要在 /modules/compiler/src/java/flex2/tools/oem/internal/OEMReport.java 里简单的修改,然后重新编译打包就okay了。</div> <div> <pre>private void storeTimestamps(File path) { // the fix is here: if(path.isHidden()) return; // end of the fix timestamps.put(FileUtil.getCanonicalPath(path), path.lastModified()); for (File file : path.listFiles()) { if (file.isDirectory()) { storeTimestamps(file); } } }</pre> </div> <div>同样地,博主给出了修改后的jar下载链接,可惜是在墙外的dropbox,所以我提供一个墙内的下载地址,flex-compiler-oem.zip下载-解压-替换到{flex-sdk-4.x-home}/lib,我换了之后至少flashbuilder不会有事儿没事儿罢工了,至于编译速度,稍快一点点吧,依然很慢!!!(项目太大了)。 Top Tagged with: Flex, Flex4 Posted in 技术发表评论 取消回复电子邮件地址不会被公开。 必填项已用 * 标注姓名 *电子邮件 *站点评论您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> [...]
加快 FlashBuilder4 的编译速度 | 沉默前行
August 12, 2011 at 9:23 am
Thnx for sharing this, Jiri!
Does anyone has the compiled bugfix for download for SDK 4.51 or is this bug fixed here?
Is this bug solved in SDK 4.5.1? I replaced the jar file with yours but I got an eclipse error
tnx a lot!
Gert Stalpaert (@GertStalpaert)
August 18, 2011 at 8:15 am