Giter Site home page Giter Site logo

Comments (15)

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024 1

So no, this is not the reason, it is the repeated calls to locate-library which make things so slow, with this change, I get almost the same performances as before:

diff --git a/all-the-icons.el b/all-the-icons.el
index 671037e3b..7f78fd268 100644
--- a/all-the-icons.el
+++ b/all-the-icons.el
@@ -1100,6 +1100,7 @@ Return the icon file name if found."
                    (fn (all-the-icons--data-name (car mapping))))
           (assoc-default (cadr mapping) (funcall fn))))))
 
+(defvar all-the-icons-svg-library "/home/thierry/elisp/all-the-icons.el/svg/")
 (cl-defmacro all-the-icons-define-icon (name alist &key svg-path-finder (svg-doc-processor ''identity) (padding 0))
   "Macro to generate functions for inserting icons for icon set NAME.
 
@@ -1125,7 +1126,7 @@ PADDING is the number of pixels to be applied to the SVG image."
      (defun ,(all-the-icons--function-name name) (icon-name &rest args)
        (let* ((file-name (all-the-icons--resolve-icon-file-name icon-name ,alist (quote ,name))) ;; remap icons
               (size (window-default-font-height))
-              (lib-dir (concat (file-name-directory (locate-library "all-the-icons")) ,(format "svg/%s/" name)))
+              (lib-dir (concat all-the-icons-svg-library ,(format "%s/" name)))
               (image-path (concat lib-dir ,(or (and svg-path-finder
                                                     `(apply ,svg-path-finder file-name lib-dir size args))
                                                '(format "%s.svg" file-name))))

This is of course a dirty patch just to show where the slowdown happens.

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024 1

So probably computing the path of the svg directory one time for all is the way to go.

from all-the-icons.el.

wyuenho avatar wyuenho commented on June 11, 2024

I'm not entirely sure why the difference is so high. Is it because you are running Emacs under WSL? If not, can you provide me with a profiler report?

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

So even if avoiding locate-library make things much faster, I still see some slowdowns due to stuff being computed at each of the function calls, probably these could be avoided or at least cached (memoized)?

from all-the-icons.el.

wyuenho avatar wyuenho commented on June 11, 2024

@thierryvolpiatto see if eb32540 works better.

About cache, the icons are cached at here. Caching them at the icon set level is going to blow up memory usage tremendously, and introduce more cache invalidation issues I have to deal with in addition to #367 and #368.

Let me know if you can think of other ways to speed up this branch :)

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

For reference:
emacs-helm/helm@4a540f5

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

Now helm is working fine with this branch, by using caching where needed I have reduced memory usage and increased speed.
When do you plan merging this branch to master?

from all-the-icons.el.

wyuenho avatar wyuenho commented on June 11, 2024

Don't know, whenever I have some time and brain space :) Feel free to send over a PR if you'd like

from all-the-icons.el.

thierryvolpiatto avatar thierryvolpiatto commented on June 11, 2024

from all-the-icons.el.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.