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

[Question] Why all-the-icons-icon-for-mode create idle timers? #113

Closed
stardiviner opened this issue May 6, 2018 · 7 comments · Fixed by #227
Closed

[Question] Why all-the-icons-icon-for-mode create idle timers? #113

stardiviner opened this issue May 6, 2018 · 7 comments · Fixed by #227

Comments

@stardiviner
Copy link
Contributor

I have following config:

(defun *major-mode ()
  "The major mode, including process, environment and text-scale info."
  (if (cdr (assoc major-mode all-the-icons-mode-icon-alist))
      ;; (all-the-icons-icon-for-buffer)
      ;; (all-the-icons-auto-mode-match?)
      (all-the-icons-icon-for-mode major-mode :v-adjust -0.1 :height 1.0)
    ;; (all-the-icons-icon-for-file (buffer-file-name) :v-adjust -0.05 :height 1.0)
    (propertize (format-mode-line "%m" mode-name)
                'face 'mode-line-data-face)
    ))

And I execute helm-timers found there are some timers are from all-the-icons.

all-the-icons major-mode timers

My question is why need to create those timers? After did some profiling with Emacs profiler. Found it might slow down performance a little. Is it really necessary?

@stardiviner
Copy link
Contributor Author

stardiviner commented May 7, 2018

I found why now, it is because memoize is used. (memoize 'all-the-icons-icon-for-mode).
Is this memoize must necessary? I don't know why all-the-icons for major-mode need to be updated by timer. Shouldn't it be buffer local and static?

@wyuenho
Copy link
Collaborator

wyuenho commented Feb 23, 2019

Judging from memoize's source, looks it's there to implement some sort of poor-man's weakref. It basically runs the timer every 2 hours by default to free up memory. I would imagine this was put in place to speed up icon look ups from that flat list. Lots of linear searches are expensive.

@wyuenho wyuenho closed this as completed Feb 23, 2019
@harizvi
Copy link

harizvi commented Jun 11, 2020

I just hit this issue, with my timers list showing 680 outstanding timers. I had visited a few large directories with dired! The reason I started looking was because Emacs was running "laggy", esp with ivy-switch-buffer acting weirdly. Just wondering if this is not considered a problem?

@mpereira
Copy link

Another one bumping into this. My Emacs currently has 2000 non-idle timers started by all-the-icons.

Would keeping an in-memory hash map cache of icons be sufficient as a performance-improving alternative?

@wyuenho
Copy link
Collaborator

wyuenho commented Sep 1, 2020

Would keeping an in-memory hash map cache of icons be sufficient as a performance-improving alternative?

Perhaps. Care to submit a PR to replace memoize?

@yantar92
Copy link

yantar92 commented Sep 2, 2020

Perhaps. Care to submit a PR to replace memoize?

As a simple solution, all-the-icons can set memoize-default-timeout to nil when defining memoized functions. The timers will not be created then. This should not cause any significant memory leaks since the number of possible function arguments is finite (and relatively small).

@mpereira
Copy link

mpereira commented Sep 8, 2020

@wyuenho I unfortunately don't have a lot of free time these days. Does it make sense to re-open this ticket for visibility?

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