Fix long line perf of compilation-shell-minor-mode #24
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.
To reproduce the issue of Emacs freezing on long lines, do the following:
Depending on the machine configuration, make your lines longer. 1024*8 is enough to freeze my MacBook Pro 2019 visibly but I need more characters to slow down an XPS-13 running Ubuntu.
In the real world the issue comes up when I'm enjoying my compilation-shell-minor-mode buffer but accidentally cat or print some data with very long lines. Then Emacs freezes and I experience one of my very rare moments of unhappiness with the editor.
Using
M-x profiler-start, profiler-stop, profiler-report
the culprit iscompilation-parse-errors
. The function loops over many (about 50) patterns of potential error output and scans the buffer for them repeatedly.The PR edits the function to use a limited version of
re-search-forward
. Instead of finding the pattern everywhere, it only looks for the pattern in the first 1024 chars of every line. It seems plausible that real-world compiler warnings would sit close to the beginning of lines.With the patch the experience (in combination with global-so-long-mode) becomes tolerable; while not lightning fast, Emacs is a lot more responsive in this situation and I as a user retain control to fix the problem, such as comint-clear-buffer etc.