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

Disabling explain-pause-mode does not clear timers created while the mode is activated #90

Open
yantar92 opened this issue Aug 22, 2020 · 4 comments
Labels
bug Something isn't working question Further information is requested

Comments

@yantar92
Copy link

The issue is in the topic. Severals dozens of timers created by explain-pause-mode appears to slow down Emacs, though clearing the timers would be a good idea regardless of this problem.

@lastquestion lastquestion added bug Something isn't working has-repro Has a repro case question Further information is requested and removed has-repro Has a repro case labels Aug 23, 2020
@lastquestion
Copy link
Owner

Did you check the timers via the list-timers command? When the mode is activated, it hooks all timers so the name of the created timers will be like explain-pause--wrap-callback. Even after you disable the mode, the functions are still wrapped. It shouldn't do anything when the mode is disabled, but the wrapper functions are still there.

So,

  • it's possible to unwrap the functions and replace the wrapper timers with the real timers when the mode is disabled
  • but, even if they are not renamed, the wrapper functions should do absolutely nothing
  • however, given the way the functions are wrapped, it's actually impossible for the end user to figure out what's actually happening once the mode is disabled. which is fairly terrible.

Are you noticing that more and more timers are created and not destroyed? Or is it rather after the mode is disabled, the timers are all still named explain-pause--wrap-callback?

@lastquestion
Copy link
Owner

It's also possible the code that's supposed to check to see if the mode is on or off is not working right, and that could be slowing down emacs.

But I suspect the timers created actually were created by other packages, but there's no way to tell which was which, because they are all named explain-pause--wrap-callback.

I think the first step is to introduce a new symbol for every wrapped callback that has the name of the original function in it. Also, it might be possible to unwrap all the callbacks when the mode is uninstalled. It should be possible.

@lastquestion
Copy link
Owner

Hm, it's possible that when the mode is re-enabled, it's wrapping already wrapped timers and that would indeed slow things down every time you enabled-re-enabled the mode. I will check on that.

@yantar92
Copy link
Author

Did you check the timers via the list-timers command?

Yes.

Even after you disable the mode, the functions are still wrapped. It shouldn't do anything when the mode is disabled, but the wrapper functions are still there.

Here is an example of relevant list-timers output.
Even if the timers do nothing, they still require Emacs to process them.

        35.11      300.0    explain-pause--wrap-callback
        36.13      300.0    explain-pause--wrap-callback
        43.51       60.0    explain-pause--wrap-callback
        43.51       60.0    explain-pause--wrap-callback
  •     0.50          t    explain-pause--wrap-callback
    
  •     1.00          t    explain-pause--wrap-callback
    
  •    15.00          t    explain-pause--wrap-callback
    
  •    60.00          t    explain-pause--wrap-callback
    
  •  7200.00          -    explain-pause--wrap-callback
    

Are you noticing that more and more timers are created and not destroyed? Or is it rather after the mode is disabled, the timers are all still named explain-pause--wrap-callback?

Both. If explain-pause-mode is enabled for a long time, the number of timers generally keep increasing. Up to the point that Emacs slows down to >0.5 sec to run self-insert-command simply because Emacs is checking if there is a need to run all those timers. Killing the timers often has an immediate effect and improves Emacs performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants