mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Don't try to rebuild a repository graph cache bucket more than once per request
Summary: Ref T2683. This is a small optimization, but it has low complexity: don't rebuild a bucket more than once in the same request, since it will almost always be the same. Bucket rebuilds are pretty cheap, but this saves a few queries. Test Plan: - After discovering (but before parsing) a commit, viewed its browse view. Verified that this patch causes us to perform only one bucket rebuild, and therefore reduces the number of queries we issue. - Parsed the commit and viewed the browse view again, got successful rebuild and then fills from cache. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T2683 Differential Revision: https://secure.phabricator.com/D9055
This commit is contained in:
parent
cfa265f020
commit
84fc8f0baf
1 changed files with 16 additions and 0 deletions
|
@ -55,6 +55,8 @@
|
|||
*/
|
||||
final class PhabricatorRepositoryGraphCache {
|
||||
|
||||
private $rebuiltKeys = array();
|
||||
|
||||
|
||||
/* -( Querying the Graph Cache )------------------------------------------- */
|
||||
|
||||
|
@ -282,6 +284,20 @@ final class PhabricatorRepositoryGraphCache {
|
|||
* @task cache
|
||||
*/
|
||||
private function rebuildBucket($bucket_key, array $current_data) {
|
||||
|
||||
// First, check if we've already rebuilt this bucket. In some cases (like
|
||||
// browsing a repository at some commit) it's common to issue many lookups
|
||||
// against one commit. If that commit has been discovered but not yet
|
||||
// fully imported, we'll repeatedly attempt to rebuild the bucket. If the
|
||||
// first rebuild did not work, subsequent rebuilds are very unlikely to
|
||||
// have any effect. We can just skip the rebuild in these cases.
|
||||
|
||||
if (isset($this->rebuiltKeys[$bucket_key])) {
|
||||
return $current_data;
|
||||
} else {
|
||||
$this->rebuiltKeys[$bucket_key] = true;
|
||||
}
|
||||
|
||||
$bucket_min = ($bucket_key * $this->getBucketSize());
|
||||
$bucket_max = ($bucket_min + $this->getBucketSize()) - 1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue