@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve performance of two recent commit migrations

Summary:
Ref T13216. See PHI959. These two recent migrations can be expressed more efficiently:

- When updating commit audit statuses, the field isn't JSON encoded or anything so we can just issue several bulk UPDATEs.
- When inserting mail keys, we can batch them in groups of 100.

Test Plan: Used `bin/storage upgrade -f --apply phabricator:...` to reapply patches. Saw equivalent behavior and faster runtimes.

Reviewers: amckinley

Reviewed By: amckinley

Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam

Maniphest Tasks: T13216

Differential Revision: https://secure.phabricator.com/D19802

+25 -23
+5 -11
resources/sql/autopatches/20180910.audit.03.status.php
··· 12 12 5 => 'needs-verification', 13 13 ); 14 14 15 - foreach (new LiskMigrationIterator($table) as $commit) { 16 - $status = $commit->getAuditStatus(); 17 - 18 - if (!isset($status_map[$status])) { 19 - continue; 20 - } 21 - 15 + foreach ($status_map as $old_status => $new_status) { 22 16 queryfx( 23 17 $conn, 24 - 'UPDATE %T SET auditStatus = %s WHERE id = %d', 25 - $table->getTableName(), 26 - $status_map[$status], 27 - $commit->getID()); 18 + 'UPDATE %R SET auditStatus = %s WHERE auditStatus = %s', 19 + $table, 20 + $new_status, 21 + $old_status); 28 22 }
+20 -12
resources/sql/autopatches/20180914.audit.01.mailkey.php
··· 8 8 $conn = $properties_table->establishConnection('w'); 9 9 10 10 $iterator = new LiskRawMigrationIterator($commit_conn, $commit_name); 11 - foreach ($iterator as $commit) { 11 + $chunks = new PhutilChunkedIterator($iterator, 100); 12 + foreach ($chunks as $chunk) { 13 + $sql = array(); 14 + foreach ($chunk as $commit) { 15 + $sql[] = qsprintf( 16 + $conn, 17 + '(%s, %s, %d, %d)', 18 + $commit['phid'], 19 + phutil_json_encode( 20 + array( 21 + 'mailKey' => $commit['mailKey'], 22 + )), 23 + PhabricatorTime::getNow(), 24 + PhabricatorTime::getNow()); 25 + } 26 + 12 27 queryfx( 13 28 $conn, 14 - 'INSERT IGNORE INTO %T 29 + 'INSERT IGNORE INTO %R 15 30 (objectPHID, mailProperties, dateCreated, dateModified) 16 - VALUES 17 - (%s, %s, %d, %d)', 18 - $properties_table->getTableName(), 19 - $commit['phid'], 20 - phutil_json_encode( 21 - array( 22 - 'mailKey' => $commit['mailKey'], 23 - )), 24 - PhabricatorTime::getNow(), 25 - PhabricatorTime::getNow()); 31 + VALUES %LQ', 32 + $properties_table, 33 + $sql); 26 34 }