Recently I blogged about HighPid, a tool to generate high PID (process id) and TID (thread id). Although this tool considers IDs high if they are more than 2^16, I wondered if I can get the IDs to be real high. Well after recompiling and running the tool I could not generate IDs beyond around 300,000. Here is a plot of how the system PIDs reached to 300k+ after roughly around 35000 iterations on my Vista x86 host.
Contrary to what I expected, the ID generation in Vista seems pretty predictable especially at higher ranges. [There are serious security implications of this but that would perhaps be another post.] At the 300k+ range , process creation eventually fails and HighPid gives up. The simple design of HighPid needed to be rethought out. Since thread creation via win32 API CreateThread was much cheaper than creating a process (CreateProcess), it seemed like a more scalable option to try out. The new HighPid (v2.0) help text looks like below.
Note the /g option that lets one specify ID values higher than 65535 (the default minimum).
After several other tweaks to the source, it was time to try things out. And as it turned out, claiming IDs by calling CreateThread paid off big time. I could generate much higher process and thread IDs than I could with the previous code. Here is a snapshot of HighPid v2.0 in action.
It is nice to see 7 million+ PIDs (23 Bits) on the same system after claiming around 1.8 million+ thread IDs (and consequently thread handles) in a single process. CreateThread eventually fails with ERROR_NOT_ENOUGH_MEMORY (Error 8 – Not enough storage is available to process this command) or ERROR_NOT_ENOUGH_QUOTA (Error 1816 – Not enough quota is available to process this command).
While that is a 20+ time improvement over previous runs, can HighPid go even higher ? Stay tuned.