Banzai - batching up reference resolution
During https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22070 I became painfully aware that the current way we do reference resolution (go one by one) leads to linear growth in the number of SQL calls we have to make per reference
We should make sure we:
a) are sharing context whenever possible. https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22070 for example now shares project
a little more aggressively and that cut down calls from 10 per label to 2 per label
b) batch the reference resolution by parent - this would improve things a LOT since, for example, we could find all labels for a particular parent in a single pass