Better compilation-mode performance? #87
Replies: 1 comment 2 replies
-
|
I see what you mean. Rate-limiting Here is a simpler version (operating on top of Doom's defaults). See if this helps you as much as it does me: ;;; add to $DOOMDIR/config.el
(after! compile
(setq compilation-max-output-line-length nil) ; don't scan each line's length.
(remove-hook 'compilation-filter-hook #'comint-truncate-buffer)
(add-hook! 'compilation-filter-hook
(defun doom-comint-truncate-buffer-h (&optional _string)
"Rate-limit `comint-truncate-buffer' in compilation-mode buffers."
(if (> (buffer-size)
;; HACK: Approximate this because counting lines is prohibitively
;; expensive in longer buffers, especially for
;; `compilation-filter-hook' which fires rapidly.
(* 80 comint-buffer-maximum-size))
(let ((gc-cons-threshold most-positive-fixnum)
(gc-cons-percentage 1.0))
(with-silent-modifications
(comint-truncate-buffer)))))))Suppressing GC while compilation is running is another thing to try: ;;; add to $DOOMDIR/config.el
(defvar old-gc-cons-threshold nil)
(add-hook! 'compilation-start-hook
(defun doom-compilation-start-h (_)
(unless old-gc-cons-threshold
(setq-local old-gc-cons-threshold (cons gc-cons-threshold gc-cons-percentage)
gc-cons-threshold most-positive-fixnum
gc-cons-percentage 1.0))))
(add-hook! 'compilation-finish-functions
(defun doom-compilation-finish-h (buf _)
(with-current-buffer buf
(when old-gc-cons-threshold
(setq-local gc-cons-threshold (car old-gc-cons-threshold)
gc-cons-percentage (cdr old-gc-cons-threshold))
(kill-local-variable 'old-gc-cons-threshold)))))
Depends on the output. It could upset formatting and disrupt text properties applied by |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Sometimes I use
compileto run scripts that execute quickly, but generate lots of output (maybe unexpectedly so). Here's a synthetic TypeScript test case:in my terminal,
tsx test.tsfinishes after 0.2s. In emacs, using compile, I get around 180s. Much of that, I think, is caused bycomint-truncate-buffer. Doing the following,the runtime reduces to 21s. With
(setq compilation-scroll-output nil), to about 12s.Is this a good candidate for inclusion into doom-emacs proper? Is
comint-truncate-buffer's property of only deleting complete lines considered essential? Also, perhaps we could dynamically disablecompilation-scroll-outputonce we have to truncate, and scroll once compilation has finished? And perhaps there's a way to speed up things further, since the terminal (kitty, in my case) still outpaces emacs by orders of magnitude?Beta Was this translation helpful? Give feedback.
All reactions