Skip to:
Content

bbPress.org


Ignore:
Timestamp:
06/14/2017 06:45:49 PM (8 years ago)
Author:
johnjamesjacoby
Message:

Performance: Last pass at 2.6 performance tuning.

  • Keep a local cache of non-options that aren't in the database, to avoid multiple database misses for options we know aren't in the database after wp_load_alloptions() is called
  • Stop getting all favorite IDs and subscription IDs when checking if a user has favorited or subscribed to something, because these queries are expensive joins that are difficult to cache & invalidate
  • Consolidate forum/topic favorites & subscriptions logic back into central routers, to make it easier to handle taxonomy term subscriptions in the future, and remove nested filter calls that make the call-stack confusing
  • Informally deprecate some forum & topic specific fav/sub functions
  • Rename one of the engagements remove functions to better match existing naming pattern
  • Typo fixes & general code quality improvements
  • Bump slow tests threshold up to 500 for now, and we can bring back down later (my 12" MacBook runs this pretty slowly, so I'd like to play with this more)
  • Unit tests are all passing, and more quickly, maybe surprisingly

This should result in around 20 fewer database hits on non-persistent-cache sites, on average. When viewing single topics & replies, this will result in more than 25 fewer database hits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/topics/functions.php

    r6534 r6544  
    23812381
    23822382/**
    2383  * Remove a deleted topic from all users' favorites
     2383 * Remove a deleted topic from all user favorites
    23842384 *
    23852385 * @since 2.0.0 bbPress (r2652)
     
    24142414
    24152415/**
    2416  * Remove a deleted topic from all users' subscriptions
     2416 * Remove a deleted topic from all user subscriptions
    24172417 *
    24182418 * @since 2.0.0 bbPress (r2652)
     
    24312431    }
    24322432
     2433    // Bail if no topic
    24332434    $topic_id = bbp_get_topic_id( $topic_id );
    2434 
    2435     // Bail if no topic
    24362435    if ( empty( $topic_id ) ) {
    24372436        return;
    24382437    }
    24392438
    2440     // Get users
    2441     $users = (array) bbp_get_topic_subscribers( $topic_id );
    2442 
    2443     // Users exist
    2444     if ( ! empty( $users ) ) {
    2445 
    2446         // Loop through users
    2447         foreach ( $users as $user ) {
    2448 
    2449             // Remove each user
    2450             bbp_remove_user_subscription( $user, $topic_id );
    2451         }
    2452     }
     2439    // Remove all users
     2440    return bbp_remove_object_from_all_users( $topic_id, '_bbp_subscription', 'post' );
    24532441}
    24542442
Note: See TracChangeset for help on using the changeset viewer.