Flex 4.5 - to long build process - apache-flex

We are developing an app using flex 4.5. The app runs just fine (no performance issues at all) but it takes us forever to compile and build it. A minor change, like just add a comment or press enter in an mxml file and rebuild takes about 3 minutes. You just cant work that way.
It is a large project with about 1300 files. We also use Parsley as IOC container and a beat of cairngorm navigation. We also use Maven (Flex mojos) but I am talking about a normal eclipse build (Ctrl + B).
We separated some of the code to a different SWC and all of our graphics are stored in a different resource SWF.
Please, Do you have any suggestions?
Regards, Ido

Summary
Turn off auto-build
Close unrelated projects
Remap Ctrl+B
Encapsulate application domains
Turn off auto-build
First thing to do when you install FlashBuilder is turning off the automatic building "feature". The Flex compiler is waaay to slow to constantly build in the background unless you work on very small projects. It's in menu > Project > Build Automatically.
Close unrelated projects
Any open project eats away memory. Close as many as you can.
Remap Ctrl+B
Since you use the Ctrl+B keybinding to launch the build process, you should know that this will actually build your entire workspace. Every single project that is open will be built. When you have a lot of dependencies that's gonna take a whole lot of time.
That's why I remap the Ctrl+B combo to just build the project that I'm currently working on. A small donwside is that sometimes you have to go 'manually' build a few projects, but that's largely outweighed by the time gain.
Go to menu > Window > Preferences. Type "key" in the search box. Click the topic "keys" under "general". Now type "build" in the searchbox on the right. Select "Build Automatically" and click the "Unbind Command" button. The ctrl+B binding should disappear. Now select "Build Project", then select the "Binding" input field (lower left) and hit Ctrl+B. Save and you're done.
Encapsulate application domains
I don't have a single project that is bigger than 200 files (usually even less than 100). Since your project consists of 1300 files I assume that it is does not have one monolithic function. So you should be able to slice it up into separate libraries; preferably one for each application domain. This will allow you to compile sizeable bits of the application and has the added benefit of clearly separating some concerns within your application.

How to fix slow build time when trying to use the debugger on Flash Builder 4.6 Mobile Apps
I ran into the same problem. Here is how you fix it.
It seem when you build a mobile app with a Server Connection like PHP it writes all of the
files on the server Directory..
When it come time to compile the app to debug it packages all of the sitting in the server directory. To fix this issue do the following.
Properties of the project.
Flex Build Packaging
for this example Pick Google Android.
Package Contents.
UnSelect anything that does not belong in your project..
After doing this build time when from 30 minutes to under 10 seconds..

Ok, This is how we fixed it:
We deleted all the dependencies. Then, we added only the necessary ones. You won't believe how many SWC files were just there and never used.
We went through almost every action-script and mxml file, and deleted unnecessary imports (using CTRL+ O on eclipse). This is a lot of work.
We changed the buiders on the project configurations so that only Flex builder remains. There were more builders including Maven. Every builder makes everything slower.
That is it.

Related

Save Opened Files Per Project

I've been using Aptana and it is a great tool for web development. I don't know if I can resort myself going back to Notepad++
Anyway, I have multiple project on Aptana ... I think it is stored in a single workspace. But I switch over to other projects depending on my mood. In each project, I have multiple files opened and it kind of destroys momentum that I have to close the windows of my previous projects and open the files on the projects I want to work on.
My question: Is there a way to save the opened files per project. Like when i switch to Project A, all of the files I opened in project A will open. When I switch to project B, all of the files I opened in Project B is opened?
I decided to play around with "workspaces", and although there isn't a very GUI oriented way of working with these collections yet, I came up with a workable solution!
Create a new folder in your home directory, and just call it "workspaces", then open up Aptana, and choose File -> Switch Workspace -> Other and then type in the path to the new "workspaces" folder, and then the name of the workspace. I have one workspace called "generic" where I pretty much have every project loaded up. Then I have a bunch of workspaces named after the project to which they are committed. No more reluctance to switch tasks in Aptana! No more opening up bits and pieces of projects in Notepad++ or Sublime! Everything is good again!
Now all Aptana really needs to do is make a menu where you can click to select which workspace to use when aptana loads instead of having to remember your-exact_project-name and being able to refresh your memory by looking at all the workspaces you have. Ideally they would impliment a kind of search/filter bar after you start typing your project name, and then a hoverup that say "hit enter to auto complete" since there's no standard practice as to whether tab or enter should be autocomplete, and sometimes making it enter can be anoying cause you just wanted to make a new project called 'ant' not load your engineering project named'antennas'.
Anyway, sorry for the formatting. Hope this helps.

