Titan Network

More Titan Projects => ParagonWiki => Feedback => Topic started by: Blondeshell on July 03, 2012, 07:23:22 PM

Title: Page Loading Timeouts
Post by: Blondeshell on July 03, 2012, 07:23:22 PM
I know that some large pages can take a few seconds to load, either for viewing or editing, but I'm having difficulty getting the Store-Bought Enhancements page (http://paragonwiki.com/wiki/Store-Bought_Enhancements) to load at all.  I get various errors like these:

Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/cohtitan.com/wiki/public_html/w/includes/parser/Parser.php on line 3528
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/cohtitan.com/wiki/public_html/w/includes/parser/Preprocessor_DOM.php on line 1099
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/cohtitan.com/wiki/public_html/w/extensions/ParserFunctions/Expr.php on line 223
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/cohtitan.com/wiki/public_html/w/includes/parser/Preprocessor_DOM.php on line 882

...and so on.

Does anyone else have any problems getting that page to load? Is it possibly related to switching to SemanticWiki instead of DPL?  For reference, I'm using IE8 and I've restarted the browser and cleared my cache.
Title: Re: Page Loading Timeouts
Post by: Cannonfodder on July 03, 2012, 09:19:26 PM
Not just you.

Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/cohtitan.com/wiki/public_html/w/includes/parser/Preprocessor_DOM.php on line 998
Title: Re: Page Loading Timeouts
Post by: eabrace on July 03, 2012, 09:36:00 PM
Yep.  I appear to be having issues trying to load that one, too.

Code: [Select]
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/cohtitan.com/wiki/public_html/w/includes/parser/Preprocessor_DOM.php on line 905
If I pick the page apart in Edit mode, I can display everything up through the max level 40 sets, but somewhere in the middle of loading up the max level 50 sets is where it goes sour.
Title: Re: Page Loading Timeouts
Post by: Sekoia on July 04, 2012, 03:28:03 PM
I just disabled SMW temporarily and the page still isn't loading, so it isn't SMW's fault. I also tried disabling Labeled Section Transclusion and it wasn't its fault either. I then tried disabling DPL and ParserFunctions, and neither of them let it work either.

Unfortunately, my area is afflicted with major power outages so my only internet at the moment is via a limited, slow cell tether, so I can't look into this further at the moment. If nobody else finds a solution, I can probably investigate further this weekend. (They expect to have power mostly restored by Friday night.)
Title: Re: Page Loading Timeouts
Post by: Blondeshell on July 04, 2012, 05:00:30 PM
Thanks for checking into it, sir.  Sorry to hear you've been one of the many without power this week.
Title: Re: Page Loading Timeouts
Post by: eabrace on July 04, 2012, 06:17:56 PM
I'm going to attempt something which I do not expect to work.  But it just might be crazy enough...
Title: Re: Page Loading Timeouts
Post by: eabrace on July 04, 2012, 06:45:41 PM
... nope.  Didn't work.

I tried creating subpages for each of the "Max Level X" sections and transcluding them, hoping that it would count each transclusion as a separate page load.  It does not, so it still times out.

However, that did give me another idea.  I've created subpages for each of the sections to allow people to continue accessing the information until we can find a solution to the timeout.  I've also added an EdNote to the page to let everyone know what's going on.
Title: Re: Page Loading Timeouts
Post by: Sekoia on July 05, 2012, 12:56:38 PM
I tried the following:
- Restarted Apache
- Restarted MySQL
- Temporarily disabled every extension except Titan Authentication
- Temporarily simplified constants in PP2EUR and PP2GBP
- Split off documentation in various templates used so that pre-parsed template transclusion was smaller
- Tried manually replacing {{Table End}} with |} in the article's text
- Optimized all database tables and verified that none needed to be repaired

None of that worked. I do notice however that the wiki seems to be running fairly slowly, and continued to run slowly regardless of what I tried.

I could perhaps raise the script limit from 30 seconds, but that seems unwise. We really shouldn't have pages that take 30 seconds or more to run. Something changed that made this stop working and I don't think it was the article itself. Unfortunately, I'm at a loss for what it might be.
Title: Re: Page Loading Timeouts
Post by: Blondeshell on July 17, 2012, 05:52:04 PM
I think I might have a clue as to what is causing these pages to load and save slowly.

While adding the market sale items for this week, I put "N/A" as the sale parameter for the Bats Aura, and got a whole host of error messages:

