On 1/27/2012 10:03 AM, Gregory Szorc wrote:
> I have a theory that if I give my VM more memory (enough to hold the
> source tree, .o files, and the linker's peak RSS), that my device I/O
> will effectively go to 0 (minus write buffer flush writes).
Proved. And it took a *lot* of memory. Peak memory usage was ~9GB. At
the time of linking, the page cache was ~5.5GB. By the end of the build,
it went up to ~5.6GB. This was with a clobber build against a fully
populated ccache (debug and optimized builds using GNU linker).
When I performed builds with an empty page cache, it was painfully
obvious that I/O was the bottleneck. Looking at system monitoring,
overall CPU wait % was greater than 80% for significant parts of the
build. Here are some raw numbers (coming from cgroups cpuacct and blkio
subsystems):
Empty page cache Populated page cache
Wall time: 9:11 3:20
CPU time 358s (5:58) 301s (5:01)
CPU user: 22s 22s
CPU system: 140s 8s
Effective CPU: 14.75% 34.5%
Disk Time: 58s 0.004s
I/O Wait Time: 2160s 0.15s
I/O Read Bytes: 2448GB 8192 bytes
After removing my objdir at the end of a build, my page cache goes from
~5.6GB to ~2.5GB, a difference of ~3.1GB.
So, conclusions.
If I were assembling a build machine and wanted consistently fast debug
build times, I would need enough memory to prevent page cache eviction.
Since peak memory usage is in the ~9GB range and you might have other
things running on your machine, I think you'd have to go with 12GB to be
on the safe side. If you can throw more in there, great.
Also, I/O matters. A lot. Without data in the page cache, my device read
~2.5GB during the build spending 58s on the I/O scheduler. This comes
out to ~42MB/s. Not too shabby. However, queued I/O operations spent an
aggregated 36 minutes waiting for data from disk. This translated to a
5:50 wall clock difference in build times.
Keep in mind this was all done with a fully populated ccache, so the
conditions were ideal for a fast build. If we remove the ccache and
force the build to become more CPU heavy, the differences likely won't
be as pronounced.
Greg