Aptana Studio 3 "Building Workspace" with EXT 4 Library

I have a web project setup in Aptana Studio 3.
I like the IDE, but so far my biggest issue with it is how long it takes for it to "Build the workspace". It seems to take forever to sort through all of the EXTJS 4.x files.
Everytime I rebuild the theme file, it takes at least 30 minutes, and the whole time the IDE can't be used. Or if I update the EXT version, it has to go through it all again.
I am sure I could remove the EXT files from the tree entirely until I put my code on the server, but I don't like for things to be scattered, and I am likely to forget to put it back.
Is there anyway I can have it exclude the EXTJS files from process it goes through?
I have try right clicking on the folder in the tree and "Exclude from Index" but that doesn't seem to work at all (This might not even be used for what I think it is).
When I put a whole new set of library files in, this process has taken up to 2 hours. And even if I stop it, it takes 5 or 6 minutes to actually stop.
I realize that the machine I am working on isn't very powerful, but I think this is a little ridiculous, especially for as often as it happens.
Any advice on this other than "get a more powerful machine" would be greatly appreciated.
If it helps I am running Kubuntu 11.10 32 bit.
I haven't used Aptana but it looks eclipse based. In eclipse, you can tweak you project's 'builder' and 'validation' settings so that 'builders' don't walk through the entire ExtJS tree each time you open the workspace or save a file in the project.
There are obviously downsides to disabling validations but its a trade off. (I had the same issue but on eclipse. I moved ExtJS to a separate eclipse project and disabled all builders)
just disable the javascript validator from the project properties window, this is enough.

FlexBuilder/MXMLC: Profiling the build process?

I've noticed that, recently, builds in FlexBuilder have been taking much, much longer than they used to (30 or 40 seconds, as opposed to 3 or 4). What is the simplest way of profiling these builds to figure out what is taking so much time?
Did you try cleaning your project? ( Project--> Clean )
From the Adobe Live Docs: Performing a clean build
After a project has been built, subsequent builds affect only the resources that have been added
or modified. To force the Flex Builder compiler to rebuild all resources in a project, you can
perform a clean build. You might perform a clean build if, for example, you want to eliminate all
potential sources of a problem you encountered when testing your application.
1. Select Project > Clean from the main menu.
2. Select the project (or projects) whose build files you want to discard and rebuild from scratch.
3. Click OK.
I have found that when Flex Builder reaches a java heap space of, say 500M, the builds slows way down, try restarting Flex Builder whenever that happens. Also, add the heap monitor to the status bar by going to Window->Preferences, type "heap space" in the filter and check the box that says "Show heap status".
I've also found that embeds slows the builds down very much, so does having a lot of stuff in your html-template folder. I suggest moving all embeds to a separate module, like described here.
Evenrything in your html-template folder will get copied to bin-debug during build, so that will be slow too. How to solve this depends on your project, but removing any .svn or .cvs folders from html-template is a start.
FlashBuilder is just an eclipse and eclipse is Java. You can profile eclipse itself with JProfiler. so much for the first question.
To trakc down, waht actually makes the build process so slow is much harder and profiling may not be what you want. Additionally to the adives above, there is also the
-incremental=true
compiler argument.
Make sure your "-Xms" entry equals your "-Xmx" entry.
And there's more than heap. You can also set the -XX:PermSize= and -XXMaxPermSize= parameters wisely. But that would need some understanding of the GC process, as the ratio between heap and permspace is crucial here.
And if you play with these variables, always make sure they are actually used. It happens more than easy to put them somewhere (batch file, exlipse.ini) with them having any effect.

How to shortcut time before data after first hit in browser

We have a couple of large solutions, each with about 40 individual projects (class libraries and nested websites). It takes about 2 minutes to do a full rebuild all.
A couple of specs on the system:
Visual Studio 2005, C#
Primary project is a Web Application Project
40 projects in total (4 Web projects)
We use the internal VS webserver
We extensively use user controls, right down to a user control which contains a textbox
We have a couple of inline web projects that allows us to do partial deployment
About 120 user controls
About 200.000 lines of code (incl. HTML)
We use Source Safe
What I would like to know is how to bring down the time it takes when hitting the site with a browser for the first time. And, I'm not talking about post full deployment - I'm talking about doing a small change in the code, build, refresh browser.
This first hit, takes about 1 minute 15 seconds before data gets back.
To speed things up, I have experimented a little with Ram disks, specifically changing the <compilation> attribute in web.config, setting the tempDirectory to my Ram disk.
This does speed things up a bit. Interestingly though, this totally removed ALL IO access during first hit from the browser.
Remarks
We never do a full compile during development, only partial. For example, the class library being worked on is compiled and then the main site is compiled which then copies the binaries from the class library to the bin directory.
I understand that the asp.net engine needs to parse all the ascx/aspx files after critical files have been changed (bin dir for example) but, what I don't understand is why it needs to do that when only one library dll has been modified.
So, anybody know of a way to either:
Sub segment the solutions to provide faster first hit or fine tune settings in config files or something.
And, again: I'm only talking about development, NOT production deployment, so doing the pre-built compile option is not applicable.
Thanks, Ruvan
Wow, 120 user controls, some of which only contain a single TextBox? This sounds like a lot of code.
When you change a library project, all projects that depend on that library project then need to be recompiled, and also every project that depends on them, etc, all the way up the stack. You know you've only made a 1 line change to a function which doesn't affect all of your user controls, but the compiler doesn't know that.
And as you're probably aware ASPX and ASCX files are only compiled when the web application is first hit.
A possible speed omprovement might be gained by changing your ASCX files into Composite Controls instead, inside another Library Project. These would then be compiled at compile time (if you will) rather than at web application load time.

Any advice for speeding up the compile time in Flex Builder 3?

