This module introduces a significant performance issue.

This is detailed in the port of this module into pathauto proper:
https://www.drupal.org/node/936222#comment-9847907

We can easily provide this as a patch for this module until that patch gets in.

Comments

amoebanath’s picture

StatusFileSize
new2.93 KB

Ported patch pathauto-persists-936222-281_0 from the linked issue for the pathauto_entity_load and pathauto_entity_state_load_multiple functions.

amoebanath’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: performance_issue-2476393-1.patch, failed testing.

amoebanath’s picture

Status: Needs work » Needs review
StatusFileSize
new2.71 KB

Corrected function names & tweaked Drupal static usage.

Status: Needs review » Needs work

The last submitted patch, 4: performance_issue-2476393-4.patch, failed testing.

amoebanath’s picture

Status: Needs work » Needs review
StatusFileSize
new2.94 KB

I missed the drupal_static_reset out!

sebastien m.’s picture

No news ?

dave reid’s picture

Status: Needs review » Needs work
  1. +++ b/pathauto_persist.module
    @@ -4,9 +4,29 @@
    +    $path_auto_entity_types = db_query("SELECT entity_type FROM {pathauto_persist} GROUP BY entity_type")->fetchAllKeyed(0, 0);
    

    Shouldn't this just be SELECT DISTINCT entity_type instead of using a GROUP BY?

  2. +++ b/pathauto_persist.module
    @@ -4,9 +4,29 @@
    +      if (!isset($entities[$id]->path) || !is_array($entities[$id]->path)) {
    +        $entities[$id]->path = array();
    +      }
    

    This is handled by https://www.drupal.org/node/2107365 and not related to performance.

  3. +++ b/pathauto_persist.module
    @@ -63,7 +83,35 @@ function pathauto_persist_entity_state_load($entity_type, $entity_id) {
    +  if (!$table_exists) {
    +    if (!defined('MAINTENANCE_MODE')) {
    +      $message = t('The <code>pathauto_state

    table does not exist, so a default value was provided. Please make sure to run update.php');
    + drupal_set_message($message, 'warning');
    + watchdog('pathauto', $message, array(), WATCHDOG_WARNING);
    + }
    + $result = array();
    + foreach ($entity_ids as $id) {
    + $result[$id] = FALSE;
    + }
    +
    + return $result;
    + }

    This is not relevant for pathauto_persist.

dave reid’s picture

+++ b/pathauto_persist.module
@@ -63,7 +83,35 @@ function pathauto_persist_entity_state_load($entity_type, $entity_id) {
+  // Filter out entity_ids that are not integers.
+  $entity_ids = array_filter($entity_ids, 'is_numeric');
+  // If everything was filtered out, return an empty array.
+  if (empty($entity_ids)) {
+    return array();
+  }

This should be left out too.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new0 bytes

Updated with all the un-relevant sections removed.

dave reid’s picture

StatusFileSize
new1.08 KB

Try that again, I had staged everything but didn't use git diff --cached.

Status: Needs review » Needs work

The last submitted patch, 11: 2476393-fix-entity-load-performance.patch, failed testing.

dave reid’s picture

Status: Needs work » Needs review
StatusFileSize
new1.14 KB

Turns out drupal_static_reset() doesn't like using a query result as the default parameter. Need to set separately.

dave reid’s picture

Status: Needs review » Fixed

Committed #14 to 7.x-1.x.

  • Dave Reid committed 3820a1f on 7.x-1.x
    Issue #2476393 by Dave Reid, amoebanath: Improved performance by...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.