Re: New Optimization Section on d.g.o



On Mon, 2004-09-27 at 10:26 +1200, Callum wrote:

> Currently "Optimizing GNOME Software" contains a single article on using
> Massif for memory profiling. I hope to be able to get a couple more
> articles up myself, but further contributions (and criticism of the
> existing article) will be very welcome.

Oh, here is an article!

	Robert Love

			 Disk Seeks Considered Harmful

				  Robert Love
				<rml tech9 net>
				  26 Sept 2004

				
Dear GNOME Hackers,

Disk seeks are one of the most expensive operations you can possibly perform.
You might not know this from looking at how many of them we perform, but trust
me, they are.  They suck.  Consequently, please refrain from the following
suboptimal behavior:

	(a) Placing lots of small files all over the disk.
	(b) Opening, stating, and reading lots of files all over the disk
	(c) Doing the above on files that are laid out at different times,
	    so as to ensure that they are fragmented and cause even more
	    seeking.
	(d) Doing the above on files that are in different directories,
	    so as to ensure that they are in different cylinder groups and
	    and cause even more seeking.
	(e) Repeatedly doing the above when it only needs to be done once.

Ways in which you can optimize your code to be seek-friendly:

	(a) Consolidate data into a single file.
	(b) Keep data together in the same directory.
	(c) Cache data so as to not need to reread constantly.
	(d) Share data so as not to have to reread it from disk when each
	    application loads.
	(d) Consider caching all of the data in a single binary file that
	    is properly aligned and can be mmaped.

The trouble with disk seeks are compounded for reads, which is unfortunately
what we are doing.  Remember, reads are generally synchronous while writes
are asynchronous.  This only compounds the problem, serializing each read, and
contributing to program latency.

Thanks!


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]