<p>I'm desperately looking for cheap ways to lower the build times on my home PC. I just read an <a href="http://www.axantum.com/Blog/post/How-to-make-a-file-read-in-Windows-not-become-a-write.aspx" rel="nofollow noreferrer">article about disabling the Last Access Time attribute</a> of a file on Windows XP, so that simple reads don't write anything back to disk.</p>
<blockquote>
<p>It's really simple too. At a DOS-prompt write:</p>
<p><code>fsutil behavior set disablelastaccess 1</code></p>
</blockquote>
<p>Has anyone ever tried it in the context of <strong>building C++ projects</strong>? Any drawbacks?</p>
<p>[Edit] More on the topic <a href="http://www.windowsdevcenter.com/pub/a/windows/2005/02/08/NTFS_Hacks.html" rel="nofollow noreferrer">here</a>.</p>

[{'answer_id': 81176, 'author': 'paxdiablo', 'author_id': 14860, 'author_profile': 'https://Stackoverflow.com/users/14860', 'pm_score': 2, 'selected': False, 'text': "<p>I haven't tried this on a Windows box (I will be tonight, thanks) but the similar thing on Linux (noatime option when mounting the drive) sped things up <strong>considerably</strong>.</p>\n\n<p>I can't think of any uses where the last access time would be useful other than for auditing purposes and, even then, does Windows store the user that accessed it? I know Linux doesn't.</p>\n"}, {'answer_id': 81184, 'author': 'Dominik Grabiec', 'author_id': 3719, 'author_profile': 'https://Stackoverflow.com/users/3719', 'pm_score': 2, 'selected': False, 'text': "<p>I'd suggest you try it and see if it makes a difference. </p>\n\n<p>However I'm pessimistic about this actually making any difference, since in the larger/clean builds you'll be writing out large amounts of data anyway, so adjusting the file access times wouldn't take that much time (plus it'd probably be cached anyway).</p>\n\n<p>I'd love to be proven wrong though.</p>\n\n<hr>\n\n<p><strong>Results:</strong></p>\n\n<p>Ran a few builds on the code base at work in both debug and release configurations with the last access time enabled, and disabled. </p>\n\n<p>Our source code is about 39 MB (48 MB size on disk), and we build about half of that for the configuration that I built for these tests. The debug build generated <strong>1.76 GB</strong> of temporary and output files, while the release generated about 600 MB of such data. We build on the command line using a combination of Ant and the Visual Studio command line built tools.</p>\n\n<p>My machine is a Core 2 Duo 3GHz, with 4GB of ram, a 7200rpm hdd, running Windows XP 32 bit.</p>\n\n<blockquote>\n  <p>Building with the last access time disabled:</p>\n  \n  <p>Debug times = 6:17, 5:41</p>\n  \n  <p>Release times = 6:07, 6:06</p>\n  \n  <p>Building with the last access time enabled:</p>\n  \n  <p>Debug times = 6:00, 5:47</p>\n  \n  <p>Release times = 6:19, 5:48</p>\n</blockquote>\n\n<p>Overall I did not notice any difference between the two modes, as in both cases the files are most likely in the system cache already so it should just be reading from memory.</p>\n\n<p>I believe that you'll get the biggest bang for your buck by just implementing proper precompiled headers (not the automatically generated ones that Visual Studio creates in a project). We implemented this a few years ago at work (when the code base was far smaller) and it cut down our build time to a third of what it was.</p>\n"}, {'answer_id': 81210, 'author': 'sven', 'author_id': 46, 'author_profile': 'https://Stackoverflow.com/users/46', 'pm_score': 0, 'selected': False, 'text': '<p>it will improve the performance a little. Other than that it won\'t do much more (you won\'t be able to see when the file was last accessed of course). I have it turned of by default when I install windows XP using <a href="http://www.nliteos.com/" rel="nofollow noreferrer">nLite</a> to cut of the bloat I don\'t need.</p>\n'}, {'answer_id': 81377, 'author': 'bastos.sergio', 'author_id': 12772, 'author_profile': 'https://Stackoverflow.com/users/12772', 'pm_score': 1, 'selected': False, 'text': "<p>It's a good alternative, but it will affect some tools.  Like the Remote Storage Service, and other utilies that depend on file access statistics to optimize your file system (i.e. Norton Defrag)</p>\n"}, {'answer_id': 82015, 'author': 'Mike Dimmick', 'author_id': 6970, 'author_profile': 'https://Stackoverflow.com/users/6970', 'pm_score': 3, 'selected': False, 'text': '<p>From <a href="http://msdn.microsoft.com/en-us/library/ms724933(VS.85).aspx" rel="nofollow noreferrer">SetFileTime\'s documentation</a>:</p>\n\n<p>"NTFS delays updates to the last access time for a file by up to one hour after the last access."</p>\n\n<p>There\'s no real point turning this off - the original article is wrong, the data is not written out on every access.</p>\n\n<p>EDIT:</p>\n\n<p>As to why the author of that article claimed a 10x speed-up, I think he attributed his speed-up to the wrong thing: he also disabled 8.3 filename generation. To generate an 8.3 filename for a file, NTFS has to basically generate each possibility in turn then see if it\'s already in use (no reference; I\'m sure <a href="http://blogs.msdn.com/oldnewthing/" rel="nofollow noreferrer">Raymond</a> has talked about it but can\'t find a link). If your files all share the same first six characters, you will be bitten by this problem, and the corrolary is you should put characters which differentiate files in the first six characters so they don\'t clash. Turning off short name generation will prevent this.</p>\n'}, {'answer_id': 83057, 'author': 'Mark', 'author_id': 4405, 'author_profile': 'https://Stackoverflow.com/users/4405', 'pm_score': 0, 'selected': False, 'text': '<p>I don\'t want to draw attention away from the "last access time" question, but there might be other ways to speed up your builds.  Not knowing the context and your project setup, it\'s hard to say what might be slow, but there might be some things that might help:</p>\n\n<p>Create "uber" builds.  That is, create a single compilation uber.cpp file that contains a bunch of lines like</p>\n\n<pre><code>#include "file1.cpp"\n#include "file2.cpp"\n</code></pre>\n\n<p>You might have trouble with conflicting static variable names, but those are generally easy to sort out.  Initial setup is kind of a pain, but build times can increase dramatically.  For us, the biggest drawback is that in developer studio, you can\'t right click a file and say \'compile\' if that file is part of an uber build.  It\'s not a big deal though.  We have seperate build configurations for \'uber\' builds which compile the uber files but exclude the individual cpp files from the build process.  If you need more info, leave a comment and I can get you that.  Also, the optimizer tends to do a slightly better job with uber builds.</p>\n\n<p>Also, do you have a large number of include files, or a lot of depencendies between include files? If so, that will drastically slow down build times.</p>\n\n<p>Are you using precompiled headers?  If not, you might look into that as a solution as that will help as well.</p>\n\n<p>Slow build times are <em>usually</em> tracked down to lots of file I/O.  That is by far the biggest time sink in a build -- just opening, reading and parsing all of the files.  If you cut down file I/O, you will improve build times.</p>\n\n<p>Anyway, sorry to slightly derail the topic slightly, but the suggestion at hand to change how the last access time of a file is set seemed to be somewhat of a \'sledgehammer\' solution.</p>\n'}, {'answer_id': 90619, 'author': 'user11318', 'author_id': 11318, 'author_profile': 'https://Stackoverflow.com/users/11318', 'pm_score': 0, 'selected': False, 'text': '<p>For busy servers, disabling last access time is generally a good idea.  The only potential downside is if there are scripts that use last access time to, for instance, tell that a file is no longer being written.</p>\n\n<p>That said, if you\'re looking to improve build times on a C++ project, I highly recommend reading <a href="http://aegis.sourceforge.net/auug97.pdf" rel="nofollow noreferrer">Recursive Make Considered Harmful</a>.  The article is about a decade old, but the points it makes about how recursive definitions in our build scripts cause long build times is still well worth understanding.</p>\n'}, {'answer_id': 638521, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Disabling access time is useful when using ssd's (solid state drives - cards,usb drives etc) as it reduces the number of writes to the drive. All solid state storage devices have a life which is measured by the number of writes that can be made to each individual address. Some media specify a minimum of 100's of thousands and some even 1 million. Operating systems and other executables can access many files in a single operation as well as user document accesses. This would apply to eee pc's, embedded systems and others.</p>\n"}, {'answer_id': 2070854, 'author': 'mrd0', 'author_id': 251445, 'author_profile': 'https://Stackoverflow.com/users/251445', 'pm_score': -1, 'selected': False, 'text': "<p>To Mike Dimmick:</p>\n\n<p>Try to connect USB drive with many files and copy them to your internal drive. That's also the case in addition to program compilation (which is described in original post).</p>\n"}]
['https://Stackoverflow.com/questions/81158', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2095/']