(https://paragonwiki.com/w/images//b/b1/Decimal-error.jpg)

Upon digging into it, I realized those errors didn't have anything to do with the currency conversion templates themselves, but rather with the Decimals Template (http://paragonwiki.com/wiki/Template:Decimals). Is it possible that the pages are slow becaue they have to churn through all of the #if checks for each currency value? Is there anything that can be done to simplify the rounding process and maybe speed things up?
Title: Re: Page Loading Timeouts
Post by: eabrace on July 17, 2012, 06:03:08 PM
Holy cow, that's hard to read.  I made it a little more readable.

Code: [Select]
{{#ifexpr: {{{2}}}<=0
  | {{#expr:{{{1}}} round {{{2}}}}}
  | {{#expr:{{{1}}} round {{#ifexpr: {{{2}}}>12
    |12
    |{{{2}}}
    }}
  }}
  {{#ifexpr: ({{{2}}}>=1) and (({{{1}}} round 0)=({{{1}}} round {{{2}}}))
    |.0
    |
  }}
  {{#ifexpr: ({{{2}}}>=2) and (({{{1}}} round 1)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=3) and (({{{1}}} round 2)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=4) and (({{{1}}} round 3)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=5) and (({{{1}}} round 4)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=6) and (({{{1}}} round 5)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=7) and (({{{1}}} round 6)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=8) and (({{{1}}} round 7)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=9) and (({{{1}}} round 8)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=10) and (({{{1}}} round 9)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=11) and (({{{1}}} round 10)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
  {{#ifexpr: ({{{2}}}>=12) and (({{{1}}} round 11)=({{{1}}} round {{{2}}}))
    |0
    |
  }}
}}

My gut says that there should be a way to optimize all of those "#ifexpr: ({{{2}}}>=" statements.

Edit:  Are those only counting out the number of decimals we want to round to?  If so, do we really need to go beyond 2?  Does the template ever get parsed beyond 2 to begin with?
Title: Re: Page Loading Timeouts
Post by: eabrace on July 17, 2012, 06:43:41 PM
I have something to try out, but it'll take me a few to finish typing it all out and then remove the extra whitespace...
Title: Re: Page Loading Timeouts
Post by: eabrace on July 17, 2012, 06:50:26 PM
Code: [Select]
{{#ifexpr: {{{2}}}<=0
  | {{#expr:{{{1}}} round {{{2}}}}}
  | {{#expr:{{{1}}} round {{#ifexpr: {{{2}}}>12
    |12
    |{{{2}}}
    }}
  }}
  {{#ifexpr: ({{{2}}}>=1)
    {{#ifexpr: (({{{1}}} round 0)=({{{1}}} round {{{2}}}))
      |.0
      |
    }}
    {{#ifexpr: ({{{2}}}>=2)
      {{#ifexpr: (({{{1}}} round 1)=({{{1}}} round {{{2}}}))
        |0
        |
      }}
      {{#ifexpr: ({{{2}}}>=3)
        {{#ifexpr: (({{{1}}} round 2)=({{{1}}} round {{{2}}}))
          |0
          |
        }}
        {{#ifexpr: ({{{2}}}>=4)
          {{#ifexpr: (({{{1}}} round 3)=({{{1}}} round {{{2}}}))
            |0
            |
          }}
          {{#ifexpr: ({{{2}}}>=5)
            {{#ifexpr: (({{{1}}} round 4)=({{{1}}} round {{{2}}}))
              |0
              |
            }}
            {{#ifexpr: ({{{2}}}>=6)
              {{#ifexpr: (({{{1}}} round 5)=({{{1}}} round {{{2}}}))
                |0
                |
              }}
              {{#ifexpr: ({{{2}}}>=7)
                {{#ifexpr: (({{{1}}} round 6)=({{{1}}} round {{{2}}}))
                  |0
                  |
                }}
                {{#ifexpr: ({{{2}}}>=8)
                  {{#ifexpr: (({{{1}}} round 7)=({{{1}}} round {{{2}}}))
                    |0
                    |
                  }}
                  {{#ifexpr: ({{{2}}}>=9)
                    {{#ifexpr: (({{{1}}} round 8)=({{{1}}} round {{{2}}}))
                      |0
                      |
                    }}
                    {{#ifexpr: ({{{2}}}>=10)
                      {{#ifexpr: (({{{1}}} round 9)=({{{1}}} round {{{2}}}))
                        |0
                        |
                      }}
                      {{#ifexpr: ({{{2}}}>=11)
                        {{#ifexpr: (({{{1}}} round 10)=({{{1}}} round {{{2}}}))
                          |0
                          |
                        }}
                        {{#ifexpr: ({{{2}}}>=12)
                          {{#ifexpr: (({{{1}}} round 11)=({{{1}}} round {{{2}}}))
                            |0
                            |
                          }}
                        }}
                      }}
                    }}
                  }}
                }}
              }}
            }}
          }}
        }}
      }}
    }}
  }}
}}
Hopefully, this will stop plowing through the #ifexpr: statements on the third check (">=3").  That's a whole lot fewer checks than having to indiscriminately plowing through all 12 every time.

Edit:  There are pipes ('|') missing after each >= check above.  I added them all (I think) when I modified the template.
Title: Re: Page Loading Timeouts
Post by: Sekoia on July 17, 2012, 07:06:08 PM
I just installed the NumberFormat (http://www.mediawiki.org/wiki/Extension:NumberFormat) extension which gives a parser function that does this. It's much more efficient to do this kind of thing in PHP directly than in complicated templates. Hopefully that'll help.

Edit: That now lets Store-Bought Enhancements page (http://paragonwiki.com/wiki/Store-Bought_Enhancements) load properly so I restored it to the full listing.
Title: Re: Page Loading Timeouts
Post by: Blondeshell on July 17, 2012, 07:28:25 PM
It looks like that was the culprit. The regular Paragon Market and /Sales pages also load faster now.
Title: Re: Page Loading Timeouts
Post by: eabrace on July 17, 2012, 07:56:22 PM
Had to run to a training class for an hour right after I made the change.  Realized as I was sitting there I missed a few pipes

{{#ifexpr: <expression>|<true>|<false>}}

But hey, I'll take an OBE win.  :)