Performance and Reflection

Page 1 of 3 123 LastLast
  1. #1

    Performance and Reflection

    Hi guys,

    First of all, you are doing a great job with Coolite. My screen looks like fabuluous !

    I have one screen with TabPanel which contains TextFields, combo, date etc... classic form. I activate Trace.axd in order to see the duration of rendering.

    It seems that event Prerender is time-consuming. Therefore, thanks to Ant Profiler, I figure out that the issue comes from Reflection Method. You use a lot of GetType() GetProperties, GetValue etc.

    Do you consider to migrate to PropertyDescriptor in order to improve performance ?

    In my case, it takes 1,4 second just to render screen. It is a little to heavy

    Thks,

    Jerome
  2. #2

    RE: Performance and Reflection

    Hi Jerome,

    Agreed. At the moment there's some pretty heavy reliance on Reflection and boxing within the Toolkit. Recently we did some profiling with the v0.7 code-base and made a few optimizations. But, there is a lot more we can do to tighten things up. This is going to be a major focus of the final move to v0.7 release and during the v0.8 cycle.

    Some of the Reflection may be unavoidable, but I certainly know of a couple optimizations we can implement that will provide a noticeable speed bump. There's a lot happening during PreRender for us.

    We will also be moving to Json.NET 3.5 once final release occurs, and from what I've read from James Newton-King, he's done some serious profiling and optimizations as well.

    Can you post the .aspx sample you were testing with? Was that 1.4 seconds to 1 to 4 seconds? Is that the server side number? or a number from the client-side? If client-side, are you testing in FireFox with FireBug running? FireBug can have a significant impact on page performance. If it took (up to) 4 seconds (server-side) to generate the script I would really interested to try and reproduce exactly what you are testing with. I have never experienced those kinds of performance numbers, so that would certainly get my attention.

    Geoffrey McGill
    Founder
  3. #3

    RE: Performance and Reflection

    Hi again Geoffrey,

    I tried to zip my project and remove non interesting part. Still, it takes 3 Mo which can't be sent by this forum. How can I send you this file ?

    Meanwhile, please find enclosed a screen capture which points out the delaying of Prerender event.

    Thks,

    Jerome
  4. #4

    RE: Performance and Reflection

    Please feel free to .zip any files and send to support [at] coolite [dot] com.



    Geoffrey McGill
    Founder
  5. #5

    RE: Performance and Reflection

    I am using JetBrains DotTrace profiler and seeing similar results. My page takes less than 1 sec on the server with about 35% of the time in PreRender. The most time consuming functions involve reflection and string manipulation.

    Coolite.Ext.Web.ClientConfig.ToExtConfig(PropertyInfo, Object, ClientConfigAttribute, Object)
         Object System.Reflection.RuntimePropertyInfo.GetValue(Object, Object [])
         Coolite.Ext.Web.ClientConfig.WriteValue(String, Object)
              Coolite.Ext.Web.TokenUtils.ParseTokens(String, Control)
    Hope that helps in optimizing the code.
  6. #6

    RE: Performance and Reflection

    Hi jchau,

    Thanks for the info.

    We spent some time optimizing yesterday and picked off some low hanging fuit.

    One of the bigger tests involved creating 1000 MenuItems. That would be 10 Toolbar Buttons, each with 10 MenuItems, and each MenuItem had 10 sub MenuItems. This is an extreme example and in no way would I recommend adding 1000 menu options to your production application, or at least not on initial Page_Load.

    Results


    Before Optimization (Page_Load)
    
    Begin PreRender            0.0376957825645438      0.000031
    End   PreRender            3.78988251300095        3.752187
    Begin PreRenderComplete    3.78992378919667        0.000041
    End   PreRenderComplete    4.92509927937769        1.135175
    
    ********************************************************
    
    After Optimization (First server request for Page)
    
    Begin PreRender            0.0335534264829748    0.000022
    End PreRender              0.886260544287053    0.852707 <-- 440% improvement
    Begin PreRenderComplete    0.886301680800213    0.000041
    End PreRenderComplete      1.90563458484249    1.019333
    
    After Optimization (Any future request, now caching)
    
    Begin PreRender            0.0089685281229877    0.000018
    End PreRender              0.636710880852175    0.627742 <-- 595% improvement for all future requests
    Begin PreRenderComplete    0.636752995143237    0.000042
    End PreRenderComplete      1.30571846421822    0.668965 <-- 150% improvement for all future requests
    I think we're going to be able to chop those numbers at least in half again. We should be able to work around the .GetValue() Reflection, which will produce a very nice bump.

    No matter what happens, in the end the PreRender and PreRenderComplete events are always going to incorporate the most processing. There's a lot happening in those two events, but we will keep choping away at any performance bottle necks.

    Hope this helps.

    Geoffrey McGill
    Founder
  7. #7

    RE: Performance and Reflection



    I'm glad to hear from you with such news and waiting 0.7 to test improvement.

    Bravo !

    Jerome
  8. #8

    RE: Performance and Reflection

    Impressive gains! Are the changes already in SVN?
  9. #9

    RE: Performance and Reflection

    jchau (11/14/2008) Impressive gains! Are the changes already in SVN?
    Yes, the optimizations have been committed to SVN.

    Here's the Toolbar+Menu sample I was referring to, if you wish to run the test as well. We're working on more optimizations right now and one Menu refinement in particular that will help with this test.

    Example

    <%@ Page Language="C#" Trace="false" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>1000 Menus</title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Ext.IsAjaxRequest)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        ToolbarButton tb = new ToolbarButton("Button" + i.ToString());
                        this.Toolbar1.Items.Add(tb);
                        
                        Coolite.Ext.Web.Menu menu = new Coolite.Ext.Web.Menu();
                        tb.Menu.Add(menu);
    
                        for (int j = 0; j < 10; j++)
                        {
                            Coolite.Ext.Web.MenuItem menuItem = new Coolite.Ext.Web.MenuItem("Item" + j.ToString());
                            menu.Items.Add(menuItem);
                        
                            Coolite.Ext.Web.Menu subMenu = new Coolite.Ext.Web.Menu();
                            menuItem.Menu.Add(subMenu);
    
                            for (int k = 0; k < 10; k++)
                            {
                                Coolite.Ext.Web.MenuItem subMenuItem = new Coolite.Ext.Web.MenuItem("SubItem" + k.ToString());
                                subMenu.Items.Add(subMenuItem);
                            }
                        }
                    }
                }
            }
        </script>
    </head>
    <body style="padding:10px;">
        <form id="form1" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            <ext:Toolbar ID="Toolbar1" runat="server" />
        </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
  10. #10

    RE: Performance and Reflection

    Now that the server side is pretty snappy, any tips for client side optimization? It takes about 1-2 secs for Coolite controls to render on one of my more complex page. The page header image and Telerik menu render first, then 1-2 sec later, the rest of the page shows up. Aside from Coolite client side library, the page also loads ASP.NET AJAX library plus whatever Telerik throws in. This isn't a huge deal since 1-2 sec render time is already fast enough.
Page 1 of 3 123 LastLast

Similar Threads

  1. Performance issues with 0.8.2
    By ywonline in forum 1.x Help
    Replies: 3
    Last Post: Oct 26, 2011, 4:43 PM
  2. [CLOSED] [1.2] IE8 Performance
    By softmachine2011 in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 05, 2011, 12:02 PM
  3. Multiheader + performance
    By Birgit in forum 1.x Help
    Replies: 2
    Last Post: Mar 14, 2011, 3:47 PM
  4. Performance
    By Puia in forum 1.x Help
    Replies: 2
    Last Post: Jul 28, 2009, 10:51 AM
  5. GWT EXT performance
    By jeybonnet in forum Open Discussions
    Replies: 6
    Last Post: Mar 25, 2009, 8:39 AM

Posting Permissions