Calculate repository language statistics on git push to speed up Projects::GraphsController#charts

Description

Currently, this controller action calculates a hash of {language: percentage} by looking at every blob in the repository for a given commit. There's a Gitaly migration analysis here: gitaly#158 (closed)

Currently, you can ask for language analysis of any ref, and these are calculated on the fly:

https://gitlab.com/gitlab-org/gitlab-ce/graphs/master/charts https://gitlab.com/gitlab-org/gitlab-ce/graphs/v9.0.0/charts https://gitlab.com/gitlab-org/gitlab-ce/graphs/v8.0.0/charts https://gitlab.com/gitlab-org/gitlab-ce/graphs/cf1beb003bc538fded81c26bb360b1ec9525937e/charts

Proposal

github-linguist comes with a built-in caching solution for this data: https://github.com/github/linguist/blob/master/bin/git-linguist

We can run this command on git push. It will calculate the statistics and write them to disk at that point.

The controller action can then just read the precalculated statistics, rather than computing them in a HTTP request-response lifecycle.

It's not feasible to cache all possible refs, but we can cache the HEAD of the default branch, at a minimum, and perhaps also the HEAD of all branches and tags, if necessary. We can fall back to the slow path if we want to continue supporting arbitrary refs, or we could remove it and restrict these statistics to the cacheable set.

We can do all this without needing any action from Gitaly at the moment.

/cc @bkc @jacobvosmaer-gitlab @DouweM