views:

68

answers:

1

Does anybody know why hg status is slow (3-10 secs) the first time it's called from the command line on a windows client (I'm assuming it is cached after that).

hg status is a local operation and it should not take that long especially with empty repos.

This is the case on both an active repository with several changes and a brand new repo with no files. So the size of the repo does not seem to be a factor on the performance. Thanks!

+3  A: 

When you run the hg status command, Mercurial has to scan almost every directory and file in your repository so that it can display file status. Hg has to perform at least one expensive system call for each managed file to determine whether it's changed since the last time Mercurial checked, there's no avoiding that.

I believe the reason subsequent calls to hg st are faster is because of the cached information the OS retains about all recently accessed files —avoiding disk access if the file has not been modified—. Sometimes the files themselves may even remain memory mapped by the OS or cached altogether on the HDD buffer.

Edit: also, if you haven't invoked hg in a while, the OS will need to read the hg executable and its dependencies from disk, since they might not be cached on RAM already.

Julio Gorgé
Thanks! That answers it! however this means that an empty (or a very small) repo should be VERY fast which is not true in all the cases I've seen.
Ash
Julio Gorgé