• Register
    • Help

    striker  0 Items
    Currently Supporting
    • Home
    • News
    • Forum
    • Wiki
    • Support
      • Manage Subscriptions
      • FAQ
      • Support For
        • VaultWiki 4.x Series
        • VaultWiki.org Site
    • What's New?
    • Buy Now
    • Manual
    • 
    • Support
    • VaultWiki 4.x Series
    • Bug
    • Permissions Calculations are Slow

    1. Welcome to VaultWiki.org, home of the wiki add-on for vBulletin and XenForo!

      VaultWiki allows your existing forum users to collaborate on creating and managing a site's content pages. VaultWiki is a fully-featured and fully-supported wiki solution for vBulletin and XenForo.

      The VaultWiki Team encourages you to join our community of forum administrators and check out VaultWiki for yourself.

    Issue: Permissions Calculations are Slow

    • Issue Tools
      • View Changes
    1. issueid=3785 June 10, 2014 3:49 PM
      pegasus pegasus is offline
      VaultWiki Team
      Permissions Calculations are Slow

      Took a bit of investigating to find where the slow-down was on most pages, but there ended up being around 50-60ms on some pages just to build simple area bits. This seemed like a lot of time for a small block on the page. It turned out, that a majority of the time (about 70%) was spent just calculating permissions for the areas, which led me to wonder, why permissions calculations were so slow.

      Well, there wasn't really any design flaw that accounted for this. A lot of the time was accounted for because of nested loops, method calls within those loops, and repetitive merges. But all of this is actually necessary to make custom permissions cascade in an expected way.

      A very small bit of optimization was had by making sure the same permissions weren't calculated more than once (~0.1ms). It turned out that by breaking 1 nested loop into 3 almost identical nested loops could further reduce the time by eliminating some unneeded default values that needed to be merged later (~3ms). Another ~3ms was saved by doing the unthinkable and increasing duplicate code within the loops, rather than using separate methods. And another ~3ms was saved by replacing a recursive method with nested loops (the maximum number of recursions was known). However, this all only brought us down to 45-55ms (1.6ms per permission lookup, down from 2ms), which was not really an acceptable range.

      So after a little more refactoring, I decided to cache the output of the calculations for each user for each node by storing the final result in the database. The result was that permission calculation time was reduced by a factor of ~10, and times were reduced accordingly (~15-25ms on the tested code segment where permissions were needed).

      This has the most noticeable benefit for guest users, because the initial calculation may never be applied for any given guest.

      For this to work correctly though, the cache needs to be erased when:
      - a user changes member groups (erase cache for that user)
      - an area is re-parented (erase cache for that area's before and after childlists)
      - masks for a user are changed (erase cache for that user)
      - permissions are updated for guests (erase cache for guests)
      - permissions are updated for any users (erase cache for all users)
    Issue Details
    Issue Number 3785
    Issue Type Bug
    Project VaultWiki 4.x Series
    Category Performance
    Status Fixed
    Priority 5 - Minor Bugs / Small Tweaks
    Affected Version 4.0.0 Gamma 6
    Fixed Version 4.0.0 Gamma 7
    Milestone VaultWiki 4 Gamma X
    Software DependencyAny
    License TypePaid
    Users able to reproduce bug 0
    Users unable to reproduce bug 0
    Attachments 0
    Assigned Users (none)
    Tags (none)




    1. June 10, 2014 6:35 PM
      pegasus pegasus is offline
      VaultWiki Team
      Fixed in the next release.
      Reply Reply  
    + Reply

    Assigned Users
    Loading Please Wait
    Tags
    Loading Please Wait
    • Contact Us
    • License Agreement
    • Privacy
    • Terms
    • Top
    All times are GMT -4. The time now is 11:18 PM.
    This site uses cookies to help personalize content, to tailor your experience, and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Learn more… Accept Remind me later
  • striker
    Powered by vBulletin® Version 4.2.5 Beta 2
    Copyright © 2025 vBulletin Solutions Inc. All rights reserved.
    Search Engine Optimisation provided by DragonByte SEO (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
    Copyright © 2008 - 2024 VaultWiki Team, Cracked Egg Studios, LLC.