Use text properties instead of overlays for ANSI coloring #1500
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TL;DR
This PR improves the performance of REPL buffers by using text properties instead of overlays for ANSI coloring.
Also, this fixes #1452 while removing the hacky workaround introduced by #1455.
I recently sent some PRs related to overlays in the REPL buffer,
but I've finally realized we should avoid using overlays for ANSI coloring in the first place.
It's simply because overlays are pretty slow. I improved the performance a bit in #1488, but it's not radical.
So, in this PR, I remove all code related to overlays and use text properties instead.
I measured the performance by calling
cider-repl--emit-interactive-output
repeatedly.The complete benchmark code is here, and the version of my Emacs is
GNU Emacs 24.4.1 (x86_64-apple-darwin14.0.0, NS apple-appkit-1343.14)
.As this figure shows, the overlay version (current master) is getting slower and slower as the number of lines in the REPL buffer increases.
Total time the overlay version spent on inserting 1000 lines is about 5 seconds. As for the text property version, it's about 0.6 seconds.
If no window displays the REPL buffer, it is much faster in the both cases:
I keep my changes in #1488 as is because they are harmless, but I can remove them if it is necessary.
I also wonder whether I should remove my old changelog entries related to overlays.
Since this PR removes old PRs' changes, it looks a bit strange that these changelog entries appears in the same release.
P.S.
While I had not intended that, the PR #1455 seems to have improved the performance significantly ;)
(This is the worst case, that is, all outputs have a trailing overlay.)