1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Speeding up the AVForums menu - some advice needed, please

Discussion in 'XenForo Development Discussions' started by Stuart Wright, Sep 20, 2015.

  1. Stuart Wright

    Stuart Wright Well-Known Member

    Hello folks,
    we have a custom FORUMS menu which allows members to drill down to the forums they want.
    It uses an Ajax load calling the getViewableNodeList function in XenForo_Model_Node.
    It's a little slower than I'd like and I'm wondering whether this is as efficient as it can be for our specific needs?
    I.e. would a custom function speed things up?
    Any advice you could give would be very much appreciated. Thanks.
  2. Stuart Wright

    Stuart Wright Well-Known Member

    Hoping for some advice from an expert like @Chris D ?
  3. Chris D

    Chris D XenForo Developer Staff Member

    Realistically if you want a list of nodes that can be viewed by the current user, taking into account their permissions, with the number of nodes you have, there is going to be some overhead.

    If it's running right now on your site I think this is running quite well.
  4. Stuart Wright

    Stuart Wright Well-Known Member

    Ok, Chris, thank you. That's exactly what we want to do.
    If the current function is not doing anything superfluous to our needs then it's safe to assume it's going to already be as efficient as it can get.
    I guess from here it's a case of removing unwanted forums.
  5. Daniel Hood

    Daniel Hood Well-Known Member

    I wonder how much of a benefit there'd be in caching the results on the first page load and calling at soon as the page is loaded rather than waiting for them to scroll over the menu. So for example, when I first load www.avforums.com, it'll load, then the ajax request will be made to get the menu (since we don't want to slow down the initial page load). Then on every subsequent page load, it would just load from the cache rather than doing the full request again.
    jeffwidman likes this.
  6. Stuart Wright

    Stuart Wright Well-Known Member

    Would that be particularly hard to do, Daniel? Any potential downsides?
  7. Daniel Hood

    Daniel Hood Well-Known Member

    I don't think it'd be difficult to do at all.
    The only downside I can think of is if they get additional access or lose access after they start their session. That can be fixed by deleting the cache for their account every time their permissions change though.
  8. Xon

    Xon Well-Known Member

    Cache by permission combination id rather than user id, and it mostly fixes itself.
  9. Zenexer

    Zenexer Active Member

    It looks like you may have a few things slowing down your site. On your index page, my browser waits on your server for about 1.25 sec. That's quite a bit. The ajax request only waits for about 354 ms, but that's still a lot longer than I'd expect for a request that should have very little overhead. You should run a profiler (e.g., xdebug) to determine which add-ons are the troublemakers, then either optimize them or remove them. In debug mode, XenForo will also show you a breakdown of the database queries used to serve a request, including profiling information. My guess is that you have something making an excessive number of queries. In my tests, such ajax requests normally took between 100 to 200 ms to complete. The index page should never take more than 750 ms--even that's not ideal, but sadly XenForo's index pages aren't nearly as optimized as they could be. Other frequently-visited pages should generally be much faster (roughly 100 ms).

    tl;dr I don't think this particular controller/action is the problem.

Share This Page