real world programming

Changing Priority

Posted by kevinup on February 3, 2009

So a while ago my client gave me new requirement that went something like this:

It has to be fast, really, really, really, fast. And did I mention it has to be fast? Oh almost forgot, it has to go fast.

Well, I coded it up, was pleased and moved on. This week our QA server was having some problems. It would slow down, and then suddenly be responsive again. Apparently the testers had finally gotten around to testing my little piece of functionality. The head architect came to me saying that everything was running slow on the box. My code was basically spawning a bunch of threads, doing a bunch of work, and then closing out. This was causing the processor to peak at 99%, which is apparently a problem J.

Part of me was a little proud of my code. In hindsight I should have asked more questions about how fast it needs to run in.

Anyway, with the following code, it still was able to run pretty quick, without doing any major refactoring:

Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: