vifm / vifm

Vifm is a file manager with curses interface, which provides Vim-like environment for managing objects within file systems, extended with some useful ideas from mutt.
https://vifm.info
GNU General Public License v2.0
2.74k stars 123 forks source link

Using classify to set icons cause a significantly slow start #542

Closed rockyzhang24 closed 4 years ago

rockyzhang24 commented 4 years ago

Hi,

I tried to use classify to set icons for lots of files/dirs, but it led to a sluggishness issue. I'm using all the devicons from ranger_devicons. Actually I just converted the code in this file to the "classify" sentences which are shown below.

When I start the vifm, there is an around 1s sluggishness. I use ranger_devicons in ranger as well, but the start of ranger is much faster than vifm.

If I get rid of all these icon settings, vifm becomes very very smooth and unbelievably fast. Thank you very much.

macOS version: 10.15.4 (the lastest) vifm version: image

" Icons

" Filetypes
set classify=' :dir:/, :exe:, :reg:, :link:,? :?:, ::../::'

" Dirs
set classify+=' ::.git/::/'
set classify+=' ::.config/::/'
set classify+=' ::Desktop/::/'
set classify+=' ::Documents/::/'
set classify+=' ::Downloads/::/'
set classify+=' ::Dropbox/::/'
set classify+=' ::Music/::/'
set classify+=' ::Pictures/::/'
set classify+=' ::Public/::/'
set classify+=' ::Templates/::/'
set classify+=' ::Videos/::/'
set classify+=' ::node_modules/::/'

" Files
set classify+=' ::.Xauthority,,.Xdefaults,,.Xresources,,.bash_aliases,,.bashprofile,,.bash_profile,,.bash_logout,,.bash_history,,.bashrc,,.dmrc,,.DS_Store,,.fasd,,.gitconfig,,.gitattributes,,.gitignore,,.inputrc,,.jack-settings,,.mime.types,,.nvidia-settings-rc,,.pam_environment,,.profile,,.recently-used,,.selected_editor,,.tmux.conf,,.xinitrc,,.xinputrc,,config,,bspwmrc,,sxhkdrc,,Makefile,,Makefile.in,,Makefile.ac,,mimeapps.list,,.zshenv,,.zprofile,,.zshrc,,.zlogin,,.zlogout,,vifmrc,,yabairc,,skhdrc,,ini,,user-dirs.dirs::'
set classify+=' ::.fehbg::'
set classify+=' ::.vim,,.vimrc,,.viminfo,,init.vim::'
set classify+=' ::Dockerfile,,docker-compose.yml::'
set classify+=' ::dropbox::'
set classify+='X1 ::exact-match-case-sensitive-1.txt::'
set classify+='X2 ::exact-match-case-sensitive-2::'
set classify+=' ::favicon.ico::'
set classify+=' ::a.out,,configure::'
set classify+=' ::config.mk,,config.m4,,config.ac::'
set classify+=' ::Rakefile::'
set classify+=' ::gruntfile.coffee,,gruntfile.js,,gruntfile.ls::'
set classify+=' ::gulpfile.coffee,,gulpfile.js,,gulpfile.ls::'
set classify+=' ::ledger::'
set classify+=' ::package.json,,package-lock.json,,webpack.config.js::'
set classify+=' ::.ncmpcpp,,playlists::'
set classify+=' ::known_hosts,,authorized_keys,,license,,LICENSE.md,,LICENSE,,LICENSE.txt::'
set classify+=' ::procfile::'
set classify+=' ::react.jsx::'
set classify+=' ::README.rst,,README.md,,README.markdown,,README,,README.txt::'

