26 September 2005
Maybe it's not as sexy as alpha video or a drop-shadow filter effect but the improved performance of Macromedia Flash Player 8 is a feature you can immediately benefit from—without doing a thing. One of the biggest contributors to the overall performance boost is the new garbage collection scheme, which improves ActionScript execution while reducing player memory usage.
Additionally, several changes to Flash Player 8 that are specific to the Macintosh platform result in greater parity between Windows and Macintosh performance. With these changes, you could see up to a 50% increase in the overall performance of Flash Player 8 when viewing content and applications.
The new garbage collector in Flash Player 8 is the main driver of performance boosts in ActionScript execution and reduced memory usage. As the size and complexity of Flash applications increased, we were starting to reach the limits of the reference-counting algorithm used for garbage collection in Flash Player 7. By switching from simple reference counting to deferred reference counting, we eliminated over 90% of the reference counting in Flash Player.
The overhead for reference counting in Flash Player 7 was approximately 20% of total execution time, which often resulted in rendering pauses for large applications. The new garbage collector reduces this overhead to only 1–2% of total execution!
Flash Player 8 also uses incremental garbage collection, which breaks up the operations for marking objects for deletion and the actual deletion step so that they can be run whenever there is a free cycle.
Because efficient garbage collection and memory usage are directly related, Flash Player 8 uses approximately 50% less memory than Flash Player 7. The garbage collection method used in Flash Player 7 resulted in almost linear use of memory. By contrast, using incremental garbage collection, the memory usage in Flash Player 8 performed more like a step function as chunks of memory were freed periodically during free cycles (see Figure 1).
Figure 1. Windows memory usage graph during a sample test pass (click to enlarge)
For the same test on Mac OS X, the garbage collection performed slightly differently: Flash Player freed memory mostly at the end (see Figure 2)
Figure 2. Mac OS memory usage graph during a sample test pass (click to enlarge)
As a result of the new garbage collector and lower memory consumption, most of your existing content should experience some improvements in speed when running in Flash Player 8—without any recompiling.
Although the overall performance of your content and applications will improve, the new garbage collector has some performance side-effects for specific areas. Some operations will be faster, while others will be slower when compared to the same operations in Flash Player 7. This is because the underlying infrastructure for supporting memory management has changed. As a result, microbenchmark tests, or small benchmark tests that measure a particular aspect of functionality, cannot really be used for an apples-to-apples comparison between older player versions and Flash Player 8.
For example, let's say you have a microbenchmark test that calculates an equation to exercise some math routines, and you run it five times in a row in the player. In Flash Player 7, it takes 300 milliseconds to calculate. That individual test will also take 300 milliseconds on each subsequent run. With the garbage collection in Flash Player 8, this same microbenchmark test might take 310 milliseconds the first time, 300 milliseconds the next time, and so on. The first time might be slower than in Flash Player 7 but subsequent runs would run faster, resulting in an overall average that is faster than Flash Player 7.
See a set of our sample Flash Player microbenchmark tests and results at the end of this article. The primary goal for performance is to improve overall application performance, not necessarily improve each individual microbenchmark. Microbenchmark tests are useful to us for checking that we aren't setting things back with the changes we make, but the important thing to note is that we have also added reference application benchmarks to our test suite for more complete testing of how overall performance is impacted.
With this release, we focused a significant amount of time and energy on player performance on the Mac to bring greater parity between Windows and Mac OS performance across all aspects, as well as increase stability. One of the big moves was rewriting the Mac plug-in to use the new "Mach-O" OS X runtime architecture, which allows the player to take advantage directly of the new technologies and features of the platform. We also spent a lot of time optimizing the core rendering routines specifically for the Mac.
To improve playback of video and large content and lower CPU usage, Flash Player 8 uses some OpenGL features when run in Safari on Mac OS X 10.2 and above. This is not full support of OpenGL; the player takes advantage of specific features to get bits on the screen faster. Using OpenGL improves video playback and animation, and reduces tearing or horizontal redraw lines.
Similar to the change in garbage collection, this feature improves the overall performance of rendering in Safari; however, in some cases performance may decrease. OpenGL also has some built-in limits and on older, slower systems Mac OS X will cap the frame rate to 30 frames per second. Why is it Safari only? The feature requires the browser to notify the player when a user creates a new tab or switches tabs, and at the time of this release Safari was the only Mac browser capable of supporting this feature.
The following Sample Flash Player Microbenchmark Tests and Results (see Figure 3) are provided as an illustration of the types of performance tests Macromedia runs during the development of the player:
Figure 3. Sample Flash Player microbenchmark tests and results (click to enlarge)
Obviously, this is not a comprehensive list of performance enhancements that affect specific player features. Many changes and optimizations are deep under the surface, such as changing underlying internal data structures to use less memory or using floating-point matrices to improve rendering accuracy. Some enhancements make specific functionality faster, while others might make performance trade-offs in order to support cool new functionality. When taken as a whole, the overall effect of the performance features and optimizations in Flash Player 8 makes for a smoother, faster experience for your content and applications.
To learn more about Flash Player, visit the Flash Player Developer Center.
To learn more about Flash Player 8 features, visit the Flash Player Features page.