Tuesday, 22 April 2008

A new use for a USB stick

Also known as pen drives, flash drives or memory sticks, these little devices are used by many of my fellow students to carry their work around on, so that it's available whatever computer they are using. You can now get 4 gig ones, big enough to carry large movies. Mine is 256 megabytes; I only bought it because there is a minimum amount for a card transaction in the College shop. I've rarely used it, instead relying on SSH, email, google docs and my laptop to carry stuff around, but mostly relying on not bothering to organise stuff so that I have lots of different versions of my work on different computers. I have to say, I wouldn't recommend it as a way of working.

Included in Windows Vista is a nice little feature that enables you to use your flash memory as virtual memory. What's virtual memory? Ok, a little explanation for those that are interested. Programs that run on your computer use memory, right? Also known as RAM, this stuff is (usually) volatile (i.e. what's on it is lost when you turn off the machine) and fast. In fact it's many, many times faster to access than a hard drive. There are other memories on your computer which are faster, namely the caches, which store bits of memory which are accessed frequently, and, fastest of all, the registers, which store tiny snippets of vital stuff, like what line of the program comes next. The latter two things are generally on the processor chip itself.

So when you start a program, it will load some or all of itself into memory. There is typically a maximum of 4 gigabytes of addressable memory in a desktop machine, hence the limit on how much RAM you can install. In the past this limit was absolute: you couldn't write a program that needed more that 4 gigs (and it would have been unthinkable in the days when this limit was set) and all the running programs could add up to no more than that figure. Indeed, the limit was usually a lot less, depending on how much actual memory was in your machine. I remember my iMac telling me No you can't start another program up.

The workaround for these problems is what is known as Virtual Memory. To say it simply, this involves allocating space on the hard drive which can be used to store parts of running programs. Usually a program will be using only some of it's code at any time, so large chunks can be written out into the hard drive. If that bit is needed, it's fetched again. This of course takes time, so there are ways of guessing whether particular bits of code will not be needed. Sometimes when you're doing a lot on the computer, it can pause for a time. This background process of swapping stuff onto and off the hard drive is one of the reasons. If you're not using a program, but it's still open in the background, much of the memory used can be swapped out, so when you start to try to work with it again, it can take quite a while to "warm up".

In order to make this process faster, you need a virtual memory storage that is faster to read than a hard drive. That's where flash memory comes in. It's cheap and much quicker than a HD. Recognising that, Microsoft have enabled flash memory in the form of USB sticks to be used for a certain amount of VM. Sorry, getting a bit acronym heavy. That seems to happen in IT. Urg. Within the settings for the stick you can allocate a certain proportion of it to be used for VM. The computer will then recognise it and use it whenever you insert it. And apparently you can remove it at any time, with the only penalty that you lose the speed advantage again.

I have yet to try it, as it seems my USB stick has give up the ghost. But I will. I'm looking forward to seeing if it speeds up performance.

No comments: