Adept Software Development

Adept: (A)pplication (D)evelopment (E)nterprise to (P)ersonal (T)ransition. It is a system I am developing to leverage Enterprise developer skills to produce stand-alone software for other market segments. This is a general software development blog discussing issues about project, architecture, design and development. The emphasis will be in Java, but many of the issues will be more general. Almost all will be technical.

http://marringtons.com

Monday, August 27, 2007

Disk Caches and Notebooks

Now that I am working in a research job again I will be reviving my blogging. As Software Manager I just did not have time or enough excess energy. While I am thinking up a list of topics I will start off with a complaint session. With the new contract I bought a Macbook Pro with wireless broadband so I could access things like Safari Books Online without worrying that a net-nanny had decided that programming was bad language. I am not a mac-o-phile, but when I did the analysis this time the top of the line Macbook turned out to be the best value for money. My notebook before that was an IBM running Windows 2000 and then XP. With 384Mb of RAM I expected a fair bit of hard disk activity. The Mac has 4Gb, so why does the hard disk run all day? Fortunately "Activity Monitor" has a disk activity pane. With the system idling I see a write every 15 to 30 seconds. No reads, as expected. Unfortunately the monitor did not tell me who was writing to disk. So, for fun (?) I started killing off tasks one at a time. I hoped to find a culprit. No such luck. The space apart between right became wider. Once I had removed most applications it was as long as 4 minutes. I had the drive wind-down set at 5 minutes and it powered down once. The truth is that in this modern day of multi-thread programs it makes sense to have threads running in the background to monitor the context and save it in case the computer closes down unexpectedly. Or to do housekeeping that either writes do disk directly or makes changes to the virtual memory balance. It could be something as simple as a log being updated to say that no activity has taken place. My gut feeling is that most hard disk spin most of the time. I wonder how many tons of carbon a day that equates to for the world's desktops? Or closer to home, how much longer I can run on battery without the hard disk spinning all the time. I was going to wait for a solid state drive, but they weren't quite main-stream. To show that others are thinking on the subject - it is touted as one of the benefits of hybrid drives. I don't think we need fancy hardware to improve things today. I don't even think it needs much of a software change. I think all modern operating systems have write-behind caches. How about giving me a power saving option that does something like:
if no user activity in 5 minutes
if no program using significant constant amounts of CPU time
if write-behind cache is less than 100Mb (or possibly even 10Mb).
if battery power is not low (notebook or UPS)
then
  Turn off drive and cache writes in memory until one of the conditions above change.
It would have to be a power setting in the control panel. There are probably some systems out there where these background tasks are critical and the risk too high. I probably wouldn't use it on a desktop without a UPS. Given the low cost of a UPS these days I would probably buy one just to have my hard disk powered down for a large portion of the day.