March 21st, 2005

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

  1. Explorer has had its thread affinity set to 1 proc….
  2. because you previewed an MPG file…
  3. whose decoder calls SetProcessAffinityMask in its DLL_PROCESS_ATTACH…
  4. because the author of the decoder couldn’t fix his multiproc bugs…
  5. 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.)

Topics
Other

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.