I run Flex Builder 3 on a mac and as my project grows - the compile time gets longer and longer and longer. I am using some SWC's and there is a fair amount of code but it shouldn't take minutes to build and crash daily should it?
First of all, comments on some of the response:
There is no need to explicitly specify -incremental in Flex Builder because it uses incremental compilation by default.
-keep-generated-actionscript is a performance killer because it instructs the compiler to write out AS3 codes generated for MXML components in the middle of the compilation. File I/O in the middle of a compilation means unnecessary pauses and low CPU utilizations.
-optimize slows down linking because it instructs the linker to produce smaller SWFs. Note that -optimize=true|false doesn't have any effect on building SWCs because SWCs are libraries and have to be unoptimized.
I rarely mess with JVM settings because JVM knows its jobs well and tunes itself quite well at runtime. Most people make matter worse by setting various GC tuning parameters. That said, there are 3 settings most people understand and set correctly for their usage:
-Xmx (max heap size)
-server or -client (HotSpot Server or Client VM)
-XX:+UseSerialGC or -XX:+UseParallelGC (or other non-serial GC)
-server consistently outperforms -client by about 30% when running the Flex compiler.
-XX:+UseParallelGC turns on the parallel garbage collector. ideal for multicore computer and when the computer still has CPU cycles to spare.
You may also want to check out HellFire Compiler Daemon (http://bytecode-workshop.com/). It uses multiple processor cores to compile multiple Flex applications at the same time. You can also run the compiler on a second machine via sockets (assuming that your second machine has faster CPUs and more memory).
In my opinion, use more modules than libraries and use HFCD.
Hope this helps.
-Clement
There's no need to use mxmlc on the command line just to be able to add compiler flags. Right click your project in the Flex Navigator, select Properties and then Flex Compiler in the dialog that appears. There you can add any extra compiler flags.
Not sure that there's very much to do though, more code means more compile time, that's just the way it is. If you're not doing a release build (or whatever it's called in Flex Builder) it's unlikely that your compiler settings include optimize to begin with. Better choices to try would be -incremental (which only recompiles the parts that have changed) and -keep-generated-actionscript (which stops the compiler from deleting the ActionScript files it has generated from your application's MXML files).
I very much prefer using mxmlc on the command line (by way of Ant) compared to Flex Builder. Although I don't think that the latter compiles any slower, it feels more sluggish in every way. Using Ant also makes it possible to do more than just compilation when building, and conditional compilation (only compile a SWF or SWC if the source code has actually changed). Check out a blog post of mine for more info on that.
What you could try is the Flex Compiler Shell, another command line tool that can speed things up. Basically it tries to keep as much as possible in memory between builds, so no need to wait for things like the JVM starting up (the Flex compiler is a Java application). On the other hand this is sort of what Flex Builder does anyway.
In addition to the suggestions already mentioned, close any projects that you have open that you are not using.
Rich click on the Project in the Navigator view and select "Close Unrelated Projects".
Depending on how many projects you have open, this can lead to a significant improvements in compile time, as well as all around performance.
mike chambers
mesh#adobe.com
Slow compile time is most often caused by having large numbers of embedded resources ([Embed] or #Embed).
Option 2 on this article might help you: [http://www.rogue-development.com/blog2/2007/11/slow-flex-builder-compile-and-refresh-solution-modules/]
I created RAM Disk with workspace and it gives up to 10% of better compilation time. Not much, but something.
You want at least 4 gigs on your computer if possible, and make sure to override the default memory settings that eclipse/flexbuilder gives to the application.
If you're not sure how to do this, you can find the flexbuilder app in /Applications, right click and choose "Show Package Contents". Then go into the contents file and edit the eclipse.ini file. Edit that file have memory settings of at least:
-vmargs -Xms768m -Xmx768m -XX:PermSize=128m -XX:MaxPermSize=128m
It's also worthwhile to go into the eclipse/flexbuilder preferences and to check the "Show heap status" box under Windows->Preferences->General (This is in eclipse with the FB plugin, I'm assuming it's also there for standalone FB).
This shows the current memory in the lower right of the window and has a little trash icon so you can force garbage collection.
I'd also suggest turning off automatic building of the project when your files change (you can force a build with cmd-B).
We had a huge project with quite a few modules files and performance in FlexBuilder 3 was decent with these steps.
Go to Project->Properties->Flex Applications. All of the applications listed are compiled each time (even though you have a default set). If you remove everything but the default (don't worry, it won't delete the actual files), it only compiles the default app. This resulted in a significant speed up for me. If you change your default app, it ADDs it to the Flex Applications list - adding to your compile time. You will need to maintain this list to get the quickest compile.
I always disable "automatic compile" for Flex. It compiles too much, takes too long, and so interrupts my work.
If you have many different project files and all of those needs to be recompiled, but you also have other projects open and don't want to close them always you're doing a build, you can also use Eclipse Working Sets.
Unfortunately, the default Flex Navigator does not support working sets. But you can open the Package Explorer with Window / Show View / .... Click on the little white downward arrow to the topright and select Top Level Elements: Working Sets. You can then add Working Sets (aka groups of projects). Each project needs to be in at least one working set ("Other Projects" being the default), but can be in several.
Now with Project / Build Working Set / ... you can instruct Eclipse to build all the projects in this working set, but none of the others. This is especially useful if you suspect your project references to be sometimes broken - otherwise building the 'topmost' project should trigger subsequent builds automatically.
As Clement said, use the HellFire Compiler Daemon. If you have multiple modules and more CPU cores on your machine it can compile them in parallel. Another option is to use IntelliJ (the commercial version) which offers the same feature.
The SDK 4.x.x introduced silly bug (see Adobe bugsystem, issue FB-27440), which causes projects with SVN or CVS meta data compile much slower than with SDK 3.x.x. On how it can be fixed, see here.
You may want to explore the command-line compiler found in the Flex SDK, mxmlc. As I recall, Flex Builder 3 seems to hide all the compiler details, but perhaps there are arguments you can append that will help you speed up the compilation.
For example, you may want to set optimize=false which will skip the step of optimizing the bytecode (perhaps reducing compilation time)? This of course comes at the price of performance and file size of the actual application.
More documentation on mxmlc can be found at: http://livedocs.adobe.com/flex/3/html/compilers_13.html.
Good luck!
I don't use Flex Builder, but I use the Flex SDK compiler everyday and I was wasting tons of time waiting for the MXMLC compiler to do its job until I found Flex Compiler SHell:
http://blog.zarate.tv/2008/12/07/theres-something-called-flex-compiler-shell/
Although in theory Flex Builder already uses this optimizations, might be worth checking.
You can use WORKING SETS to compile just a set of your components that are part of the application that you are changing and not the whole project
http://livedocs.adobe.com/flex/3/html/help.html?content=build_6.html
Usually the first build takes the longest, and then it's pretty quick after that. That's using Vista x64 w/ core 2 duo.
Otherwise, I am nearly certain a Intel Core i7 Extreme Edition 965 3.2GHz upgrade processor would speed your Flex building up nicely .. :) :) :)

Resources