Friday, January 29, 2010

Flex Builder Error: "Unable to export SWC oem"

Solution: Right click on project, select Properties > Flex Library Build Path > Assets. Uncheck the root node and check it again, then compile project. The error is gone.

I found the solution here:

Friday, January 15, 2010

Performance Optimization for Embedded Systems

Some key points:
  • Load code and data as much as possible into internal memory (L1 cache);
  • Use compiler or linker options to optimize for code size can sometimes give better performance than optimize for performance (GreenHills has a very nice tool to help find the optimum compromise between optimize for speed and size). Major points for manipulation:
    • Optimize for speed
    • Optimize for size
    • Remove unused functions
    • Remove debug information
    • Enable code cache
  • Carefully tune the use of code cache and data cache. Performance difference between fine tuned layout and the default can be 10 time or more;
  • Use integer, fixed point over float over double. If floating point computation is necessary, but double is not needed, then remember that all the constants MUST explicitly declared as floating precision, otherwise there may be a lot of double computation and float to double conversions. For example, instead of x=2.0; should use x=2.0f;
  • Bit shift is faster than add (usually), add is faster than multiply (usually), multiply is faster than divide. So the following tricks usually are helpful:
    • Use left shift and right shift instead of multi and div by 2, 4, 8, 16, 32, ... (integer only);
    • Use add instead of multi 2, 3;
    • If a number is used as divider many times, pre-calculate it's inverse, and use multiply for the calculations;
  • Blackfin (DSP architecture specific): assign data to A/B bank properly to enable parallel data retrieval;
  • Profiler is your friend: use profiler to find the biggest consumer and focus on them;
  • In C++ world: avoid deep hierarchy, because those practices take precious memory space which in turn have grave impact on performance;
  • Be careful when you use C runtime. Call to "printf" can easily add 1k memory footprint;

Thursday, January 14, 2010

"var scope" for CFC Function Variables

Why is it good practice to always "var-scope" every CFC function variable?
  • Make it clear that the variables are only visible within the function;
  • Using "var-scope" actually can help improve performance. I tried the test here, and am personally convinced that "var-scope" has significant positive impact on performance;
  • If you "var-scope" every CFC function local variables, then it will be obvious when you have typo in your code. Because you can use tool like "varScoper" to scan your file, if there are complains, you either forget to "var-scope" a variable, or you've got a typo that "varScoper" just helped you to catch;