Stop Coding!

The Unofficial Flex Compiler Blog

[2010/04/02] Stop Coding! Did you know…

leave a comment »

Stop Coding! Did you know that Flex incremental compiler performance  varies based on what you change in a class? (Of course! What am I smoking!?) In both Flex 3 and 4, when you make a code change in an ActionScript class, the incremental compilation invalidates the build data (CompilationUnit) for the class you touched and all of its subclasses (or boardly speaking, its dependents) and compile them again. However, if your code change does not involve API changes (e.g. additions or deletions of public functions or variables), the build data for the subclasses and dependent classes stay.

Let me use the HFCD output to illustrate this. It takes about 6.7s (CPU time) to do a full, clean compile of framework.swc.

[Fri Apr 02 10:35:38 EDT 2010] compile(framework.swc) result=1 time=6695
[Fri Apr 02 10:35:46 EDT 2010] link(framework.swc) size=2013668 time=483

Then I add a function, doSomethingMeaningless() in The function has an empty body.

public function doSomethingMeaningless():void

Since this is a public function so it definitely changes the public API of The rule says at least all of its subclasses (a lot!) must be invalidated and compiled again in the incremental compilation. Okay, it takes about 4.5s (CPU time) to incrementally compile framework.swc.

[Fri Apr 02 10:36:03 EDT 2010] compile(framework.swc) result=1 time=4463
[Fri Apr 02 10:36:10 EDT 2010] link(framework.swc) size=2013907 time=467

Now, add something to the function, e.g. a trace() statement.

public function doSomethingMeaningless():void
trace("do something meaningless");

Again, UIComponent should be invalidated in the next incremental compilation. However, there is no public API change. All of its subclasses and dependent classes stay. The result? It takes only 1s (CPU time) to incrementally compile.

[Fri Apr 02 10:36:20 EDT 2010] compile(framework.swc) result=1 time=1088
[Fri Apr 02 10:36:21 EDT 2010] link(framework.swc) size=2013972 time=467

Of course, if you add 10,000 lines of code into the function, that’s a different story!

Note that this rule applies to ActionScript classes only. There is no API signature checking for MXML components. Yes, I know it would be nice to have that for MXML components. But it’s a lot more complicated to achieve than doing that for AS classes. Plus, MXML components are rarely deep in some foundation class hierarchies.

So what does this mean to you? Well, this “API signature checking” strategy in incremental compilations should help improve the flow of your daily coding activities if you group your API changes in a single “Save All” and avoid mixing API changes and function body changes. I’d say that this is a “good-to-know”, but don’t plan meticulously a few steps ahead what you want to save. Your brain should focus on coding… 🙂

Now, Start Coding!

Written by Clement Wong

April 2, 2010 at 11:10 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: