Monday, January 3, 2011

IE8 Process Priority in Windows 7

I wanted to bump up the process priority of Internet Explorer 8 under Windows 7.

There are at least a couple of ways to do this. If the app is already running, you can open Task Manager, right-click the app on the Applications tab and click Go To Process, then right-click the process name on the Processes tab and Set Priority to one of the levels above the default, Normal.


I chose a relatively quick-and-dirty method to create a batch file to boost the process priority of IE8, in conjunction with the START command, which can be tested via the Command Prompt.

Generally, the syntax is as follows:

     START /Priority ProgramName

Where /Priority is one of several values (Low, BelowNormal, Normal, AboveNormal, High, RealTime), and ProgramName is the name of a particular executable (EXE) whose priority you wish to boost.

I began with a simple batch file as a proof-of-concept to instantiate a High-priority instance of Notepad.

CLS

start /HIGH notepad



 



Success! Now I wanted to do something similar with Internet Explorer 8, and have it run with High process priority. The result wasn't quite what I wanted.


CLS

start /HIGH iexplore.exe





I'm running the 64-bit version of Windows 7, and have both the 32- and 64-bit versions of Internet Explorer 8 installed. Ideally I would've liked the 64-bit version to run, but it looks like by default the 32-bit one comes up via a command prompt if I omit the path (as I have lazily done here). That's no big deal, nor is the fact that there are two processes named iexplore.exe (see this article on Loosely-Coupled IE [LCIE] by Microsoft's Andy Zeigler regarding why IE8 creates two processes for itself instead of one). The problem is that neither iexplore.exe process has the desired High priority. I got around this by saving the batch file in the 64-bit version of IE's program directory, which by default lives here: 

     C:\Program Files\Internet Explorer

Now when I execute the batch file, START properly starts up one of the iexplore.exe processes at High priority.





But wait, why did it start only one process at High, and the other at Normal?? I'm not sure. I do notice, though, that unfortunately the process which appears to represent the default tab of IE8 that opens is the one set to Normal priority, which isn't exactly what I wanted. I can tell that this seems to be the case when I keep an eye on that process' CPU usage as I try browsing, as shown below.





Furthermore, as I opened additional tabs, which in turned spawned additional iexplore.exe processes in Task Manager, each of these too had only Normal process priority. Only the first process (note that the process with PID 87996 is High, while the second with PID 89476 is Normal).

The end result of this is that despite having set the priority of iexplore.exe to High via the START command in a shortcut, it seems to set this priority only for the "base" instance of iexplore.exe, not the instance which actually seems to be dedicated to browsing; not much help if your goal is to have browsing take precedence among the other activities of your applications. 

It looks like I may need to find some Windows settings specific to Internet Explorer or process priority elsewhere, whether by hacking the registry or some other means.


UPDATE 
1/4/2011

I stumbled upon a post on AskVG which links to a utility, Prio, which extends Task Manager to include among other things a Save Priority option, as shown below:




However, according to some of the comments in the article, some users of Windows 7 64-bit have reported problems getting their changes to process priorites to "stick" between reboots. 

I've installed the utility in a manner suggested by one of the commenters, woodburyadpost, who suggested the following installation steps:
  1. Install. DO NOT REBOOT. 
  2. Uninstall. DO NOT REBOOT. 
  3. Reinstall (and, presumably, reboot).

Curiously, the very first time I installed the utility, I received no prompt asking me to reboot, whereas after following the above steps, the installer did suggest a reboot. Perhaps this indicates the installer is missing something the first time through whereby a component isn't getting copied or installed on the system properly?

At any rate, we'll see if this works, and if so, it'll be a handy utility to have!


Friday, December 3, 2010

Roamatherapy!

Ahh, Christmas, the time for presents, tasty food, and ruminating on the memories of days when Santa Claus really existed outside mere childhood imagination.

For the cheapskate who's always wanted to dabble in aromatherapy, and because "road aromatherapy" or "road rage smells like Christmas" didn't seem catchy enough, I present ROAMATHERAPY


TRY THIS

  1. Go to your local live Christmas Tree seller. This might be your local supermarket with trees and wreaths out front, or some guy selling these out of a tent along the roadside.

  2. Grab a discarded sprig of Douglas Fir. You also could ask nicely, but I doubt the seller would mind if it's already fallen away from the tree.

  3. Using Duck™ tape, a chip clip, or a convenient crevice between the vent and the dash, secure the sprig so that hot air from the vents wafts across it.

  4. Turn on your car's heater. Akin to the principles used by various aromatherapy diffusers, the pleasant aroma of the Douglas Fir is expressed from the plant material into your car's interior.

 

If your memories of Christmas are gloomy or nonexistent, hopefully this will bring you some of the Christmas cheer I associate with the holiday that is far more enjoyable than its rampant consumerism.


 

Thursday, December 2, 2010

String Concatenation and Implicit Conversions

I needed to modify a SQL function to strip some leading zeros in order to concatenate a string. Part of this process involved dealing with pluralization of the number of cents (I'm picky that way).


SELECT
 CASE
  WHEN CAST(CAST(CONVERT(decimal(18,6), 0.30) * 100 AS float) AS varchar(10)) = 1 THEN ''
  WHEN CAST(CAST(CONVERT(decimal(18,6), 0.30) * 100 AS float) AS varchar(10)) > 1 THEN 's' 
  ELSE ''
 END
 

The idea is that if the value (0.30 representing cents) translates into a number greater than 1, the resulting concatenated sentence will read something like "The discount is 30 cents." If the value equals 1, however, it would read "The discount is 1 cent."

When the above is executed, I get an error:

 Msg 245, Level 16, State 1, Line 1
 Conversion failed when converting the varchar value '0.03' to data type int.



At first this baffled me. Data type int?? I wasn't trying to obtain an integer value, I was ultimately trying to obtain a varchar for this string I'm building.

Then it hit me, SQL is performing an implicit conversion when it is comparing the value resulting from the conversion first to decimal, then float, and finally to varchar, with 1.

Lesson learned, when attempting to compare two varchar with numeric values, make sure that if the value being tested is decimal, that the static value being used to compare it against is also decimal.

I made the following changes and now it works flawlessly.


SELECT
 CASE
  WHEN CAST(CAST(CONVERT(decimal(18,6), 0.30) * 100 AS float) AS varchar(10)) = 1.0 THEN ''
  WHEN CAST(CAST(CONVERT(decimal(18,6), 0.30) * 100 AS float) AS varchar(10)) > 1.0 THEN 's' 
  ELSE ''
 END