|
Comment #11
Great article! I find many people are totally clueless about swapfile optimizations and
I get frustrated everytime I hear someone saying the swapfile should be something X ram. I
find that some programs take huge amounts of RAM so if you lock your swapfile to a certain
size and you find your computer crashes then better make sure your swap file didn't get
filled up. 3DSMax is a good example of a RAM sucker so if you start using it watch out
:-).
Something not mentioned in the article is the ability to change the file system
information just for your swap file if you put it in a partition of its own. Running
Windows 98 I place the swap file in the first partition usually making it 200 megs and I
use 32K clusters (instead of 4K) which helps performance. If you're using Windows 2000,
you can use NTFS on your swap partition with the largest cluster size available and use
FAT 32 for other partitions if you wanted. If you're using Linux you can use HPFS with a
large cluster size since I think it's faster then ext2 but uses more memory apparently.
Using a separate partition for your swap file gives you an additional ability to
optimize it with the added flexibility but you need to have a copy of something like
Partition Magic handy just in case you set your partition size too small.
On a slightly different topic I find right after booting that Windows 2000 (build 1946)
uses only 53 megs of RAM (my computer has 256MB) while Win98 uses 110. Win 98 seems to use
a lot more for drive caching and I get much better performance when compiling large
programs. This problem is the same for NT4 as well. Do you have any idea how to increase
the disk caching performance of NT4/Win2k?
Idealego
Thanks Idealego,
I use System Monitor to determine the optimal size of the swapfile. I just run System
Monitor and open up all the programs I usually run concurrently and then some. After
running through all the programs, I then check the maximum size of the swapfile in use.
Rounding up the number to the nearest 50MB, I'll use that figure for my permanent
swapfile. If I require more swapfile in the future, it's very simple to add more.
About the cluster size of the partition affecting the swapfile performance, I'm not
really sure about that. While a larger cluster size means fewer entries in the FAT and
consequently faster searches, it could mean a certain amount of wastage. Besides, the FAT
overhead isn't really that significant. Also, if you create two partitions and place the
swapfile (temporary in your case) in the first partition, it's just the same as creating a
permanent partition, only with less hassle. But if you have had good experience with such
a setup, others could benefit from the same setup as well. :-)
This one requires some thought. Thanks for this contribution to the issue.
Oh... I have never had the opportunity to play with both WinNT and Win2K but I guess
this following method should work. In the System.ini, go to the [vcache]
section and add the following lines :-
MinFileCache=x where x can be any value in KB
(i.e. 2048 for a minimum of 2MB)
MaxFileCache=y where y can be any value in KB (i.e.
16384 for a maximum of 16MB)
Thus, you can set the MinFileCache size to any value you like. That will enable you to
increase the disk caching performance of your system.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Adrian,
Idealego just asked how to optimize his Windows NT file cache, and you suggested to
edit his system.ini file. I would like to point out, and explain why, that is incorrect.
Windows NT does not use the system.ini or win.ini, except for support of legacy
applications. It doesn't really take anything in those files "seriously". In
fact, you can delete them and it couldn't care less! I'm sure you already know that
Windows NT is a completely different operating system, deep down inside, from Windows 9x
and that it only "looks" like Windows 9x and sometimes is forced to
"pretend" it's Windows 9x for the sake of certain legacy applications.
To adjust the working set of the file cache in Windows NT you will have
to use a third party utility such as CacheSet or Cache Manager available
from Systems Internals (http://www.sysinternals.com/).
Hope this information was useful to you. See you on Anandtech.
Mazrim Taim @ Locutus
Hello Locutus! :)
Thanks for that neat piece of information! As I mentioned above, I have not have the
opportunity to play with WinNT. I'm very glad you are able to clear this matter up.
Thanks again!
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #12
Hello Adrian,
I liked the article - clear and to the point. I wanted to give only one remark about
your statement that the first partitions on a disk are the fastest and the last are the
slowest. This is generally true, but not for all the disks. It is always so that the outer
tracks are the fastest ones, but the drive manufacturer can choose which logical disk
blocks he maps on which tracks. The IBM 21/2" notebook disk DPLA- 25120 has the
fastest access on the first BLOCKS and on the last BLOCKS. The blocks between 60% and 90%
are the slowest ones.
The disk transfer curves can be found in the excellent German computer magazine C´T
14/98 on page 152. (http://www.heise.de/ct/)
Johan Devos
Belgium
Hello Johan,
Thanks for the input there. I didn't realise that some hard disk manufacturer like IBM
would purposely map the hard disks like so. That's probably because most people do not
really fill up their hard disk. So it will be most logical to map the drive so that the
first blocks are the fastest and the last (and almost always unused) blocks are the
slowest. All the hard disks that I have tested have all shown a standard curve (except for
the new IBM Deskstar Titan 14GXP drive) with the highest transfer rate from the first
blocks and the lowest from the last blocks.
I haven't seen the C'T report on this IBM hard disk so I don't know why IBM actually
mapped this drive differently. One possible reason is that it could have been done in
order to boost benchmark results, especially the disk transfer tests. In any case, thanks
for writing in with this neat piece of info. :)
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #13
I thought I'd pass this along for your readers that are poor like me and do not own
Norton Utilities. Currently they are offering a free 30 day trial version of their program
at the following URL - http://www.symantec.com/nu/index_downloads.html
I have not tried it yet, since the download is HUGE 37MB or so. But I imagine that you
could download the program and use it just to place your swapfile at the outside of the
disk as suggested. Hope this helps
Jeff Viken
That's an excellent idea, Jeff!! :-)
Why didn't I think of that? After all, you only need to move the swapfile once. So,
everyone can download the trial version, optimize the swapfile and uninstall it. Great
idea there, Jeff! Thanks a lot! You have just solved this problem for lots of people.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #14
I have a question about defragging and virtual memory. I have a PII266 w/64MB of RAM
running Windows98 that I recently cleanly reinstalled. The swapfile is on my root
partition c:. Anyway when I disable virtual memory and reboot to defrag the swapfile area,
I get an out of memory message. I close ICQ and I have no active connections or virus
protection programs. I have also limited the startup programs. I am unable to defrag when
virtual memory is off. I can have it on, or even set to the same max/min and defragging
will work. Is 64MB of RAM too little to do this operation? I seriously doubt it.
Any thoughts?
Jeffrey A. Huseth
Hello Jeffrey,
I remembered answering such a question before. I just checked and lo behold!, the last
reply in Comment #3 holds the answer to your question.
BTW, I don't understand why you disable virtual memory while defragmenting your hard
disk. If you have a permanent swapfile and you use Norton Speed Disk (or similar
commercial utilities), it will move the swapfile to the outer tracks.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #15
Nice article on optimizing the swapfile. I had never thought of many of the issues. I
have now started moving a lot of my files to the front of the hard drive. Unfortunately,
Norton SpeedDisk says that my swapfile is unmovable. I haven't found any place to change
it. I have even included it in the "files to place first" selection, with no
luck. Any suggestions?
I am thinking of creating a zip file the same size as my swapfile, and then move that
up front. Then, If I delete that file I have a chunk of space right in the front. If I
disable and then recreate the swapfile, it should be up in the front... Does that sound
like a good idea?
Nausher Ali
Hello Nausher,
I remember doing the same thing with my old 40MB hard disk when I had the i386SX-16
system. But since Norton Speed Disk can move the swapfile, why bother?
You must select the Optimize Swap File option otherwise Norton Speed Disk won't move
your swapfile to the outer tracks. Check the page
11 of this article for the complete instructions on how to do it.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #16
Wow Adrian, That is an awesome article!
Regards,
Mike Chambers
Viper 3D
Thanks, Mike! :)
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #17
BTW, I have also read your "Optimizing Swap File" article and I praise your
efforts of showing to users several ways of moving the swap file and in Page 10, you
claimed that putting a swap file in another drive is only good theoretically and not very
practical. I am doing exactly the same but I found that performance was better. The point
is that although it is true that there are IDE channel serialization problems in the sense
that the I/O of one hard disk has to wait for the I/O of the another one but the delays of
the burst IDE transfers are in the range of microseconds (us). However, this minor problem
is overcome by saving the seek time of a single hard disk going back and forth to access
the swap file and the application files which is in the range of milliseconds (ms).
Furthermore, not requiring the hard disk to seek back and forth enables it to make large
and continuous burst transfers, provided that the file system is properly defragmented.
I recommend people moving the swap file to another drive if they have one available,
especially those old drives that are meant to be thrown away. At least, you will hear much
less hard disk noise when the system needs to allocate more virtual memory in the swap
file, even if you don't find performance enhancements.
Francisco Leong
Hello Francisco,
If you are bursting data in 1KB bursts or smaller directly from the buffer, then it's
possible that the IDE transfers are in the range of microseconds. But I don't think hard
disks read in 1KB bursts all the time. Just bursting the whole 512KB of data in the buffer
will already take 15 ms. So, most hard disk reads will take much longer than that.
As I have written, if you place the swapfile on a separate hard disk on another IDE
controller, you will realise better swapfile performance but that's not true if you put
them on the same IDE controller because the second hard disk will have to wait for the
first hard disk to finish its transaction before it can do anything. So, even though it
does not need to seek, it still needs to wait.
Besides, defragmenting utilities will pack application files right behind the permanent
swapfile on the outer tracks of the hard disk. Also, Win95/98 will read the application
into memory and only write them to the swapfile when necessary. Thus, seeking is minimal.
In any case, as long as the swapfile stays on the either hard disk on the same IDE
controller, the performance will be about the same.
This is especially true if the secondary hard disk is slower than the primary hard
disk. Let's assume that you have a brand new IBM 14GXP hard disk with a raw transfer rate
of 14MB/s and a secondary Quantum Fireball hard disk with a raw transfer rate of 10MB/s.
The lower transfer rate alone will reduce the performance of the swapfile by 28.6%. And
there's always the longer seek time characteristic of all older hard disks.
The disk noise is due to the design of the hard disk itself. Some hard disks, like the
IBM 14GXP are especially quiet while designs like the Medalist Pro are noisier. Age does
not make the drive quieter though I wish it would. ;)
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #18
Adrian - Good job with swapfile article. Tho I disagree slightly with setting min=max
size. If you set min to an amount you'll most likely never exceed, then set no max amount,
you'll have no danger of jaming W9X. This solves the thrashing problem, keeps swapfile one
size, does not need to be de-fragged, but sets no ceiling which could possibly be
dangerous...
In other words, once you've set the min size large enuff, there's no compelling reason
to set a maximum ceiling...
On Vcache/W95B: Originally I set this too small (max=8mb) on my systems with 128mb or
greater RAM. Noticed when doing DAE with CDrom, my HDD LED was flashing a lot. This was
also true on playing the saved Wav file... Did some testing & found best settings (no
flashing LED). I set min to 4mb, max to 1/4 available RAM, chunksize=512. BTW an IDE CDrom
will flash the LED during DAE regardless, tho at proper Vcache settings you'll get no
flashing during playback of Wav file on HDD...
Regards,
NuovoTech
Hello NuovoTech,
Actually setting Min=Max just creates a permanent swapfile, that's all. You can set the
Min high enough that you will never need the Max value but you will not be able to create
a permanent swapfile that you can move to the outer tracks for better performance.
In any case, if you do miscalculate and run out of swapfile, all you get is an error
message that you have run out of memory. When you get that, just increase the size of the
swapfile and you should be fine. BTW, if I'm not mistaken, Win95/98 will reduce the size
of the dynamic swapfile to 0 bytes during shutdown and increase it to the Min value during
bootup. So, if anything was written to the hard disk before the swapfile was reinstated to
the Min value, then the swapfile will no longer be contiguous.
The word is still out on VCache size. I personally don't know if setting it small or
large is better. I'll have to run some tests some day to test it out.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Hi Adrian,
Great coverage of the swap file issues!
I disagree with your response to NuovoTech's comment. You can, in fact, move the swap
file using Norton Utilities with only the minimum swap file setting set, with the maximum
size not set. I believe that this approach is better than min=max, in that it avoids any
potential for "out of memory" problems.
Ted Lane
Thanks, Ted,
I have not personally tested if just setting a Min value will create a permanent
swapfile that Norton Utilities will move to the outer tracks so please forgive me if I've
misled you and everyone else there! :-)
But I'm not sure if setting just a Min setting is superior to the usual method of
setting Min = Max. That's because in the event your swapfile use exceeds the Min value,
Win98 will increase the size of the swapfile. If the swapfile has already been moved to
the outer tracks, the new sectors allocated to the expanded swapfile will be in the inner
tracks. From then on, accesses to the swapfile will become slower.
So, I'm of the opinion that it's better to add a safety margin of 30-50MB to the
highest amount of swapfile you are ever likely to use so that in the event you exceed your
normal high use, you'll still have a buffer of 30-50MB of optimized
swapfile to fall back on. If you really test your maximum use of swapfile before you set
the permanent size of the swapfile, it's doubtful you'll ever face the "Out of
Memory" problem.
However, I can see where you are coming from. There is definitely the advantage of
dynamically increasing your swapfile size when you need it. I'm worried though that the
"expanded" swapfile size may still stick after rebooting. Even if it doesn't
stick, just imagine if you happen to defragment your hard disk while the swapfile has
increased beyond the Min size. Defragmentation would take an extraordinary amount of time
(because everything has to move to make way for the extra swapfile sectors) and you would
get a "hole" in the outer tracks after rebooting.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #19
Adrian;
Your comments on the swapfile are somewhat inaccurate in the area of two issues in my
experinece. However, your site has more of a gaming slant, so perhaps for gaming, you are
correct.
First, partitions do help minimize data loss. Let me give you two examples. For people
who don't have a UPS, if you are defragging one partition, and you lose power, you usually
lose the entire partition. It messes with the fat tables, not the partition information.
It can make recovery from loss of power situations easier.
Second, remember those 1.6 Western Digital hard drives from 1996 that were only 5% bad,
but it seems everybody had one? Well, when they failed, they took out just the ONE
partition on my hard drive, until the click of death set in on them. So recovery was easy
if you were fast, and didn't try to make the bad disk good again.
A third example, is getting disk crashes in win98. If you have everything on one of
those large hard disk in one partition you will get many more lost clusters upon reboot
then if you leave win98 in its own partition with say 1 gig or so.
Lastly, a swap file on the second hard drive on its own IDE controller is much faster
(assuming relatively equal drivers on both ide controllers) when using graphic imaging
programs, printing and scanning. The difference in performance on my system when scanning
is nothing short of dramatic and I have a SCSI scanner. While the swap file moves
furiously when printing or scanning, the other hard drive with applications is swift
still. Note, this only applies to EIDE hard drives, not SCSI, and only for motherboards
with DUAL FIFO's, of the more recent type (since 1997).
Michael
Hello Michael,
Actually, that's not true. You might lose information with the older defragmentation
utilities but with the newer ones currently in the market, they will store the data in the
swapfile, write the data into its new place, verify it (if you set it so), and then delete
the original data and the copy in the swapfile and update the FAT. In the event of a power
loss, the original data will still be there. I have suffered sudden power cuts in my area
before and I have never lost a partition, not even during defragmenting sessions.
I have had more than my share of defective drives. One particular model was
exceptionally bad - the Quantum Fireball ST. I purchased about 8 different drives (ranging
from 4.3GB to 6.4GB) for my clients. Five died within 3 months and three of the
replacement drive died within a week, with one lasting only 5 hours. In all cases, all
partitions were gone and nothing could be salvaged, well, at least not without a
professional. As Russ Johnson of Symantec said, "However, if
your first partition is taken out, more than likely, the whole drive will be lost."
Again, I have had my share of disasters like system crashes in Win98 but lost clusters
aren't really serious. As far as I know, you can safely delete them. But I don't know if a
smaller partition creates less of them than a larger partition.
Oh... definately, I agree. I believe I mentioned the same thing in the article. As long
as the swapfile is on a separate IDE controller, it can be accessed at the same time as
data on the primary hard disk and thus, perform better.
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/
Comment #20
I really liked your article on swapfiles, excellent work! I think the best part about
it was the comments at the end, instead of getting all defensive when someone e-mails a
correction (like some reviewers out there), you actually welcome such feedback!
Patrick
Thanks, Patrick! :)
Adrian Wong
Adrian's Rojak Pot
http://www.rojakpot.com/
http://www.adriansrojakpot.com/ |