Stefan Monnier wrote: > > Setting vc-handled-backends to nil should indeed stop VC from doing > those directory walks. So now I don't understand why the walks done by > VC are so much cheaper than the ones done by locate-dominating-file. > Could it be that all the files you opened were under CVS control (so > the VC search stops before having to walk up the directories)? > > Eventually found vc-find-root. So - it versus locate-dominating-file ? While they're doing a fairly similar job, they do look to me like they're implemented importantly differently -locate-dominating-file takes a regex and passes it to directory-files for each directory. AFAICS directory-files scans the whole directory each time through for the match. OTOH, vc-find-root just tests if /path/to/directory/witness exists. The former is rather slower and (I think) consier. I'm not sure that there's any real performance problem with directory-files itself for what it actually does, though maybe it could be made faster. Maybe not worthwhile though - easier to rewrite locate-dominating-file to not use it as below... Profiling says locate-dominating-file is spending most all its time in directory-files trying that doomed match again and again... find-file-noselect 1108 48.279532999 0.0435735857 find-file-noselect-1 1108 29.139766999 0.0262994287 after-find-file 1108 26.323623999 0.0237577833 normal-mode 1108 21.492128000 0.0193972274 hack-local-variables 1108 19.570003 0.0176624575 hack-project-variables 1108 19.266695999 0.0173887148 project-find-settings-file 1108 19.254854999 0.0173780279 locate-dominating-file 1108 19.237415000 0.0173622879 directory-files 4152 18.688168999 0.0045010040 So is locate-dominating-file's regex-matching really necessary in project-find-settings-file? The only call to locate-dominating-file I can see is it just searching for a (hardcoded name) ".dir.settings.el" in project-find-settings-file, so vc-find-root's rather simpler witness technique would work just fine? +++ And indeed, attached patch makes emacs23 1108-file-startup rather more competitive with emacs22 on my system. Though I didn't do much testing to see if project settings functionality was 100% a-okay - though it seemed to pick up a /usr/local/src/emacs-22.3/.dir-settings.el I made okay... emacs patch withsettings realtime 22 n/a n/a 22.853 23 no no 38.518 23 no yes 38.729 23 yes no 23.295 23 yes yes 23.340