" Extentions
set classify+=' ::*.7z,,*.apk,,.*.bz2,,*.cpio,,*.deb,,*.gz,,*.gzip,,*.gem,,*.lha,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.tar,,*.tgz,,*.xbps,,*.xz,,*.zip::'
set classify+=' ::*.a,,*.cmake,,*.jl,,*.o,,*.so::'
set classify+=' ::*.ai::'
set classify+=' ::*.asm,,*.css,,*.less,,*.s,,*.sh::'
set classify+=' ::*.asp,,*.rom,,*.efi,,*.elf,,*.fish::'
set classify+=' ::*.aup,,*.cue,,*.flac,,*.m4a,,*.mp3,,*.ogg,,*.wav::'
set classify+=' ::*.avi,,*.flv,,*.m4v,,*.mkv,,*.mov,,*.mp4,,*.mpeg,,*.mpg,,*.webm::'
set classify+=' ::*.bat,,*.conf,,*.cvs,,*.htaccess,,*.htpasswd,,*.ini,,*.rc,,*.yaml,,*.yml::'
set classify+=' ::*.bmp,,*.gif,,*.ico,,*.jpeg,,*.jpg,,*.png,,*.ppt,,*.pptx::'
set classify+=' ::*.c,,*.h::'
set classify+=' ::*.cbr,,*.cbz::'
set classify+=' ::*.class,,*.jar,,*.java::'
set classify+=' ::*.clj,,*.cljc::'
set classify+=' ::*.cljs,,*.edn::'
set classify+=' ::*.coffee::'
set classify+=' ::*.cs::'
set classify+=' ::*.cxx,,*.c++,,*.cc,,*.cp,,*.cpp::'
set classify+=' ::*.d::'
set classify+=' ::*.dart::'
set classify+=' ::*.db,,*.dump,,*.img,,*.iso,,*.sql::'
set classify+=' ::*.diff::'
set classify+=' ::*.dll,,*.exe,,*.msi::'
set classify+=' ::*.doc,,*.docx,,*.epub,,*.pdf,,*.rtf,,*.xls,,*.xlsx::'
set classify+=' ::*.ejs,,*.htm,,*.html,,*.slim,,*.xhtml,,*.xml::'
set classify+=' ::*.elm::'
set classify+=' ::*.erl,,*.hrl::'
set classify+=' ::*.ex,,*.exs,,*.eex::'
set classify+=' ::*.f#,,*.fs,,*.fsi,,*.fsscript,,*.fsx::'
set classify+='| ::*.fifo::'
set classify+=' ::*.go::'
set classify+=' ::*.hbs,,*.mustache::'
set classify+=' ::*.hs,,*.lhs::'
set classify+=' ::*.js::'
set classify+=' ::*.json::'
set classify+=' ::*.jsx::'
set classify+=' ::*.key,,*.pub::'
set classify+=' ::*.log::'
set classify+=' ::*.lua::'
set classify+=' ::*.markdown,,*.md::'
set classify+='λ ::*.ml,,*.mli::'
set classify+=' ::*.php::'
set classify+=' ::*.pl,,*.pm,,*.t::'
set classify+=' ::*.psb,,*.psd::'
set classify+=' ::*.py,,*.pyc,,*.pyd,,*.pyo::'
set classify+=' ::*.rb::'
set classify+=' ::*.rlib,,*.rs::'
set classify+=' ::*.rss::'
set classify+=' ::*.scala::'
set classify+=' ::*.scss::'
set classify+=' ::*.sln,,*.suo::'
set classify+=' ::*.styl::'
set classify+=' ::*.ts::'
set classify+=' ::*.twig::'
set classify+=' ::*.vim,,*.vimrc::'
set classify+=' ::*.xul::'
xaizek commented 4 years ago

Hello,

every time you change value of 'classify' it breaks it into pieces and compiles each of them as a regular expression. If you have N of them and add one at a time, you'll get N*(N - 1)/2 compilations of individual regexps in total. ranger_devicons doesn't use regular expressions and doesn't add it one at a time, so no slowdown there.

Patterns like those actually don't need to be regular expressions and are good candidates for optimization. I thought about it, but haven't implemented yet. At the moment you can combine multiple set classify commands together which should reduce startup time.

rockyzhang24 commented 4 years ago

Thank you so much. As you suggested, I combined set classifys together. Now, the superfast start comes back :) I show them below. Could you please help me check whether it is what you mean?

BTW, I think my icon settings are relatively all-inclusive. It almost contains all the special folders and file extensions. Is it possible to put this icon setting into the doc/wiki, or the README page so that other users could use it directly? I pushed it here: https://github.com/yanzhang0219/dotfiles/blob/master/.config/vifm/icons

Thanks a lot!

" Icons

" Filetypes
set classify=' :dir:/, :exe:, :reg:, :link:,? :?:, ::../::'

" Dirs
set classify+=' ::.git/::/,
             \  ::.config/::/,
             \  ::Desktop/::/,
             \  ::Documents/::/,
             \  ::Development/::/,
             \  ::Downloads/::/,
             \  ::Dropbox/::/,
             \  ::Google\ Drive/::/,
             \  ::git/::/,
             \  ::Music/::/,
             \  ::Pictures/::/,
             \  ::Public/::/,
             \  ::Templates/::/,
             \  ::Videos/::/,
             \  ::node_modules/::/'

" Files
set classify+=' ::.Xauthority,,.Xdefaults,,.Xresources,,.bash_aliases,,.bashprofile,,.bash_profile,,.bash_logout,,.bash_history,,.bashrc,,.dmrc,,.DS_Store,,.fasd,,.gitconfig,,.gitattributes,,.gitignore,,.inputrc,,.jack-settings,,.mime.types,,.nvidia-settings-rc,,.pam_environment,,.profile,,.recently-used,,.selected_editor,,.tmux.conf,,.xinitrc,,.xinputrc,,config,,bspwmrc,,sxhkdrc,,Makefile,,Makefile.in,,Makefile.ac,,mimeapps.list,,.zshenv,,.zprofile,,.zshrc,,.zlogin,,.zlogout,,vifmrc,,yabairc,,skhdrc,,ini,,user-dirs.dirs::,
             \  ::.fehbg::,
             \  ::.vim,,.vimrc,,.viminfo,,init.vim::,
             \  ::Dockerfile,,docker-compose.yml::,
             \  ::dropbox::,
             \ X1 ::exact-match-case-sensitive-1.txt::,
             \ X2 ::exact-match-case-sensitive-2::,
             \  ::favicon.ico::,
             \  ::a.out,,configure::,
             \  ::config.mk,,config.m4,,config.ac::,
             \  ::Rakefile::,
             \  ::gruntfile.coffee,,gruntfile.js,,gruntfile.ls::,
             \  ::gulpfile.coffee,,gulpfile.js,,gulpfile.ls::,
             \  ::ledger::,
             \  ::package.json,,package-lock.json,,webpack.config.js::,
             \  ::.ncmpcpp,,playlists::,
             \  ::known_hosts,,authorized_keys,,license,,LICENSE.md,,LICENSE,,LICENSE.txt::,
             \  ::procfile::,
             \  ::react.jsx::,
             \  ::README.rst,,README.md,,README.markdown,,README,,README.txt::'

