@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.

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

+16
+16
src/applications/repository/graphcache/PhabricatorRepositoryGraphCache.php
··· 55 55 */ 56 56 final class PhabricatorRepositoryGraphCache { 57 57 58 + private $rebuiltKeys = array(); 59 + 58 60 59 61 /* -( Querying the Graph Cache )------------------------------------------- */ 60 62 ··· 282 284 * @task cache 283 285 */ 284 286 private function rebuildBucket($bucket_key, array $current_data) { 287 + 288 + // First, check if we've already rebuilt this bucket. In some cases (like 289 + // browsing a repository at some commit) it's common to issue many lookups 290 + // against one commit. If that commit has been discovered but not yet 291 + // fully imported, we'll repeatedly attempt to rebuild the bucket. If the 292 + // first rebuild did not work, subsequent rebuilds are very unlikely to 293 + // have any effect. We can just skip the rebuild in these cases. 294 + 295 + if (isset($this->rebuiltKeys[$bucket_key])) { 296 + return $current_data; 297 + } else { 298 + $this->rebuiltKeys[$bucket_key] = true; 299 + } 300 + 285 301 $bucket_min = ($bucket_key * $this->getBucketSize()); 286 302 $bucket_max = ($bucket_min + $this->getBucketSize()) - 1; 287 303