Psychic debugging: Why your expensive four-processor machine is ignoring three of its processors
On one of our internal mailing lists, someone was wondering why their expensive four-processor computer appeared to be using only one of its processors. From Task Manager’s performance tab, the chart showed that the first processor was doing all the work and the other three processors were sitting idle. Using Task Manager to set each process’s processor affinity to use all four processors made the computer run much faster, of course. What happened that messed up all the processor affinities? At this point, I invoked my psychic powers. Perhaps you can too. First hint: My psychic powers successfully predicted that Explorer also had its processor affinity set to use only the first processor. Second hint: Processor affinity is inherited by child processes. Here was my psychic prediction:
My psychic powers tell me that
- Explorer has had its thread affinity set to 1 proc….
- because you previewed an MPG file…
- whose decoder calls SetProcessAffinityMask in its DLL_PROCESS_ATTACH…
- because the author of the decoder couldn’t fix his multiproc bugs…
- and therefore set the process thread affinity to 1 to “fix” the bugs.
Although my first psychic prediction was correct, the others were wide of the mark, though they were on the right track and successfully guided further investigation to uncover the culprit.
The real problem was that there was a third party shell extension whose authors presumably weren’t able to fix their multi-processor bugs, so they decided to mask them by calling the
SetProcessAffinityMask function to lock the current process (Explorer) to a single processor. Woo-hoo, we fixed all our multi-processor bugs at one fell swoop! Let’s all go out and celebrate!
Since processor affinity is inherited, this caused every program launched by Explorer to use only one of the four available processors.
(Yes, the vendor of the offending shell extension has been contacted, and they claim that the problem has been fixed in more recent versions of the software.)