Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


May 10, 2004

Prioritize Your Perl Scripts

Prevent CPU-hogging processes from slowing you down
RSS
View this exclusive article with VIP access -- click here to join |
See More Performance Articles Here | Reprints | Or sign up for our VIP Monthly Pass!

Every month, I run a customized Perl script that reads in a bunch of Web server log files and tallies up Web service statistics. The script works well, with one exception: It's a processor hog. The script has to read in hundreds of megabytes of data, so it takes more than 1 hour to finish. And while I run the script, the perl.exe process consumes approximately 80 percent of my CPU processing time, making other work at the same machine agonizingly slow. I thought, "There has to be a better way to do this!" As it turns out, there is: I modified the script to run at a lower priority. Now, the OS gives other running applications more processing time than it gives the Perl script. The script takes a bit longer to run—but using the machine during that time is no longer painful.

Application Priority Classes
Today's multitasking OSs simultaneously run multiple applications by granting each process a certain amount of time to run, then cycling through the processes. The OS uses a process's priority class to determine the amount of CPU time that each processor receives. Windows 2000 and later recognizes six process priority classes:

  • Idle—Processes in the Idle class (aka the Low priority class) run only when no other processes are consuming processor time. A process in this class, which grants the lowest possible priority, will surrender processing time whenever another process requires it. Screen savers run in the Idle class.
  • BelowNormal—Processes in the BelowNormal class get more time than those in the Idle class but less time than those in the Normal class.
  • Normal—The default class for most processes is the Normal class.
  • AboveNormal—Processes in the AboveNormal class get more time than those in the Normal class but less time than processes in the High class.
  • High—Processes in the High class are expected to respond very quickly, even when the system is under high load. The OS allocates considerable amounts of processor time to an application running processes in this class, even at the expense of other applications.
  • Realtime—Using the Realtime class requires extreme caution because this class is designed to run only for very brief periods. The OS dedicates so much CPU time to any application running in this priority class that other processes become starved for CPU time. Therefore, components such as device drivers (e.g., mouse, keyboard, NIC) can be negatively affected. This class typically is used only by device drivers that need intensive processor time for a very short duration (e.g., when reading data coming in over a USB port).

To discover the priority class that an application or service is running under, open Task Manager and select the Processes tab, which displays a list of running processes. Right-click the process you're interested in and select Set Priority from the context menu. In the submenu that appears, you'll see a mark next to the process's current class. You can change the process's priority class by selecting a different class from the list—if you have the appropriate permissions. . . .


Already a VIP member?
Please log on to view the full article

Why become a VIP member?

VIP-only online access
VIP CD delivered twice a year: offline access to the entire Windows IT Pro article library
Monthly issue of your choice of Windows IT Pro or SQL Server Magazine

Subscribe Now
Top Viewed ArticlesView all articles
2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...

Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...


Scripting Whitepapers From Development to Production: Streamlining SharePoint Deployment with DocAve Deployment Manager

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement