Swapfile Optimization Guide
 






Comment #31

Your article on swap file management was right on. I do have one comment/question. Wouldn't it be better to set a minimum swap file size with no maximum? For instance, a 150 meg min with no max? This would give you all the benefits of the contiguous swap file, but allow it to grow larger *if* it ever needed to.

Scott Manley


Hello Scott,

If I'm not mistaken, setting a large min value with no max value will still cause Win98 to regard it as a dynamic swapfile and thus reduce the size of the swapfile to 0 bytes after you log off / shut down Win98 and reinflate it back to the Min value during booting. Thus, if any data is written to the hard disk before the swapfile is reinflated, it will cease to be a contiguous swapfile.

Also, because it's still a dynamic swapfile, disk optimizers like Norton Utilities will refuse to move it to the outer tracks of the hard disk. Creating a permanent swapfile wouldn't really cause Win98 to hang or pull other funny stunts if it runs out of memory. It just refuses to load the application with an error message that you have run out of memory. To prevent even that from happening, check your system's maximum swapfile usage and round it up generously. That should enable you to determine the optimal size of the swapfile for your system.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #32

Indeed nice article about the swapfile... Just wondering if you could ever add 'expert opinion' on whether a swapfile is better off on a FAT32 or a FAT16 partition..

Eddie Galvez


Well Eddie,

I'll try my best to get the experts to comment on that. Their statements will be posted here as soon as they reply so keep an eye out for updates here.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #33

Here are some comments about your "Optimizing The Swapfile" article.

You are correct on many things, but I think that moving the swapfile from 1st IDE drive (primary) to the second IDE drive (primary) will improve swap performance as long as the second IDE drive isn't too old (too slow). I know that the drives are on the same cable/controller, but this configuration will eliminate unnecessary seeking of drive heads and thus it is faster.

And I should say that IDE drives never offer same kind of performance as SCSI drives when using more than one drive. IDE drives eat more CPU cycles than SCSI drives and so on.

I have no IDE devices on my computer so I know what SCSI can do. But if you have only one hard drive and a CD-ROM, IDE is the perfect choice. No need for SCSI on that configuration. But if you have multiple hard drives, CD-ROM, CD-R and so on... SCSI is the way to go. SCSI + Windows NT = multitasking heaven. (been there, done that) :)

I have never achieved such multitasking benefits while running Win9x (and SCSI).

And BTW... I have 256Megs of RAM in my computer, so I don't need swap file at all, but I still set the swap size in NT to RAM + 12Megs FIXED. (I know... too much swap)

Panu Rantanen


Well Panu,

Placing the swapfile on the second hard disk on the same IDE controller will mask the first seek of the drive heads to access the swapfile but that's hardly significant. Most secondary hard disks (unless you buy both primary and secondary drives of the same model and size) are often slower than the primary hard disk in throughput by anywhere from 2MB/s to 6MB/s. That kind of loss is significant. That's why I recommend leaving the swapfile in the primary hard disk if there's such a throughput gap between the primary and secondary hard disks on the same IDE controller.

Hmm... how I wish SCSI components would drop closer to IDE components price-wise.... The swapfile would definately benefit from a SCSI system.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #34

Dear Mr. Adrian:

FYI, the recent versions of SpeedDisk no longer places the swap file at the outer tracks. It places the swap file in the middle of the drive map. According to the help file, it minimizes the average seek time  to the swap file. Since there must be a reason for Symantec to change this behavior, I believe that seek time often is the bottleneck rather than the transfer time.

Regards,

Francisco Leong


Oh? Are you referring to the new Norton Utilities 4.0? I am currently using Norton Utilities 3.07 and have not tried the new version yet. I'll try to contact Symantec and find out what I can about it.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #35

Hi Adrian Wong,

This is my second email, besides the one talking about WinZip and WinRAR.

I've an opinion about the optimization of swap file. You did mention in article that placing swap file to second harddisk, even at outer side of hard disk, won't gain in speed. I disagree with you, because I think for different hard disks, even if they are connected to the same IDE channel, can access data faster since their read/write heads need not to move as much as that when there is only one harddisk.

For example, if the program/data files are located at cylinder no. 50 and the swap file is located at cylinder no. 2, in the same partition, the read/write head needs to move to access data on the two cylinders. While there are 2 harddisks and the swap file is located at cylinder no. 2 in 2nd hard disk and program/data on cylinder no. 50 in 1st hard disk, their read/write heads do not need to move a long way to access data reside on one of the cylinders. Thus the hard disks' access times are greatly reduced and performance is much better than that of single hard disk. Correct me if I'm wrong.

Happy New Year!

Regards,

CY Hoh


Well CY,

Because both hard disks are on the same channel, only one can be active at any time. So, while the first hard disk is being accessed, the swapfile on the second hard disk cannot be accessed. But as soon as the first hard disk finishes its task, the second hard disk can immediately start its transactions. This negates the need for the first hard disk to seek to the swapfile. However, you'll note that this only masks the first seek to the swapfile after reading elsewhere and back.

On the other hand, as I have mentioned in Comment #33, most secondary hard disks are smaller and slower than the primary hard disk. Their throughput will be slower anywhere from 2MB/s to 6MB+/s. I believe this loss in throughput is more important than the ability to seek less. Also, disk optimizers like Norton Speed Disk will move frequently accessed data next to the swapfile on the outer tracks of the hard disk. Thus, the seek time is minimised.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #36

Hello Adrian,

Congratulation to ur nice article on swap file.

Like one of the fellows who wrote u, I've set the min but not the max. But unlike what u said, I've been able to defrag it w/ both Norton Utilities & Nuts and Bolts (I've confirmed that it got relocated) and Win95 doesn't kill the file b/f shut down. However, I've not been able to test whether Win95 handles it differently from a true permanent swap file or if the performance differs, cuz I can't think of a way to benchmark this. Tell me if u got any idea.

I agree w/ u that putting a 2nd hd to a 2nd IDE channel yields the best performance (if u don't access the CD-ROM often), but I guess one'll still get better performance w/ a slower hd on the same channel cuz of the hardware cache in the drive. I can't confirm that since I'm using 2 similar hds (both IBM 6.4GB, I bought the 2nd one later). In fact I don't fell any difference b/w putting the 2nd hd on either channels. I'm not very familiar w/ hardwares, but I hope u could tell me if Ultra33 allows simultaneous access w/ DMA & PIO on different drive. If so, then the 2 drives may actually be accessed together.

It's interesting that w/ Intel's BusMaster driver, the CD-ROM get spins up every time I open explorer and thus slow down a lot. But since I change it back to MS's own driver (OSR2 w/ Removable Media Update), it doesn't happen anymore. I've heard that MS's driver works better cuz it doesn't break down transfers into 4KB chunks, and I kinda confirm it w/ Adaptec's ThreadMark (higher transfer rate, but somehow I also got higher CPU utilization). It also lets me use DMA access w/ the CD-ROM. The only way I could get Win95 to recognize the 2nd IDE channel is to use Intel's driver (I'm using a LX mb), so I changed the drivers back to MS's one by one in device manager. It works well except that when I copy certain files I'll get an exceptional error in Kernel.Exe. It only happens w/ certain files and w/ explorer, it doesn't happen w/ the same files in a DOS box and I haven't received that error w/ any other programs yet. It only happens w/ certain files and if it hangs on one file, it hangs every time on that file, even after I copied something else first or after reboot. (Thus it is something w/ those files or the locations of the files). I got around 20 files which behaves that way, but after I moved it to another location and copy it back it doesn't happen any more. I duno if it happens when copying to the same drive (cuz I'm trying to move those files to another drive) but it never happens to me anymore. It seems to hang after the file is copied, cuz when I use move instead of copy, the file is lost, but it wasn't on the target location yet. I also duno if accessing the file w/ other programs hangs or not. Do u have any idea what cuz this?

As f/ the extra RAM that Win95's not using, I used Helix's Hurricane to set up a dynamic ram drive and use it as the temp directory. The only program that doesn't like this is Netscape's Communicator, which says that the drive doesn't exist and by pressing ok, it proceeds. I'm not sure if it still use the temp dir but it works fine. I would like to ask Netscape about this but I couldn't find their email (they seems to charge f/ this service). By the way, I used the old version of Hurricane and duno if the new version fixed this. There's also a shareware out there that claims to do even better by allowing the ram drive to grow over the size of the RAM by using the hard disk space in the case that u need it. I haven't tried that program but what do u think about the idea? Hurricane also allows the ram to be used to store the spool file f/ printing but I can't get that to work w/ my printer.

For some strange reason, the vcache setting doesn't work f/ me. No matter what value I set, Win95 simply use the automatic setting. I'm using Win95 OSR2 and those settings doesn't work since the first day I installed the OS.

I've heard that different hd manufacturer use different way to assign the track numbers. Most hds assign outer tracks of all the plates b/f the inner tracks, some assign all tracks on the same plates fr/ outer to inner then fr/ outer tacks of the second plate to the inner and so on, yet some assign fr/ outer to inner f/ the 1st plate then fr/ inner to outer f/ the 2nd plate and so on. That is probably why the performance of some hds doesn't degrade uniformly. Again, I'm not sure about this and don't blame me if I'm wrong. I also wonder why they don't access all the tracks at the same time, it could potentially be a lot faster (like the latest CD-ROM drives that use multiple heads to read fr/ multiple tracks at the same time). Is it technically impossible?

One setting in NU SpeedDisk that works pretty well f/ me is to put all the dirs at the beginning of the disk. It speeds up file access quite noticeably and u may want to try. Too bad N&B's DiskTune doesn't have this feature and I can't use NU now cuz it doesn't handle non-ANSI file names! In general I found that NU's design isn't as flexible as N&B's or even the old PC Tools. Why it's always the good & innovative companies that suffered first?

Whoop, it's getting too long and I hope u don't mind. I enjoy ur article and web site and hope u keep up w/ it.

Victor Wong


Thanks Victor,

Well, try shutting down to DOS and check the size of WIN386.SWP in the root directory. If it's 0 bytes, then Win98 still treats it as a dynamic swapfile. Any writes to the hard disk before Win98 can inflate the swapfile to full size will cause the swapfile to fragment. In Norton Speed Disk, you should see the swapfile (brown) as one contiguous block right at the top of the disk map.

No, only one IDE drive can be active on the same channel at any time. You will only see the performance difference once both hard disks are accessed at the same time. A good example would probably be the copying of files from one hard disk to another. The hard disks on the same controller will take a longer time than it would have been if the hard disks were on separate controllers.

Actually, Win95's bus mastering driver is the same for the following Intel chipsets - 430TX, 440LX, 440BX, 440ZX, etc.. because they are all using the Intel FW82371EB south bridge chip. As far as I can tell, Win95's bus mastering driver for Intel chipsets is quite stable. If your second IDE channel is not recognised by Win95, you might want to check the properties of the IDE controller.

Dual_Channel_Settings.gif (7145 bytes)

You have to make sure that it isn't set to Only Primary IDE Channel enabled. Naturally, you should choose Both IDE Channels enabled or just Default. The incomplete uninstallation of Intel's bus mastering driver might also be the cause.

I'm afraid I can't help you with this because I don't use Helix Hurricane and Netscape Communicator anymore. Can anyone here help with this question?

You have to make sure you type in the MinFileCache and MaxFileCache lines under the [vcache] section. Other than that, I can't think of a reason why you can't manually set the vcache settings.

CD-ROM drives are completely different from hard disks. A CD-ROM drive uses a laser to read data off a CD while a hard disk uses a magnetic head to read / write data to the platter. If I'm not mistaken, the CD-ROM that you are talking about uses a single laser that splits into seven beams to read seven tracks at the same time. I seriously doubt a hard disk head can do that with magnetic fields. :-)

Hmm... I never thought of that... ;-) I think you are right - it will speed up file access quite considerably but if you do a lot of directory creation and destruction, then it might fragment the hard disk faster. I have tried Nuts & Bolts but I moved to Norton Utilities because Symantec updates and improves Norton Utilities quite frequently. I wonder if the new Nuts & Bolts (I heard there's a new one) is better than Norton Utilities...

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #37

One small addition to your excellent piece on swap files. Norton Utilities is available not only via the 37MB download you suggested, but also as a 30day demo on at least a few CD-ROMs. I bought Norton Antivirus 5.0 and found it there. It is also available on the CD with the current issue of Maximum PC ($7.99 -March). Nuts and Bolts is there as a 30 day demo as well.

Thanks for the article. I've bookmarked your page and will return often.

Phil Anderson


Wow!! Why didn't I think of that??? (Answer : Brain Rot) Heheh...

Thanks for the great tip there, Phil! :)

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #38

Hello Adrian:

Great Swap File Article!! With that in mind, I was wondering if you might touch upon the swap file setup utilizing a mixture of SCSI and IDE Drives. What would be the best approach for this? Also, if you are using a SCSI CD-ROM and IDE drives, would the problems of having the Swap file on the Secondary Master improve the access times (as opposed to your article scenario where Secondary Master is shared with IDE CD-ROM)?

Best Regards,

Philip W. Brown


Thanks, Philip, :)

Well, the reason why I did not touch on swapfile setup with a mixture of SCSI and IDE drive is because I have virtually no experience with SCSI drives. But from a theoretical point of view, using a mixture of SCSI and IDE drives will solve a lot of problems. You can consider each SCSI drive to be the equivalent of a IDE drive on its own channel. Thus, the SCSI drives can all run concurrently with one IDE device on each controller.

If you have a SCSI CD-ROM and two IDE hard disk, then placing the swapfile on the secondary IDE hard disk (Secondary Master) will improve the performance of the swapfile.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #39

I have just read your swapfile article and I found it very useful, I had always done the permanent swapfile thing and had always put it on the primary IDE drive, but I had not known that defraggers would move it to the front of the HD! I might download that free trial of NU and give it a go see how it effects my system.

I also have a quick question: Some Soundcards (ie the Soundblaster awe32) have an IDE connector on them. If you had your CD-ROM on this and two equal hd's on different IDE channels. Would the fact that the CD-rom was on the ISA bus and not the PCI bus have a negative effect?

Stranger / Deimos / Malcolm Macdonald


Well, Malcolm,

The sound card's IDE connector can work with the CD-ROM but the slow interface will slow it down. In addition, bus mastering will not be available with the sound card's IDE connector. So, your CD-ROM will definately run slower on the sound card's IDE connector.

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/


Comment #40

Hello,

I'd like to thank ya for the info you posted about the IDE controllers/optimizing swapfiles. You've indirectly solved a somewhat different problem for me. I just set up a FreeBSD box not long ago for a client of mine.

He had requested certain hardware, in particular, 2 Fujitsu 6.4 gig IDE drives. His intentions were to RAID 0 them together to increase performance. Throw a CD drive into the mix, and the problem becomes clear...

Raid 0 [if you don't know] is just block-interleaving...or striping. The concept is to share a partition between two drives - increasing throughput while decreasing access time. This concept requires concurrent reads/writes by the controller - but since an IDE controller can only read ONE drive at a time [couldn't remember for sure...], there's no sense in bothering! [Drives are master/slaved]. [Usually I do this SCSI, which allows concurrent everything].

Anyways, thanks for that controller tidbit. Helped out..

One question about optimization...I've heard that Windows tends to swap out memory when 10% of system ram is used. Fact or fiction? And if so, can one tweak this "feature"? By registry maybe? Help would be appreciated. If you've got any questions I could answer on windows tweaking, etc, lemme know - I've gone VERY far in tweaking the windows OS. I've replaced the explorer shell with one i've written myself... much faster :)

Thanks, take it easy.

Michael Gorman
Network Operations
Visinet


Heheh... glad to be of any help at all. :)

I don't think that Win95/98 will swap out memory unnecessarily. In fact, when I boot up, about 27% of my RAM has already been used up but no swapping has occurred. But I don't know if there's a way to control when Win95/98 starts using the swapfile.

Hey, if you are deep into Windows tweaking, how about helping us out here? An article on Windows tweaking would be fantastic!

Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/

Comments?

If you have a comment or two about this article, please post them here.

Thanks for your time and I hope you enjoyed the article! :)

 

 
 

 

 
     
   

 

 
   

 
     
 

                   

 
   

 

 
 
Last Updated 16-10-2000

All trademarks used are properties of their respective owners.
Copyright © 1998-2000 Adrian Wong. All rights reserved.

 
Visit the new Tech ARP @ http://www.techarp.com/ !