martine/ninja — pull request #779 by nico (2014-06-15 22:23:06+00:00)
Title: Use FindFirstFileEx() for stat()ing files on Windows.

It's apparently much faster to stat all files in a directory with FindFirstFile()/FindNextFile() than it is to stat only the files one cares about individually with GetFileAttributesEx(). This patch changes RealDiskInterface::Stat() to get timestamps for all files in the directory of the passed-in path, and the returns these cached times for all other paths in that directory. See also #476.

For Chromium, empty build time drops from over 4s to about 1.5s. For clang, empty build time drops from about 0.48s to about 0.3s.

For a project that has a directory with tens of thousands of files, but only a few in that directory are stat()ed by ninja, this new approach might be slower than the old one, but I haven't seen such a project in practice yet. If you see one, please let me know! (`-d nowinstatcache` can be used to disable this new stat()ing mode for now; I'll ask the mailing list to test their projects in both modes after landing this.)

This batch stat()ing mode is disabled after the initial round of stat()ing, so that restat rules get up-to-date timestamps.