Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emacs uses CPU when this mode is enabled #53

Open
oscarfv opened this issue May 20, 2021 · 6 comments · May be fixed by #57
Open

Emacs uses CPU when this mode is enabled #53

oscarfv opened this issue May 20, 2021 · 6 comments · May be fixed by #57

Comments

@oscarfv
Copy link

oscarfv commented May 20, 2021

First of all: very nice package, thank you!

I noticed that with this mode active Emacs uses ~1-2% of one CPU core when sitting idle. I tried setting mini-modeline-update-interval to a larger value (0.3), but that had no effect.

@oscarfv
Copy link
Author

oscarfv commented Jul 25, 2021

The problem comes from the timer. Currently I'm experimenting with an idle timer instead.

By the way, this code:

(when (timerp (cancel-timer mini-modeline--timer)))

probably should be:

(when (timerp mini-modeline--timer) (cancel-timer mini-modeline--timer))

@kiennq
Copy link
Owner

kiennq commented Jul 25, 2021

Nice. PR is welcome :D

@slotThe
Copy link

slotThe commented Sep 13, 2021

This is perhaps tangentially related, but I wonder why in mini-modeline--timer, the run-with-timer function is always called with a repeat of 0.1

(setq mini-modeline--timer (run-with-timer 0 0.1 #'mini-modeline-display))

and then we are checking if we actually have the right update interval in mini-modeline-display

when (or (memq arg '(force clear))
                          (mini-modeline--overduep mini-modeline--last-update
                                                   mini-modeline-update-interval))              

Wouldn't it make more sense to call

(setq mini-modeline--timer (run-with-timer 0 mini-modeline-update-interval #'mini-modeline-display))

directly and get rid of the mini-modeline--last-update variable entirely (which, as far as I can tell, is not used anywhere else)?

andersjohansson added a commit to andersjohansson/emacs-mini-modeline that referenced this issue Nov 29, 2021
@andersjohansson andersjohansson linked a pull request Dec 14, 2021 that will close this issue
@andersjohansson
Copy link
Contributor

This is perhaps tangentially related, but I wonder why in mini-modeline--timer, the run-with-timer function is always called with a repeat of 0.1

(setq mini-modeline--timer (run-with-timer 0 0.1 #'mini-modeline-display))

and then we are checking if we actually have the right update interval in mini-modeline-display

when (or (memq arg '(force clear))
                          (mini-modeline--overduep mini-modeline--last-update
                                                   mini-modeline-update-interval))              

Wouldn't it make more sense to call

(setq mini-modeline--timer (run-with-timer 0 mini-modeline-update-interval #'mini-modeline-display))

directly and get rid of the mini-modeline--last-update variable entirely (which, as far as I can tell, is not used anywhere else)?

@slotThe, when using an idle-timer, as in #57, I believe it makes more sense to do this kind of check, since the idle timer can fire kind of whenever. But then again, if mini-modeline-update-interval <= the timer interval, (both are 0.1 in by default in #57 it would probably mean that it should always update when it is called (through the timer).

@slotThe
Copy link

slotThe commented Jan 4, 2022

@slotThe, when using an idle-timer, as in #57, I believe it makes more sense to do this kind of check, since the idle timer can fire kind of whenever. But then again, if mini-modeline-update-interval <= the timer interval, (both are 0.1 in by default in #57 it would probably mean that it should always update when it is called (through the timer).

Indeed, I think with an idle timer—which seems like the best solution anyways—it would make sense again

@10ne1
Copy link

10ne1 commented Sep 4, 2022

FWIW I use this modification along with the following config and mini-modeline works quite smooth on my machines, without any flickering (that's why I suppress some mostly useless error signals) or noticeable UI slowdowns (the don't pause redisplay). I am not sure about CPU usage because I tend to run lots of stuff in emacs/EXWM so some cpu usage is expected. Haven't yet investigated if / how it can be reduced.

(setq redisplay-dont-pause nil)

(defun my-command-error-function (data context caller)
  "Ignore the buffer-read-only, beginning-of-buffer,
end-of-buffer signals; pass the rest to the default handler."
  (when (not (memq (car data) '(buffer-read-only
                                beginning-of-buffer
                                end-of-buffer
				quit)))
    (command-error-default-function data context caller)))

(setq command-error-function #'my-command-error-function)

(add-hook 'before-make-frame-hook 'mini-modeline-mode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants