One of the improvements I want to make in an upcoming version of the About Startup extension is to allow to distinguish between cold and hot startups. One way to do so is to check how many page faults actually led to reading off a disk. They are called hard page faults.
On UNIX systems, their count for a given process can be obtained with the
getrusage function, which works on both Linux and MacOSX systems.
Under Windows, that is another story, and so far I haven’t found anything satisfactory.
My first attempt was to see how cygwin, which brings UNIXish libraries to Windows, was doing for its own
getrusage. And the answer to that is that it gives the wrong data. sigh. It uses
GetProcessMemoryInfo to fill the hard page faults field (
ru_majflt), and nothing for the soft page faults field (
GetProcessMemoryInfo returns the number of soft page faults.
The best I could find on MSDN is the
Win32_PerfFormattedData_PerfOS_Memory class from Windows Management Instrumentation, except is it system-wide instead of per-process information, and only gives rates (hard page faults per second, which it calls page reads per second). The corresponding raw data doesn’t seem very satisfactory either.
So, dear lazyweb, do you have any idea?
Update: Taras suggested to use GetProcessIOCounters, which, despite not giving hard page faults count, looked promising as a way to distinguish between cold and warm startup, but it turns out it is as useless as some systemtap and dtrace scripts you can find on the net: from my experiments, it looks like it only tracks active
write() system calls, meaning it doesn’t track mapped memory accesses, and more importantly, it only tracks the system calls, not when actually doing I/O, thus hitting the disk.