Announcement

Collapse
No announcement yet.

Aspx page load time

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Aspx page load time

    Moving from Asp to Asp.Net and I am experiencing long load times for my pages. Obviously, the first load takes extra time while the page is being compiled, and then all subsequent accesses to the page are quick as expected. However, if I wait a while (say an hour) and access the page, the compile delay occurs again.

    There has been a lot of discussion on the board about aspx page load delays, but I've not seen anything describing the issue I'm seeing.

    Below is the code for one of my pages. On my system, load time for this page during compile is 6 seconds while a refresh is under 1 sec.

    PHP Code:
    <!-- LogNote.aspx mfisher04Jan2009 -->

    <%@ 
    Page language="vb" %>

    <
    script runat="server">
        
    Dim hs As Scheduler.hsapplication
        Dim LogDisplay 
    As String
        Sub Page_Load
    (ByVal Sender As ObjectByVal E As EventArgs)
            
    ' for use with the HS web server
            hs = Context.Items("Content")
            If hs Is Nothing Then
                ' 
    maybe running under IIS
                hs 
    = Global.ASP.global_asax.hs
                
    If hs Is Nothing Then
                    Response
    .Write("Could not get access to HomeSeer object, is HomeSeer running?")
                
    End If
            
    End If
            
    Dim LogBuffer() As String
            Dim LogItems
    () As String
            LogBuffer 
    Split(hs.LogGet(), vbCrLf)

            
    Dim i As Integer
            LogDisplay 
    "<table border=""1"">" vbCrLf
            LogDisplay 
    &= "<td><b>Time</b></td><td><b>Class</b></td><td><b>Entry</b></td>" vbCrLf
            
    For = (UBound(LogBuffer) - 20To (UBound(LogBuffer) - 1)
                
    LogItems Split(LogBuffer(i), "~!~")
                
    LogDisplay &= "<tr><td>" '& Ubound(LogItems) & ": "
                LogDisplay &= LogItems(0) & "</td><td>"
                LogDisplay &= LogItems(1) & "</td><td>"
                LogDisplay &= LogItems(2) & "</td></tr>" & vbCrLf
            Next
            LogDisplay &= "</table>" & vbCrLf

            Dim Command As String = StripCrLf(Request.Form.Item("Buttons"))
            Dim LogClass As String = Request.Form.Item("LogClass")
            Dim LogNote As String = Request.Form.Item("LogNote")
            Select Case Command
                Case "Save"
                    If (LogClass <> "") Or (LogNote <> "") Then
                        hs.WriteLog(LogClass, LogNote)
                    End If
            End Select

            Response.Write(hs.GetPageHeader("Log Note", "", "", False, False, Nothing, Nothing, Nothing))
            Response.Write("<br><hr>")
        End Sub

        Function StripCrLf(ByVal Cmd As String) As String
            If InStr(Cmd, vbCrLf) Then
                StripCrLf = Left(Cmd, Len(Cmd) - 2)
            Else
                StripCrLf = Cmd
            End If
        End Function

    </script>


    <form name="lognote" method="post" action="LogNote.aspx">
        <h5>Create an entry in the HomeSeer log.</h5>
        Class:
        <input class="formtext" type="text" size="20" name="LogClass" value=""/>
        &nbsp;&nbsp;&nbsp;&nbsp;
        Entry:
        <input class="formtext" type="text" size="60" name="LogNote" value=""/>
        &nbsp;&nbsp;&nbsp;&nbsp;
        <input class="button" type="submit" name="Buttons" value="Save"/>
    </form>

    <%
        Response.Write("<hr><font size=""30""><b>Last 20 log entries:</b></font><br><br>")
        Response.Write(LogDisplay)
        Response.Write(hs.GetPageFooter())
    %> 
    Any thoughts?
    Last edited by mfisher; January 8th, 2009, 10:42 AM.
    Best regards,
    -Mark-

    If you're not out on the edge, you're taking up too much room!
    Interested in 3D maps? Check out my company site: Solid Terrain Modeling

  • #2
    We see that where I work as well. The first load takes a while to compile, subsequent pages are quick, then the process starts over. I think it has to be something with .NET garbage collection and marking some objects as read for GC. I am wondering if there is a Web.config or machine.config setting that will prevent that from happening - havent found the magic bullet yet, tho...
    HS3Pro Running on a Raspberry Pi3
    64 Z-Wave Nodes, 168 Events, 280 Devices
    UPB modules via OMNI plugin/panel
    Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
    HSTouch Clients: 3 Android, 1 Joggler

    Comment


    • #3
      try searching for: Jon00 aspx page loader
      tenholde

      Comment


      • #4
        tenholde,

        Thanks for the suggestion. I had a quick look at Jon00's aspx loader page and it appears that it just loads pages at HS startup so that they are precompiled and 'ready to go' when someone access later. (Please correct me if I'm wrong.)

        The problem that I'm experiencing is if the aspx page is not accessed for a while (say 10 minutes) then it has to be recompiled before being rendered. Note that during this time the HS server is mostly sitting idle and not being restarted or changed.

        The page I listed at the beginning of this thread takes about 8 seconds to serve on the first request and under 1 sec on subsequent requests (within 10 minutes of one another.) I enabled the 'trace' feature in the page and found that it takes only 0.34 seconds to render - every time, precomp or not, so I am assuming that the 7.7 second delay is being caused by precompilation.

        I see from my research that aspx pages served using IIS are compiled, the intermediated code is saved to HDD and then the page is rendered. When another request for that page is made, the ASP engine looks for and uses the precompiled code; making the serve time short.

        With the HS ASP server, I do not see that the precompiled code is saved to HDD, so I must assume that it's being held in memory.

        This leads me to ask:
        1) how does the HS ASP engine determine when it's time to discard the precompiled code?
        2) is the pre-comp code just held in memory or saved to HDD?
        3) can the HS ASP engine be forced to 'save it longer'? (maybe using ASP directives?)

        Any insight as to how the HS ASP engine is handling this would be most appreciated!
        Best regards,
        -Mark-

        If you're not out on the edge, you're taking up too much room!
        Interested in 3D maps? Check out my company site: Solid Terrain Modeling

        Comment


        • #5
          I am not an expert but I did manage to create an ASPx page where only the pre-compiled code was placed on the webserver and thus conceptually eliminating the "delay". I can't give you any scientific proof but it is worth your googling it to see.
          James

          Running HS 3 on Win10 .

          Comment


          • #6
            I'm no expert either but Homeseer does seem to store compiled aspx in memory and is lost when the Garbage Collector kicks in. When this happens is normally when memory is getting low.

            As for my aspx loader, you can run it as a recurring event and does no harm if already compiled in memory.
            Jon

            Comment


            • #7
              jasv, thanks for the pre-compiled suggestion.

              Jon00, thank you for your comments. I tend to agree that it's the GC. However, this machine has 1GB of ram and normally runs around 450mb total phy mem usage.
              Best regards,
              -Mark-

              If you're not out on the edge, you're taking up too much room!
              Interested in 3D maps? Check out my company site: Solid Terrain Modeling

              Comment


              • #8
                As a test, I created a virtual directory in IIS and pointed it to the \Homeseer 2\Html directory.

                When I initially run the same ASPX page (from the exact same location as the HS webserver runs it) the initial compile is about 2 secs. After that, all loads of the page are about 200mS - even several days later.

                In addition, I see that the compiled code is now saved in the \Windows\Microsoft.NET\Framework\v2.0.50737\..... directory.

                So, it does appear that the HS-ASP engine is not cachine the compiled code to storage, but just holding it in memory. Then the .Net Garbage Collector is "cleaning it out of memory" within a few minutes.

                Can anyone at HS-Tech confirm this?
                If indeed this is the case, is precompilation the only solution?
                Best regards,
                -Mark-

                If you're not out on the edge, you're taking up too much room!
                Interested in 3D maps? Check out my company site: Solid Terrain Modeling

                Comment


                • #9
                  As HST do not have the time to monitor all threads on the board, I would submit a help-desk ticket on this with a feature request that compiled pages are stored on the hard drive.
                  Jon

                  Comment


                  • #10
                    Was a solution ever found for this issue? I am experiencing a similar delay with the HS web server, and wondered if you were assisted by HomeSeer.

                    Also, how would I use "pre-compiled" code on the web server? What tool or format do I need to use to compile my aspx pages?

                    Thanks!

                    Comment


                    • #11
                      I do not believe anything more has been done. When you first call a aspx, it is compiled on-the-fly in to memory. Provided this is done and memory is not regained by the NET garbage collector, all future page loads should be faster.

                      One workaround solution is to use my aspx page loader (on my site) which will pre-load your pages (i.e. pre-compiled in memory) so that they are ready to go when you want them.
                      Jon

                      Comment


                      • #12
                        I wonder if there is a way to catch the event of garbage collection, and fire off your aspx page loader right after that.

                        I know some people are using blades garbage collection plug-in that basically forces GC at certain times. I would think that action would be undesirable as it could happen while you're using a web page, and I'm not sure if .NET would be smart enough to know that it should only clean up stuff that's really old, and leave alone things that are only a few minutes old.

                        I think most people will agree that this few second delay is quite annoying. Jon's aspx loader does fix this, just seems to be a round about way of dealing with the underlying problem.
                        Joe (zimmer62)

                        BLSecurtiy, AC-RF2, RCS Serial Thermostats, RFXCOM SMarthome SwitchLinc, mcsXap, Global Cache GC100, SqueezeBox, TWA_ONKYOINTEGRA, BLLogMonitor, BLPlugins, BLRadar, BLSpeech, BLZLog.aspx, HSTouch (Windows, iPhone, iPod), USB Mimo touchscreens, VMWare Server, Vortexbox, Windows Home Server, MyMovies, Windows Media Center, X10, ZWave, and much much much more.

                        Comment


                        • #13
                          Originally posted by zimmer62 View Post
                          I wonder if there is a way to catch the event of garbage collection, and fire off your aspx page loader right after that.
                          I have a similar solution to BLGarbage call Memory Flush. This also resets the Garbage Collector and recovers memory used by Homeseer. Because it is a script, you can call both memory flush and ASPX page loader via a single event. The only thing you have to remember is to set the wait for the script to finish for the first one. I actually have a 5 second delay added between the two, just for safety.

                          I've received several good comments about memory flush - here is one from my guest book: ....BTW, I used your "garbage collector" script and Wow, no more HS2 reboots. What a difference it made. Thank you for all of your help
                          Jon

                          Comment

                          Working...
                          X