It seems that the time taken to highlight a given file is quadratic with the number of chunks to highlight in that file.
Highlighting 1700 chunks takes 7ms.
Highlighting 17000 chunks takes 700ms.
Highlighting 90000 chunks takes 24000ms.
When removing the overlap check (https://github.com/SonarSource/sonarqube/blob/master/sonar-batch/src/main/java/org/sonar/batch/highlighting/SyntaxHighlightingDataBuilder.java#L61), highlighting 90000 chunks takes 175ms.