One of the primary focuses…

One of the primary focuses of BP 2.0 development has been performance. In this post, I’ll share a few numbers that demonstrate the improvements you can expect in the new version.

For testing, I set up a fresh installation of WP 3.8.1, running Twenty Fourteen and the default widget configuration. Using wp-cli-buddypress, I generated 30,000 members and 60,000 activity items. I toggled between various setups, running the latest BP 1.9.x as well as the latest BP trunk (2.0.x). The tests labeled “APC On” were run using APC with a default config (specifically, APCu on PHP 5.5.10) and the WP APC plugin. In these cases, I also primed the cache with a page refresh. Tests labeled “APC Off” do not have persistent object caching enabled.

What follows are statistics about MySQL (number of queries and the total query time). In many cases, there are corresponding improvements in script execution time and memory footprint, but these latter numbers are so dependent on other environmental features that I’ve decided not to include them here. You should take things like “query time” with a grain of salt; the numbers are useful mainly to visualize relative gains. But it’s worth noting that the improvements in query time will become more significant as sites become larger than the dummy site that these numbers come from.

  1. Baseline
    Here are some numbers with BP deactivated, so you can get a sense of what the default WP installation is doing:

    Home page – BP deactivated – APC Off

    # queries: 30
    query time: 0.005503s


    Home page – BP deactivated – APC On

    # queries: 9
    query time: 0.002269s

  2. Activity
    Several important changes were made to the way that BuddyPress activity is queried, including significant improvements in object caching and splitting the query to avoid costly JOINs. Here are some results of looking at the main Activity directory page, default filters, as a logged-out visitor.

    BP 1.9.2 – APC Off

    # queries: 80
    Query time: 0.111316s


    BP 2.0 – APC Off

    # queries: 59
    Query time: 0.046568s


    BP 1.9.2 – APC On

    # queries: 10
    Query time: 0.002157s


    BP 2.0 – APC On

    # queries: 5
    Query time: 0.001317s

  3. Members
    The efficiency of members queries was another area of intense focus during the 2.0 dev cycle. The way that last_activity data is stored and queried was overhauled, and a large number of improvements were made to userdata caching. The following data is from the 234th page of the Members directory, sorted by Last Active (/members/?upage=234), as seen by a logged-out visitor.

    BP 1.9.2 – APC Off

    # queries: 63
    Query time: 0.197926s


    BP 2.0 – APC Off

    # queries: 39
    Query time: 0.0952112s


    BP 1.9.2 – APC On

    # queries: 17
    Query time: 0.184889s


    BP 2.0 – APC On

    # queries: 10
    Query time: 0.091074s

  4. Logged-in data
    Users who are logged in to a BP site carry a lot of data along with them on every page of the site. Userdata is used to build navigation links, to build the admin bar, to populate the Notifications dropdown, etc. We’ve made an effort to make these queries less redundant and more efficent. Here are some numbers from a home page visit by a logged-in user.

    BP 1.9.2 – APC Off

    # queries: 49
    Query time: 0.010246s


    BP 2.0 – APC Off

    # queries: 45
    Query time: 0.008786s


    BP 1.9.2 – APC On

    # queries: 16
    Query time: 0.0042662


    BP 2.0 – APC On

    # queries: 4
    Query time: 0.0012240

You can see that the improvements are significant. The number of queries per page load in each case has been cut by up to 50%, and query time, on average, has been cut by more than 50%. And remember that these numbers are total values – it’s BP on top of WP’s standard queries. That is to say that the query footprint attributable to BP itself has been reduced by up to 75% in many places.

This is not an exhaustive list of benchmarks, but it’s indicative of improvements you should see across most sections of BP sites after the 2.0 upgrade. The improvements will be especially noticeable on very BP installations. If this isn’t good motivation for you to help with the 2.0 beta, I don’t know what is :)