Poor performance fetching Git branches in repo with lots of branches


#1

Observed Behavior:
Pages that show the branches of a commit (e.g. https://secure.phabricator.com/rP28ee6b8080fccb8bd001c694558e67e6bed1e69b ) are very slow to load the branches if there are a lot of branches in the remote repository, even if only “master” is set for tracking.

Expected Behavior:
I believe Phabricator should honour the repository setting for “track only” branches and be passing those to the command in DiffusionBranchQueryConduitAPIMethod.php:
git branch --list --verbose --no-abbrev --contains [ref] [tracking branches separated by spaces].
This vastly improves the performance (tested by running with -r to check remote branches):

$ time git branch -r --list --verbose --no-abbrev --contains cd1164fd9a53a9c674d081b4180e872bafabca8d
... 
origin/master                                           315590e93c3beca0fb65c1927c4fb38a96aea320 ...
git branch -r --list --verbose --no-abbrev --contains   70.96s user 0.02s system 99% cpu 1:11.01 total

$ time git branch -r --list --verbose --no-abbrev --contains cd1164fd9a53a9c674d081b4180e872bafabca8d "origin/master"
origin/master 315590e93c3beca0fb65c1927c4fb38a96aea320 ...
git branch -r --list --verbose --no-abbrev --contains  "origin/master"  0.01s user 0.00s system 98% cpu 0.016 total

There’s a slightly different list returned (as you’d expect) but I’d love to not tie up processes for over a minute on my repository boxes.

Phabricator Version:

phabricator 8ada2bc4fe74423674bce4df0b7f3a144a2c771d (Wed, May 9) (branched from 4a98e0ff65a44a208920f553a935f734726e93b2 on phacility)
arcanist 8794ce1eaca0b3ef020e2cd5d2d5479fd3626b9f (Fri, Apr 27) (branched from a604548101025875de20a9c263df3790fea425b3 on phacility)
phutil f3e10579f640ebad648c56f677164647ab7251a4 (Apr 14 2018) (branched from 20eff1c8d14f08f05ef72828fa379e871d29662c on phacility)```