Performance counter mismatch detection


One of the problems with iterative development of servers that include performance counters is that it's quite easy for the counters that are installed on a machine to get out of sync with the counters that the server is actually compiled to use. As development progresses and new counters are added the counter dll needs to be uninstalled and then reinstalled so that the text strings associated with the counters remain in sync. Before I rewrote my performance counter code it was reasonably easy to spot when this happened in a debug build, the server simply crashed... The problem was that the removal code required that the counters that you were removing matched the counters that were installed (if you see what I mean) so by the time you realised that you hadn't removed the counters before rebuilding it was usually too late...

The new version of the performance counter library doesn't suffer from this problem, you can remove mismatched counters safely, but it doesn't spot when the counters that the program is compiled with don't match the counters that are installed and this tends to lead to counter descriptions being incorrect and can be quite hard to spot. It's only really a development issue, but it's something that has bitten me enough that I decided it was time to fix it once and for all.

My solution is to take an MD5 digest of a string that is built up from the schema of the performance counters that the program is compiled with and write that into the registry along with the other performance counter stuff when the counters are installed. When the program starts up it can generate a digest of the schema that it is compiled with and compare this with the digest of the schema that was being used when the counters were installed; failure can result in an error message that tells you exactly what's going on...

These changes will be in release 5.3 of The Server Framework which is scheduled for late February. The next release, 5.2.1, which is due in early Jan, will add support for VS2008.

Leave a comment