Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  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. . . .

Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
Command Prompt Tricks

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

Microsoft Touts Xbox 360 'Black Friday' Success

Microsoft this week revealed that its Xbox 360 video game console outsold its Sony PlayStation 3 rival 3-to-1 on "Black Friday," which curiously describes the three day weekend after Thanksgiving, a period that unofficially kicks off the holiday selling ...

How can I stop and start services from the command line?

...


Related Events Virtualization Management

Virtualization for Mission-Critical BI with SQL Server

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 Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


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 Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing