I think I figured out the
real problem. I know some of you relate it to antivirus, high CPU usage, and so on. This is both correct and not. Let me explain.
But first, let me give you some specs of my machine, both hardware and sfotware, just to clarify some things.
Hardware
AMD Athlon XP 2800+
ASUS A7N8X Deluxe Motherboard
2GB PC3200 (DDR400) OCZ High-Performance Memory
830GB HD (80GB OS + 250GB x 3 data) + 500GB LaCie backup
GeForce4 Ti4600 128MB
Dual 20.1" Dell 2005FPW monitors
Logitech MX5000 Laser Desktop
Software
Microsoft Windows XP Pro with Service Pack 2 w/ all current updates
Trillian Pro 3.1 Build 121
Google Desktop 2
Logitech SetPoint
Virtual DAEMON Manager 3.47
Firefox 1.0.7
iTunes Setup
iTunes 6.0.1.3
32000+ songs (206+ GB)
music stored on F:\music (250GB SATA drive)
iTunes library stored on D:\My Documents\iTunes (250GB SATA drive)
iTunes Library.itl: 31.1MB (31,859KB or 32,623,357 bytes)
iTunes Music Library.xml: 41.8MB (42,852KB or 43,879,566 bytes)
iTunes.exe: 141,632K mem usage (129,188K VM Size) - approximate as it fluctuates.
The interesting thing that I found out is that it has nothing to do with the iTunes version. I've kept all legacy versions of iTunes since 4.6 and all previous versions cause the same problem. What I did find though is that my system will constantly write temp files at a rate of about 2-3 a minute depending on what I'm doing with iTunes.
Action: Play a song.
Reaction: temp file is generated, then disappears.
Action: Change the rating of a song.
Reaction: CPU spikes. Two temp files are generated and do not disappear.
Addendum: Each temp file is the size of the iTML xml file.
Reaction 2: CPU spikes. One temp file is generated and disappears.
Action: iTunes moves to the next song.
Reaction: CPU spikes. Temp file is generated and disappears. Song may stutter.
Reaction 2: CPU spikes. Temp file is generated and does not disappear.
Addendum: File is the size of the xml file.
Action: Change rating of a song and change the playing song.
Reaction: Temp file is generated and disappers.
Action: Skip through a song.
Reaction: Low CPU spike. Otherwise, no reaction.
Action: Create new smart playlist.
Reaction: Temp file is generated and stays.
Addendum: File is size of the xml file.
Action: Delete smart playlist.
Reaction: Two temp files are generated.
Addendum: One is the size of the itl file, the other is the size of the xml file.
This leads to several observations:
1. mp3 playback is a low CPU process of iTunes. This seems fairly logical as it is the most crucial factor and users will want to do other things with their computers besides only listening to music.
2. Any change to song information in the interface will cause a spike in the CPU and a read/write of both the itl file and the xml file.
I'm curious what kind of Windows systems they test their iTunes software on. They must be high-end machines to not catch issues like this.
This leads to several (linked) conclusions:
1. It seems as if this only happens to users with large libraries. Since the CPU is caught in an intensive process, it seems like the software is attempting to write from memory to disk. This makes sense (sort of) as the intention is most likely an attempt to preserve any immediate database changes if the software or system crashes.
2. The system attempts to write both the itl and xml file at the same time. Why it does that is beyond me - the xml file is merely an industry standard format of the exact same data as the propriety itl file. It also ***** as an xml format (if you've ever taken a look), but that's another issue.
3. The file generation depends on what stage the system is on when it stalls. If it's trying to write both the itl and xml file, then both will be generated.
4. Files are not cleaned up when the CPU spikes, resulting in a delayed write of the temp file(s). This seems to suggest that the "cleanup temp file function" is set on some sort of fixed sleep cycle and is executed after a certain amount of time the "save to itl/xml files function" is executed. The more operations iTunes has to perform, the more time it spends writing the file(s).
5. Windows locks files upon read/write. If you've ever tried deleting a file that's in use (such as an open document), you know what I'm talking about. A perfect example of why Microsoft creates all those .tmp files in the same directory as the document you're editing: the OS has problems reading and writing to a file at the same time, so the temp files are all consolidated after the file is closed.
6. I'm suspecting that this behavior has some correlation to the way Windows deals with files. If you look at Windows programs such as bittorrent, that break files into multiple chunks and performs simultaneous read/write commands to the same chunk, then you will not notice this behavior.
Here's what I think happened with iTunes development. The developers realized that the OS couldn't handle simultaneous read/writes (or something like that) and decided to use a temp file system. They wrote the software to create a temp file to write changes, overwrite the existing itl or xml file with the temp file, then attempt to delete the file. For some reason, the delete portion of the code does two things:
1. It is set to delete at a certain time, and if it cannot, then it just ignores and does not retry.
2. It ONLY attempts to delete the file that was most recently created and does not try to delete any other temp files in the directory. While this approach makes sense if other programs are writing temp files to the same directory, it still seems kind of silly.
There doesn't seem to be any possible user solution. Maybe I (or someone else) may attempt to write some sort of background script (a plugin of some sort?) that will run after certain periods of time and ensure that all temp files are deleted from the directory. It might be a bit tricky. The other solution is that the iTunes development team fixes their temp file deletion code.
For those of you using antivirus, my explanation makes sense even if you only have a small library: the antivirus software is attempting to check the file for viruses (performing a read), thus locking the file while iTunes is trying to delete it. Usage may vary, depending on your antivirus software, as some will check only upon a file write, while some will check only upon a file read, and some will check for both reads and writes.
Hmm... maybe a better solution is that Microsoft writes a better OS. Oh, wait.. this is the best they got so far. Maybe Vista will be better..
The simple solution? Get a Mac =) I support Apple and have a PowerBook, but still use a Windows desktop for various reasons.
PowerBook G4 12 Mac OS X (10.4)