Firefox/Projects/Startup Time Improvements Notes
Emails From Vlad on Startup
- Importance of Cold Start
Hey guys, Here are the details on getting a cold start (no FS cache) for perf analysis: MacOS X: sync purge Linux: sync echo 3> /proc/sys/vm/drop_caches Windows: Much trickier. First, if you're on Vista/7, you need to delete the preload cache data. In your windows dir, ... argh, can't find it atm, but there's a precache or preload or something, and there should be a firefox.exe-like dir inside it that you need to delete. Otherwise vista/7 will start doing its app preload acceleration stuff which will screw over the data you're trying to collect. Then, grab something like flushmem: http://aegisknight.org/2009/04/flushing-disk-cache/ There's another tool that's more flexible and might be faster, but that one should get the job done. Then run the app. Gotta do these steps before each start to simulate cold start. - Vlad
The purge command on Linux, echo 3> /proc/sys/vm/drop_caches, requires root privileges. [ddahl via adw]
Startup post on dev-apps-firefox
Rob Arnold notes on simulated cold startup on Windows
[14:00] <robarnold> for the disk, you open the disk and flush it... [14:00] <robarnold> for the cache, there's a sysinternals utility [14:01] <robarnold> taras: see http://technet.microsoft.com/en-us/sysinternals/bb897561.aspx [14:02] <robarnold> there's also http://twpol.dyndns.org/weblog/2009/07/29/01 which someone on vlad's blog found [14:05] <robarnold> ok. your results will probably be tainted by the windows feature that predicts file io for a process based on past runs (don't remember the name) [14:07] <robarnold> ah, I think it's in \Windows\Prefetch (at least it seems to be so on windows 7) [14:07] <robarnold> note that you might not have access to that folder since the systems, not the administrator, owns it [14:07] <robarnold> *system [14:17] <sid0> taras, robarnold: suggest you disable the prefetcher altogether [14:17] <sid0> HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\Prefetcher [14:18] <sid0> set EnablePrefetcher to 0 and (on Vista and above) EnableSuperfetch to 0 [14:18] <sid0> this might also need a reboot + clearing out of windows\prefetch
On XP at least the final fragment of the regkey mentioned by sid0 is slightly different. Not sure whether it's different from Vista/7 or he was just remembering wrong: [adw]
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters
(sorry, I remembered wrong. -- sid0)
The default value of the EnablePrefetcher key is 3 (on XP at least). [adw]
(it's the same on Vista/7 -- sid0)
adw's Windows XP experience
The notes above point to three tools for purging disk cache on Windows:
- CacheSet from Microsoft
- Uses a system call to request that the working set of the system's cache be cleared.
- purge.exe from Silver
- This appears to be equivalent to CacheSet.
- flushmem.exe from Chad Austin
- Allocates memory in 64 KiB chunks until it can't anymore, and then writes to each page, forcing older pages out to the page file.
I noticed no difference between starting Firefox warm and starting it after using both CacheSet and purge.exe. Whatever they may do, combined with disabled prefetch they are not sufficient to simulate cold startup.
After using flushmem.exe, Firefox starts up in about the same time it takes for it to startup cold, but it ground my system to a halt for nearly ten minutes.
These were Vlad's experiences as well:
[12:06pm] dietrich: vlad: what's the recommended way to force cold-start on windows? [12:08pm] vlad: all the stuff that people suggested doesn't work [12:08pm] vlad: with cacheset/purge/etc. [12:08pm] vlad: so I have no idea, other than reboot [12:09pm] vlad: reboot and turning off all the prefetching [12:09pm] adw: vlad: is https://wiki.mozilla.org/Firefox/Projects/Startup_Time_Improvements_Notes not correct? [12:13pm] vlad: -that- sadly is [12:13pm] vlad: flushmem would work [12:13pm] vlad: but it's faster to reboot [12:13pm] vlad: since flushmem causesyour system to grind to a halt for a few minutes, even more if you have lots of memory
This is actually a very complicated thing to do, and to do it correctly, these are some of the things you need to worry about:
- Invalidating the CPU caches
- Invalidating the cache on the storage media
- Invalidating the OS's read cache (note that this is not the same as the write cache which can be flushed with Sync.exe via FlushFileBuffers)
- Removing items from the OS's KnownDLL cache (Larry, KB)
- Removing items from the CLR JIT compilation cache (.NET apps only)