Optimisations to git-annex branch query and setting, avoiding repeated copies of...
authorJoey Hess <joeyh@joeyh.name>
Thu, 29 Sep 2016 17:36:48 +0000 (13:36 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 29 Sep 2016 17:36:48 +0000 (13:36 -0400)
commit1cd02762bfd088ed4e982b450366b85638efd55c
tree076437362d36a62e5521a992895299e2fd2dedb7
parent35446d3c3a3ad4f4cb4bf5d4069938c1e71a038e
Optimisations to git-annex branch query and setting, avoiding repeated copies of the environment.

Speeds up commands like  "git-annex find --in remote" by over 50%.

Profiling showed that adjustGitEnv was 21% of the time and 37% of the
allocations of that command. It copied the environment each time with
getEnvironment.

The only repeated use of adjustGitEnv is in withIndexFile, which tends to
be run at least once per file. So, it was optimised by keeping a cache of
the environment, which can be reused.

There could be other better ways to optimise this. Maybe get the while
environment once at startup. But, then it would have to be serialized back
out each time running a child process, so I doubt that would be a net win.

It might be better to cache a version of the environment that is
pre-modified to use .git-annex/index. But, profiling doesn't show that
modifying the enviroment is taking any significant time.
Annex.hs
Annex/CatFile.hs
Annex/GitOverlay.hs
CHANGELOG
Git/Env.hs