yadm-dev / yadm

Yet Another Dotfiles Manager
https://yadm.io/
GNU General Public License v3.0
5.13k stars 176 forks source link

Speed up yadm by caching results of git calls #505

Open rasa opened 1 day ago

rasa commented 1 day ago

Is your feature request related to a problem? Please describe.

yadm can be slow on slower systems.

Describe the solution you'd like

Cache expensive git calls.

Additional context

When I run yadm commit on my system, these are the commands that are run, and how often (found using GIT_TRACE=1):

  Count  Command
-------  ----------------------------------------- 
      2  git fetch --update-head-ok
      2  git maintenance run --auto --no-quiet
      2  git merge FETCH_HEAD
      2  git rev-parse --git-dir
      2  git rev-parse --git-path objects
      2  git rev-parse --show-prefix
      2  git rev-parse --show-toplevel
      2  git-submodule summary --cached --for-status --summary-limit -1 HEAD
      2  git-submodule summary --files --for-status --summary-limit -1
      4  git config --file=.config/yadm/config --bool yadm.alt-copy
      4  git config --file=.config/yadm/config --bool yadm.auto-alt
      4  git config --file=.config/yadm/config --bool yadm.auto-perms
      4  git config --file=.config/yadm/config --bool yadm.auto-private-dirs
      4  git config --file=.config/yadm/config --bool yadm.gpg-perms
      4  git config --file=.config/yadm/config --bool yadm.ssh-perms
      4  git config --file=.config/yadm/config yadm.git-program
      4  git config --get-all local.class
      4  git config core.worktree
      4  git config local.arch
      4  git config local.hostname
      4  git config local.os
      4  git config local.user
      4  git ls-files
      4  git-sh-i18n--envsubst 'usage: $dashless $USAGE'
      4  git-sh-i18n--envsubst --variables 'usage: $dashless $USAGE'

The results of at least the git config commands can be cached to speed things up, yes?

If you are open to this enhancement, I will draft a PR for your review.

erijo commented 1 day ago

It would be interesting to see how much difference it makes if you replace the calls with hard coded values (i.e. the optimal case)?

rasa commented 23 hours ago

In an iSH emulation environment, running a simple yadm command can take 45+ seconds with auto-alt and auto-perms enabled, and 7.5 seconds when they're disabled.

I will explore how this can be sped up.

https://github.com/yadm-dev/yadm/pull/466 should help when auto-alt is enabled.