New Apparat Example

Good news everyone. The Apparat inline expansion works now to full extent after fixing some minor bugs. A complete example is also available. Just change the paths in the build.properties file and compile everything using Ant.

Apparat Example

Use the inline feature with care. Apparat does not try to optimize your code and performs nothing but dead simple inlining. This can lead to slower code due to the creation of lots of local registers. Your code gets also much bigger and will require more space in memory. I am actually not a fan of manual inlining at all. I think it makes only sense to inline code if you have a powerful optimizer available that will cleanup the whole mess.

The fun story about this example is that the inlined version is slower using the lastes Flash Player release candidate if you have only 40.000 particles. That is why I increased the number of particles to 80.000 ;). I developed the example using an old standalone player and the inlined version was nearly twice as fast. However when I watched the example in the browser with the latest release candidate the game was completely different. Kudos to Adobe for significantly improving the Flash Player performance!

23 Comments

  1. Posted May 26, 2010 at 9:27 pm | Permalink

    Hmm I have version 10,1,52,14 and on my home PC inline version runs slower(37FPS) then AS3 version(40FPS).
    Adding some input to add/remove particles would allow to test it more extensively.
    About which version of Flash you are speaking about precisely?

  2. Arnoud
    Posted May 26, 2010 at 11:32 pm | Permalink

    Hi Joa,

    You are probably interested in some results on different machines.
    in response to wonder why-er: on the mac i got different results:

    as3: 20 fps (average)
    inline: 31 fps (average)

    i run player 10,1,53,38 (debug version)

    so inlining gave more than 50% performance boost,

    awesome!

    Arnoud

  3. Posted May 27, 2010 at 11:06 am | Permalink

    Decided to add more information just in case

    Win7 IE8 not-debug player 10,1,51,95
    AS3 35fps
    Inline 45fps

    Version where I checked yesterday, today results
    Win7 FireFox 3.6.3 debug player 10,1,52,14
    AS3 17fps
    Inline 30fps

    Interesting that they are different from yesterday, over checked if I have anything else running in other tabs like banners and today there is no such things so I guess yesterdays may have been wrong. Inline version clearly is faster today :)

    Would be cool if you could make some Flash that loads both Inline/AS3 versions, runs them, sends statistic to server with information about OS/Browser/Flash Version and then output it publicly in a way that we could see how they perform on average on different systems :)

  4. ffx
    Posted May 28, 2010 at 1:16 am | Permalink

    Webkit recent, OSX 10.6.3, Flash Player 10.1 rc6 nodebug:

    AS3 30fps
    Inline 40FPS

  5. Posted Jun 4, 2010 at 6:55 pm | Permalink

    Hi,
    I compiled the demo but I have a warning:
    “7z is not present on PATH. Fallback to normal compression.”
    I’ve downloaded 7zX and found the executable 7za in /Contents/Resources/
    I tried to copy all that stuff in the root of apparat, but I still get the warning.

    Should I somehow referenced the 7za file to apparat?

    Romu

  6. Posted Jun 5, 2010 at 2:43 pm | Permalink

    Apparat searches currently only for “7z” and not “7za” on the path. I will fix that for Linux systems.

    And yes: you can reference the 7za file directly by specifying “-Dapparat.7z.path=path to your 7za executable”

  7. Posted Jun 11, 2010 at 5:25 pm | Permalink

    Do you have an API of apparat where I can find information about BitMacro, FastMath, IntMath, etc …

  8. Posted Jun 11, 2010 at 8:30 pm | Permalink

    All classes and methods are fully documented. The macros are also documented on the wiki at apparat.googlecode.com.

  9. daniel
    Posted Jun 13, 2010 at 11:04 pm | Permalink

    How do you use this with flash develop? Anybody got a walkthrough?

  10. Florian Salihovic
    Posted Jun 15, 2010 at 11:40 am | Permalink

    Awesome job! For years you offer “awww”s and “oohhh”s… thanks!

  11. layola
    Posted Jul 2, 2010 at 4:48 am | Permalink

    I guess if use Pixel Bender could be event fast than inline

  12. Echooff3
    Posted Sep 23, 2010 at 10:04 pm | Permalink

    I’ve got 7z compile on OSX and I threw it into /usr/sbin. When I run reducer I still get [WARNING] 7z is not present on PATH. Fallback to normal compression.

    Any Ideas?

  13. Echooff3
    Posted Sep 23, 2010 at 10:46 pm | Permalink

    D’oh! Just figured it out. Renamed 7z back to 7za. :D

  14. Aaron
    Posted Sep 26, 2010 at 11:20 pm | Permalink

    I completed this tutorial to use apparat to build this example: http://webdevotion.be/blog/2010/06/02/how-to-get-up-and-running-with-apparat/

    I was able to generate the two .swf files “example-as3.swf” and “example-apparat.swf” with the following versions of Apparat and Scala:

    Apparat: “apparat-aggregator-1.0.RC6″
    Scala: “scala-2.8.0.final”

    Everything seems to work great during the build process, I even got it working w/Flash Builder and the Eclipse Ant plugin.

    example-as3.swf works fine (slow as heck) but

    example-apparat.swf gives me this error when I run it:

    ReferenceError: Error #1056: Cannot create property domainMemory on flash.system.ApplicationDomain.
    at apparat.memory::Memory$/select()[/home/joa/Development/apparat-release/target/checkout/apparat-ersatz/src/main/as3/apparat/memory/Memory.as:64]
    at ExampleApparat/init()
    at ExampleApparat()

    I tried running tdsi both in the ant script and from the command line with the following arguments (based on what I could gather from the apparat README)

    tdsi -i example-apparat.swf -f true -a true -e true -m true
    tdsi -i example-apparat.swf -f

    No-dice in all cases, running the .swf produces the above exceptions. Any ideas?

  15. Aaron
    Posted Sep 26, 2010 at 11:32 pm | Permalink

    I’m dumb. I used the wrong sdk version. Everything works with 4.1, I get that exception w/3.5.

  16. Zhiz0id
    Posted Nov 22, 2010 at 6:51 pm | Permalink

    Aaron,

    the problem was not in sdk.

    -target-player 10 was optional in 3.5, and must be for apparat compilation.

  17. DDD
    Posted Jun 14, 2011 at 5:37 pm | Permalink

    Hm, i tried to follow the steps from http://webdevotion.be/blog/2010/06/02/how-to-get-up-and-running-with-apparat/ but i get the following error when I run ant to compile example-apparat:

    [tdsi] java.lang.VerifyError: (class: apparat/tools/tdsi/TurboDieselSportInjection$TDSITool, method: run signature: ()V) Incompatible argument to
    function
    [tdsi] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
    [tdsi] at …
    [tdsi] Java Result: -1

  18. srayker
    Posted Jun 22, 2011 at 12:05 pm | Permalink

    Hi Joa,
    I tried steps as in the link http://webdevotion.be/blog/2010/06/02/how-to-get-up-and-running-with-apparat/

    But i get below error,
    Buildfile: D:\workspace\apparatTest\build\build.xml

    BUILD FAILED
    D:\workspace\apparatTest\build\build.xml:52: The following error occurred while executing this line:
    jar:file:/C:/apparat/apparat.jar!/apparat/embedding/ant/antlib.xml:22: typedef A class needed by class apparat.embedding.ant.stripper.StripperTask cannot be found: scala/ScalaObject

    One person in the comments section faced similar issue, but his fix did not solve issue with my trial.
    Below are my path settings,

    FLEX_HOME=C:/Program Files/Adobe/Adobe Flash Builder 4/sdks/4.1.0
    APPARAT_HOME=D:/apparat-ant-example/apparat
    SCALA_HOME=D:/apparat-ant-example/scala-2.8.0.RC3/bin

    Any help is greatly appreciated.

    Thanks,
    srayker

  19. srayker
    Posted Jun 22, 2011 at 1:18 pm | Permalink

    Hi Joa,
    The earlier issue got resolved by removing /bin in scala_home, my err.

    But i get below err now,

    BUILD FAILED
    D:\apparat-ant-example\build\build.xml:64: Unable to execute command
    at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
    ute.java:867)
    at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:481)
    at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:495)
    at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:631)
    at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:672)
    at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:498)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
    a:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
    cutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
    Caused by: java.lang.IllegalArgumentException
    at java.lang.ProcessImpl.(ProcessImpl.java:69)
    at java.lang.ProcessImpl.start(ProcessImpl.java:30)
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
    at java.lang.Runtime.exec(Runtime.java:593)
    at org.apache.tools.ant.taskdefs.Execute$Java13CommandLauncher.exec(Exec
    ute.java:862)
    … 21 more
    Has anyone have come across this?

  20. timudjin
    Posted Aug 4, 2011 at 9:32 pm | Permalink

    Joa, this is an ANT noob question…

    How would one apply a Hidden Gems debug item like “apparat.7z.path” to the build.xml file in this example?

    I’ve tried adding it to the tdsi tag in build.xml:

    and tried adding it as an “” to the exec tag in build.xml.

    I’ve also tried this in Flash Builder 4.5 – Run As > 2 Ant Build, Main tab, Arguments:
    “-Dapparat.7z.path=/Users/tshayakhmetov/Applications/Keka.app/” with no success.

    What am I doing wrong?

  21. Posted Mar 12, 2012 at 6:30 pm | Permalink

    http://webdevotion.be/blog/2010/06/02/how-to-get-up-and-running-with-apparat/

    this link requieres scala 2.8.0, if you getting java errors thats because of scala. GL

  22. Posted Mar 12, 2012 at 6:45 pm | Permalink

    actually aptana using scala 2.8.0.RC7 anyone could share a download link?

  23. Posted Jun 5, 2012 at 11:35 am | Permalink

    Hey. If I didn’t use any apis of apparat, will tsid command will optimize the performance of my app?

7 Trackbacks

  1. […] This post was mentioned on Twitter by Joa Ebert, Little Buddha. Little Buddha said: RT @joa: New Apparat Example http://bit.ly/aVEBKi […]

  2. By Apparat FastMath on Jun 9, 2010 at 7:02 am

    […] FastMath Last week, I Looked into Joa Ebert’s blog post showcasing his new Apparat example. I downloaded the source he provided and set up Scala […]

  3. By taquo (Takuo Suzuki) on Oct 25, 2010 at 11:25 pm

    apparatの例はここにあります。http://blog.joa-ebert.com/2010/05/26/new-apparat-example/ #maxjp

  4. […] to the buildfile, buildr-as3 will download the Apparat framework, give your swf the extra speed via TurboDieselSportInjection and run the apparat reducer to compress your swf. First we need to make an instance of the […]

  5. […] to the buildfile, buildr-as3 will download the Apparat framework, give your swf the extra speed via TurboDieselSportInjection and run the apparat reducer to compress your swf. First we need to make an instance of the […]

  6. […] recently posted a simple example to illustrate the power of his powerfull optimization framework called Apparat. Apparat is a […]

  7. […] Apparat tool suite, written in Scala,provides amongst other incredibly handy things a way to do inlining in AS3. I highly recommend using it for larger projects where code style and performance are important. I […]