" Extentions
set classify+=' ::*.7z,,*.apk,,.*.bz2,,*.cpio,,*.deb,,*.gz,,*.gzip,,*.gem,,*.lha,,*.lzh,,*.lzma,,*.rar,,*.rpm,,*.tar,,*.tgz,,*.xbps,,*.xz,,*.zip::,
             \  ::*.a,,*.cmake,,*.jl,,*.o,,*.so::,
             \  ::*.ai::,
             \  ::*.asm,,*.css,,*.less,,*.s,,*.sh::,
             \  ::*.asp,,*.rom,,*.efi,,*.elf,,*.fish::,
             \  ::*.aup,,*.cue,,*.flac,,*.m4a,,*.mp3,,*.ogg,,*.wav::,
             \  ::*.avi,,*.flv,,*.m4v,,*.mkv,,*.mov,,*.mp4,,*.mpeg,,*.mpg,,*.webm::,
             \  ::*.bat,,*.conf,,*.cvs,,*.htaccess,,*.htpasswd,,*.ini,,*.rc,,*.yaml,,*.yml::,
             \  ::*.bmp,,*.gif,,*.ico,,*.jpeg,,*.jpg,,*.png,,*.ppt,,*.pptx::,
             \  ::*.c,,*.h::,
             \  ::*.cbr,,*.cbz::,
             \  ::*.class,,*.jar,,*.java::,
             \  ::*.clj,,*.cljc::,
             \  ::*.cljs,,*.edn::,
             \  ::*.coffee::,
             \  ::*.cs::,
             \  ::*.cxx,,*.c++,,*.cc,,*.cp,,*.cpp::,
             \  ::*.d::,
             \  ::*.dart::,
             \  ::*.db,,*.dump,,*.img,,*.iso,,*.sql::,
             \  ::*.diff::,
             \  ::*.dll,,*.exe,,*.msi::,
             \  ::*.doc,,*.docx,,*.epub,,*.pdf,,*.rtf,,*.xls,,*.xlsx::,
             \  ::*.ejs,,*.htm,,*.html,,*.slim,,*.xhtml,,*.xml::,
             \  ::*.elm::,
             \  ::*.erl,,*.hrl::,
             \  ::*.ex,,*.exs,,*.eex::,
             \  ::*.f#,,*.fs,,*.fsi,,*.fsscript,,*.fsx::,
             \ | ::*.fifo::,
             \  ::*.go::,
             \  ::*.hbs,,*.mustache::,
             \  ::*.hs,,*.lhs::,
             \  ::*.js::,
             \  ::*.json::,
             \  ::*.jsx::,
             \  ::*.key,,*.pub::,
             \  ::*.log::,
             \  ::*.lua::,
             \  ::*.markdown,,*.md::,
             \ λ ::*.ml,,*.mli::,
             \  ::*.php::,
             \  ::*.pl,,*.pm,,*.t::,
             \  ::*.psb,,*.psd::,
             \  ::*.py,,*.pyc,,*.pyd,,*.pyo::,
             \  ::*.rb::,
             \  ::*.rlib,,*.rs::,
             \  ::*.rss::,
             \  ::*.scala::,
             \  ::*.scss::,
             \  ::*.sln,,*.suo::,
             \  ::*.styl::,
             \  ::*.ts::,
             \  ::*.twig::,
             \  ::*.vim,,*.vimrc::,
             \  ::*.xul::'
xaizek commented 4 years ago

Yes, that's what I meant.

You might want to remove these two lines though:

set classify+='X1 ::exact-match-case-sensitive-1.txt::'\ set classify+='X2 ::exact-match-case-sensitive-2::'

I just realized that there is a link to vifm_devicons at https://vifm.info (see "Related" on the right side). You could have used that, but it would be slow as well. I've added link to yours as an alternative (although I think they are almost identical in contents).

rockyzhang24 commented 4 years ago

Okay. Thank you very much! I have already removed those two meaningless lines. Just let you know, compared to vifm_devicons, my icon setting is more comprehensive. I set icons for some special directories (like ~/Documents, ~/Dropbox, etc) and more special files. And it has no slowdown issue. :) I have added a README on my vifm repo containing a screenshot and installation instruction. Could you please change the link of my icons you added to the link of my vifm repo above so that other friends could see the README page? Thanks a lot!

I Love Vifm!!!!