Rename detection stalling for some specific huge files
When generating similarity metrics for files that are required for rename detection, then libgit2 caches these metrics for files to not have to continually re-calculate these metrics. For some files it doesn't make sense to calculate these metrics, e.g. for tiny files that have very few lines only, as similarity metrics don't really mean a lot in this context. As a result, libgit2 has heuristics to exclude such files from rename detection. For any such file, though, we continually re-calculate the metrics.
While the above is inefficient already, the heuristics may fail for huge files in case their contents are crafted in a special way. E.g. if a file consists of NUL-characters only, has less than four lines or similar, then it doesn't matter how big that file is, we won't ever cache it. This is especially bad if you have a 50MB file consisting of NUL-characters only as reported in gitaly#2027 (closed), as we're going to calculate similarity metrics for this file 2xN times, where N is the number of other files that exist. As a result, doing the rename detection is going to take a long time.