I fixed a problem in the Trader Desktop Performance console I posted last week: Using the AIR client and the RTMP channel, the message latency started to increase when the application was deactivated (lost focus)… Background: When an AIR application loses focus, the AIR 2 runtime lowers the frame rate of the application to a smaller value to prevent the application from using unnecessary CPU resources if it’s running in the background. Because of the current dependency between frame rate and RTMP message processing, this behavior is not appropriate for our Trader Desktop application when using an RTMP channel, because it would significantly reduce the number of real time messages the application can handle. This would lead to a rapidly growing queue of messages waiting to be processed, and the message latency growing out of control. The fix is to force a higher frame rate on the “deactivate” event of the WindowedApplication.
Click here to download an update of the application including the fix.
Source Code
A number of people also asked for the source code of the application. You can download traderdesktop-projects.zip projects here.
Importing the projects in Flash Builder 4:
- In Flash Builder 4, click File > Import > General > Existing Projects into Workspace.
- Specify traderdesktop-projects as the root directory and click finish.
- Explore the projects: TraderDesktop-lib is the library project where most of the source code lives. TraderDesktopPerfConsole is the project for the AIR version of the console. TraderDesktopWebPerfConsole is the project for the Browser version.
Fast DataGrid
The DataGrid available out-of-the-box in the Flex SDK is a general-purpose component that was built to support a wide variety of use cases and is therefore not specifically optimized to handle a trader desktop price grid with a large amount of real time updates. The good news is that it is easy to optimize the DataGrid for this use case. The basic idea is to disable the DataGrid’s collectionChange event handler and let the itemRenderers watch (and handle) changes to their respective data items: check out the FastDatagrid.as class and the applications item renderers for the details. Also read Tom Sugden’s recent blog post on this topic.
2 Comments
Thanks for posting this Christophe. Your timing is perfect ;)
Another interesting thing to improve performance on the client would be to disable unnecessary Bindings to trigger. Imagin you have 2 views in a ViewStack both subscribed to different high-traffic end-points.
Although one of the views is always hidden Bindings keep executing. You could disable unnecessary Bindings as explained here http://www.rialvalue.com/blog/2010/05/05/disabling-bindings-on-certain-views-to-avoid-unnecessary-processing-time/
2 Trackbacks
[...] Direct Link [...]
[...] infrastructure. Modifying the application to get the stock updates from a server is easy: use this application as an [...]