June 10th, 2008 — 02:55 am
The application I’m working on is a C4I, GIS based application, originally written in framework 1.1.
Recently we did several tests to prove the improvements derived from upgrading to framework 2.0 (or 3.0) without doing major changes in the base code. The performance improvement focus was on switching to Generics for collections containing value types.
Possible pitfalls - mostly the usage of Hashtable and other 1.1 collections, which tend to return NULL when the key is not found. Unlike them, the Dictionary class and similar generic collections tend to throw exceptions if the key is not found. This requires adding calls to the ContainsKey method to prevent these exceptions. Nothing complicated, but a lot of manual labour.
Performance improvements (also with some minor refactoring):
- CPU usage in heavy-load-scenarios was reduced by 10-20%
- Time in GC (as measured by perfmon) was reduced to half of the previous value
Comment » | Performance, Winforms
April 26th, 2008 — 03:27 pm
Jeff Atwood (CodingHorror) complained about the fact a caching addon for Wordpress is optional, and is not included in the basic software:
Personally, I think it’s absolutely irresponsible that WP-Cache like functionality isn’t already built into WordPress. I would not even consider deploying WordPress anywhere without it.
And why is that?
This is an incredibly scary result; blog.stackoverflow.com is getting, at best, a moderate trickle of incoming traffic. It’s barely linked anywhere! With that kind of CPU load level, this site would fall over instantaneously if it got remotely popular, or God forbid, anywhere near the front page of a social bookmarking website.
I don’t have a traffic report for stackoverflow.com, but since both Jeff’s and Joel’s blogs (both being among the most popular technical blogs in the world) point there, I suspect my definition of “moderate trickle” may differ from Jeff’s.
And as Arik pointed out, Wordpress may target smaller users, for which this is not an issue (someone wrote the problem occurred with more than 20000 users per day) while power-users can install optional components to deal with the traffic issues.
Comment » | Blogging, Performance
March 14th, 2008 — 05:11 am
After going this week to the Microsoft performance open house, here are few things to consider:
- Create performance counters of your own to measure various statistics.
- Try to avoid using interfaces and virtual methods to supports inlining.
- If you use a “Contains” method of a collection on structs, be sure to override the “Equals” method, since the default Object.Eqauls method used boxing twice - once for the parameter and the once for “this“.
- Similarly, you should override the GetHashCode methods for structs, since the default implementation for a struct is very inefficient.
- Use Perfmon.exe to monitor the “% time in GC” - a high value may indicate mid-life crisis.
Comment » | Performance, Programming
August 23rd, 2007 — 04:31 am
Some times you need to measure the value of something while running the application.
Using a logger is not comfortable, since you don’t want to monitor gazillion rows of values.
The solution: create a performance counter and use Perfmon.exe to view it while the application is running.
Here is a code for creating a counter:
private PerformanceCounter CreatePerformanceCounter(){ string categoryName = "My Category";
if ( !PerformanceCounterCategory.Exists(categoryName) ) { CounterCreationDataCollection CCDC = new CounterCreationDataCollection();
// Add the counter. CounterCreationData myCounter = new CounterCreationData(); myCounter.CounterType = PerformanceCounterType.NumberOfItems64; myCounter.CounterName = "My Counter"; CCDC.Add(myCounter);
// Create the category. PerformanceCounterCategory.Create("categoryName", "This is my cateogory", CCDC); }
PerformanceCounter result = new PerformanceCounter(categoryName, "My Counter", false);}
Note: You’ll need an administrator account to create a new category, but once it’s there any account it OK.
Comment » | Performance, Useful .Net classes