www.dailyunixtip.com
Over these last few weeks I’ve finally got it together to dust off the code for www.dailyunixtip.com and get the thing live.
It’s not big and it certainly isn’t that clever, I hope the site is something useful to put on a Google homepage or as a feed in your browser, and that it’ll occasionally turn up the odd little gem.
I would very much appreciate your questions and comments. Please, take a look around the site and if you feel so inclined, sign up and contribute a tip.
Digital Economy Bill
Like many people in my industry in the UK I wrote to my MP, Adam Holloway, a few months back registering my concerns and opposition to the Digital Economy Bill. I’m not the only one, and sure enough the House of Lords isn’t too happy with some of the provisions in the bill; they are due to report their analysis of the bill on the 1st of March.
In the extended content are the responses I received. It is my understanding that correspondence with a public official is part of the public record, and that I am permitted to reproduce these letters:
Truncate The Transaction Log of Every Database on a Microsoft SQL Server
Somewhat hackish and lacking alerting/error handling, but good enough to keep an internal or development database machine somewhat tidy:
declare@cmd1 varchar(500)
declare@cmd2 varchar(500)
declare@cmd3 varchar(500)
declare@cmd4 varchar(500)
set@cmd1 =
'IF ("?" NOT IN ("master", "tempdb", "msdb", "model")) print "*** Processing DB ? ***"'
set@cmd2 ='IF ("?" NOT IN ("master", "tempdb", "msdb", "model")) execute("alter database ? set recovery simple with no_wait")'
set@cmd3 ='IF ("?" NOT IN ("master", "tempdb", "msdb", "model")) execute("dbcc shrinkdatabase (?)")'
-- Execute the first 3 commands
execsp_MSforeachdb @command1=@cmd1,@command2=@cmd2,@command3=@cmd3
-- As we can only pass 3 commands to this sp_, iterate around again to restore the recovery mode.
set@cmd4 ='IF ("?" NOT IN ("master", "tempdb", "msdb", "model")) execute("alter database ? set recovery full with no_wait")'
execsp_MSforeachdb @command1=@cmd4
.NET Performance Tuning Rosetta Stone for the Java Native
Introduction
I’ve spent quite some time tuning the performance of Java server applications in my last two roles. It helps that I had a great mentor (hello JJ if you are out there). For the past couple of months I’ve been increasingly involved in trouble-shooting and tuning performance problems with .NET applications. Being VM managed garbage collected runtimes both, many of the common problems and solutions I see for the JVM are also applicable to the .NET runtime. Here I present my Rosetta Stone for the JVM native looking to tune a .NET application. It isn’t a complete guide to .NET performance tuning (and I couldn’t write it if you need it - you could do a lot worse than reading this.), but it is enough to get the JVM native started for the most common subset of problems.
Garbage Collection Policy
Within most JVMs the default GC policy is "client", which keeps the memory footprint low and assumes relatively short-lived processes. It is therefore common to pass the -server switch to switch the trade-off within the garbage collector to better suit long-running process with generally larger heaps (I’ll ignore the existence of the new collectors in Java 6 for now). The .NET runtime behaves in exactly the same way, and also defaults to a "workstation" policy. This MSDN article details how to change the collector to the more agressive and threaded "server" collector.
Heap preallocation to ensure contiguous block of memory
It is a common trick to pre-allocate the JVM heap by setting the -Xmx and -Xms switches to the same value, thereby ensuring a contiguous allocation of memory and staving off any unexpected future allocation errors. This is not possible with the .NET 3.5 runtime, something I don’t understand given that arrays are allocated in contiguous blocks. I don’t think that the .NET runtime requires contiguous regions per-se, but the size and numbers of the assemblies being loaded (plus the aforementioned arrays) will require contiguous memory at some point. You should keep a careful eye on both the amount of free memory and its fragmentation.
GC and other performance counters
On the JVM we use the -verbose:gc and other related switches, or JMX, to monitor the JVM process and the important metrics, with .NET everything is most easily accessible through perfmon and the .NET counters. A little note on terminology, "pinned" objects are those that have active references and cannot be collected.

