SlimTune 0.2.1 Released!

I’ve been working towards this milestone for some time now, and it’s finally ready for public consumption. SlimTune 0.2.1 is out!

SlimTune Profiler on Google Code

This version sports a newly retooled interface, along with numerous stability improvements and several new features. To recap, here’s some of the cool things SlimTune can do:

  • Live Profiling – Why should you have to wait until your program has ended to see results? SlimTune reports results almost immediately, while your code is still running. See your bottlenecks in real-time, not after the fact.
  • Remote Profiling – Other tools must be run on the same machine as the application being profiled, which can be inconvenient and worse, can interfere with the results. Remote profiling is an integral part of SlimTune.
  • On-Demand Profiling – Just because your code’s running doesn’t mean you want the profiler interfering. SlimTune lets you profile exactly when and where you need it, so you can focus on the results you need instead of filtering uninteresting data.
  • SQL Database Storage – Instead of developing a custom, opaque file format, we use well known SQL database formats for our results files. That means you don’t have to rely on SlimTune to be able to read your files.
  • Multiple Visualizations – Most performance tools offer a single preset view of your data. Don’t like it, or want it sliced differently? Tough. With SlimTune, multiple visualizers ship out of the box to show you what you want to see, the way you want to see it.
  • Plugin Support – We’re doing our best to produce the most useful visualizations, but that doesn’t mean your needs are the same as everyone else. A few dozen lines of standard SQL and C# code are all it takes to drop in your own view of the performance data, focused on what YOU want to see.

And yes, I know the writing is a bit cheesy, but product pages usually are.

SlimTune was started because the .NET profilers out there suck, or are expensive. I thought there should be a good, open source product out there to support all the developers who are doing real work, but can’t necessarily spend hundreds of dollars per seat for licensing. The more people using SlimTune, the better the feedback will be and the better the thing will get. Please help spread the word, and if you’re using SlimTune for something cool, let me know!

Advertisements

How to Serialize Interfaces in .NET

I’m working on some final touches for SlimTune’s next version, and one of them involves persisting the launcher settings between application runs. Launching is handled by an interface ILauncher, which can be set to any number of things via a reflected list of inherited types. A PropertyGrid is used to configure the settings, and all the underlying code ever sees is the interface. SlimTune’s a plugin based C# app, and this is all pretty standard.

When it came to persisting this data across sessions, I figured it’d be no big deal — I’ll just serialize the object out to isolated storage, and deserialize it again when I need it. There’s one hang-up, though. Serializers (or at least XmlSerializer) can’t handle interfaces! Worse still, the so-called solutions I found online were utterly ludicrous. It turns out this is actually an incredibly easy problem to solve, and mainly involves stopping and thinking about what you’re doing for about five seconds.

Alright, so we can’t serialize an interface, but we can serialize any concrete type. Same goes for the deserialization process. The answer is to simple: store the concrete type with the serialized data.

//save the launcher configuration to isolated storage
var isoStore = IsolatedStorageFile.GetUserStoreForApplication();
using(var configFile = new IsolatedStorageFileStream(ConfigFile, FileMode.Create, FileAccess.Write, isoStore))
{
	var launcherType = m_launcher.GetType();
	//write the concrete type so we know what to deserialize
	string launcherTypeName = launcherType.AssemblyQualifiedName;
	var sw = new StreamWriter(configFile);
	sw.WriteLine(launcherTypeName);

	//write the object itself
	var serializer = new XmlSerializer(launcherType);
	serializer.Serialize(sw, m_launcher);
}

We simply ask the interface to give us its real type, and record it to the file before serializing. Okay, so the result won’t be a legal XML file, but how often is that actually a problem? Now the deserialize side of the equation:

//try and load a launcher configuration from isolated storage
var isoStore = IsolatedStorageFile.GetUserStoreForApplication();
using(var configFile = new IsolatedStorageFileStream(ConfigFile, FileMode.Open, FileAccess.Read, isoStore))
{
	//read the concrete type to deserialize
	var sr = new StreamReader(configFile);
	var launcherTypeName = sr.ReadLine();
	var launcherType = Type.GetType(launcherTypeName, true);

	//read the actual object
	XmlSerializer serializer = new XmlSerializer(launcherType);
	m_launcher = (ILauncher) serializer.Deserialize(sr);
}

Reversing things, we first read the type that was written to file, and reconstruct the actual concrete type that goes with that string. Then we know exactly what to deserialize, and XmlSerializer is happy to oblige.

Now that wasn’t so hard, was it?

ClickOnce Support in SlimDX

Man, it’s been a long time since I wrote about SlimDX. We’ve released the February 2010 version today, so go ahead and grab that if you’re so inclined. This version is mostly bug fixes, for both us and Microsoft. DirectX 11 should be much more usable, although we’re still working towards stronger D2D and DWrite implementations. In the meantime, I wanted to discuss a feature that was included too late for documentation to catch up: ClickOnce support.

ClickOnce has actually been on the to-do list for a very long time, but it ended up quite far down the priority list thanks to a lack of user demand. For the February 2010 release we’ve gone ahead and included it. The installer will set it up for VS 2008 and VS 2010; we’ve dropped 2005 support across the board so no ClickOnce there. There are a few quirks to setting it up properly though, so I just want to explain what you need to do in order to make sure it works properly.

First of all, make sure you’ve got a reference to the GAC version of SlimDX in your project (via the .NET tab in Add References). Also check the properties of the SlimDX reference; the default is Copy Local = True and that should be set to False.

Once you’ve done that, go into your project’s properties and select the Publish tab. This is where you set up all of the ClickOnce options and actually produce a distribution. If you press Application Files, you should see SlimDX.dll listed as Prerequisite (Auto). If it’s something else, you’ve got the previous step wrong.

Next, hit the Prerequisites… button. Somewhere in the listbox, you’ll see “SlimDX Runtime (February 2010)”. Check the box and press OK.

That’s it. Pretty easy, huh? Now when you publish, the SlimDX runtime will be included with your application and run automatically as part of the ClickOnce installation.

Wanted: Socket 939 motherboard

I’m looking for a s939 (AMD) motherboard to put together a mini server system for pretty much all my work (SlimDX, SlimTune, AR Labs). I have all the other pieces, it’s just the mobo I’m missing. If someone is willing to send me an old but working one — preferably micro ATX — they’re not using, that would be amazing. I will pay shipping.

I don’t want to really push anyone into gutting a working system, though. If you can include a processor that would be great, because I’m not sure if the one I have works. 2 sticks of memory would be helpful too — I’ve got two but why stop there?

Let me know if you guys have anything lying around.

SlimTune Testers Needed

I’m currently working towards the release of SlimTune 0.2.1, which will hopefully happen before GDC. If you’ve been paying attention, that might seem a bit odd to you — 0.2.0 isn’t out yet. That’s because 0.2.0 is the pre-release version, and I need testers for it.

The idea is basically to poke around the new code, let me know about glaring omissions or failures, etc. This is a short process, so if you want to do it I need you to have sufficient time this week. I want to put the final touches in this weekend, if possible. The pre-release will install normally and won’t interfere with an upgrade to the proper release version later on.

I’m particularly interested in verification that ASP.NET is working correctly, and simple sanity checks that everything is that it should be. UI feedback is always welcome, though it may not make it into 0.2.1. In any case, if you’re interested you should email me. The address, as usual, is promit dot roy, gmail.

The Eye of the Coder

I wrote this a while back and I keep losing it. Maybe now that it’s here, it won’t get lost again.


Sittin’ down, back in the cube
Ate my lunch, took a quick break
Went to Wendy’s, now I’m back with my code
Just a man and his dual monitors

So many times, it crashes too fast
You trade your soda for coffee
Don’t lose your grip on the mouse and keyboard
You must fight to keep yourself awake

It’s the eye of the coder, it’s the thrill of the bug
Risin’ up to the challenge of our deadline
And the remote debugger tracks your code in the night
And I’m watchin’ it all with the eye of the coder

Face to screen, in the office
Hangin’ tough, stayin’ focused
They report bugs, till we track them all down
For the build that we can mark as gold

It’s the eye of the coder, it’s the thrill of the bug
Risin’ up to the challenge of our deadline
And the remote debugger tracks your code in the night
And I’m watchin’ it all with the eye of the coder

Sittin’ down, back in the cube
Have the docs, got the coffee
Set the breakpoint, now I’m gonna fix it
Just a man and his dual monitors

It’s the eye of the coder, it’s the thrill of the bug
Risin’ up to the challenge of our deadline
And the remote debugger tracks your code in the night
And I’m watchin’ it all with the eye of the coder

The eye of the coder
The eye of the coder
The eye of the coder

I Have Google Buzz Now, Apparently

So…yeah, I guess I’m on Google Buzz. It’s linked to my Picasa and WordPress accounts, so you can follow everything I do. Cause that’s not creepy or anything. The best part is that the defaults for everything are public, and you end up broadcasting to a bunch of random people unless you sit down and sort through. I’m expecting this to backfire for a bunch of people, and not just eventually but almost immediately. It might not be a bad idea to start a betting pool on when the first child porn charges are filed as some highschool student accidentally sends herself to the entire school.

At this point, I imagine most of you are wondering, what the hell is Google Buzz? That’s pretty much what I said when my Gmail offered it to me. Basically, Buzz is a shot across the bow of Facebook, by attempting to integrate multiple services into a streaming feed as part of Gmail, pretty much like the Facebook homepage. Photos come from Picasa, links from Reader, and you can share stuff right in the page too. You have Buzz simply by virtue of having a Google account, although the service is still in the process of rolling out. Since that covers pretty much everyone with an internet connection (and then some), it’s a huge social network under construction.

As for how it competes with Facebook…it’s different. I like Facebook more so far because I can tag arbitrary parts of photos. Picasa makes me use face recognition, which is bullshit. But to be honest, Facebook annoys me. So I’m more likely to use Buzz as another platform to advertise SlimDX and SlimTune, same as I did with Twitter. (And then got bored of.)

Oh, and you better believe they will advertise based on what’s going on in your Buzz network.

[UPDATE] Called it.

More SlimTune UI

Still working on the details, but here are some new teaser shots.


[Update] Slightly newer version of the visualizer:

The best part of the current iteration? NO DAMN REFRESH BUTTON! The graph redraws itself, and the counter list updates itself. No user interaction required.

New SlimTune UI Teaser

Here’s a quick teaser of the new UI:

The window hosting the visualizer is missing all of its widgets, but will eventually have a variety of controls along the edges. The revised main SlimTune window is essentially complete. This window is always open as long as SlimTune is running, and maintains a list of the connections that are active. One window, one connection, and closing one closes the other. It’s much easier to keep track of things this way, and the individual windows can be hidden away to reduce clutter if desired.

[EDIT] Starting to think I should stop using JPEG. Even at 100%, it does some horrible things to text.

SlimTune and Services

I’ve now added service and ASP.NET profiling support to SlimTune. Services seem to work, although I’ve tested it pretty minimally. ASP.NET should work but I’m really not set up to test it properly. I might attempt a VM based test later, because I’m not really sure what sort of status IIS is on my main machine and I don’t really want to find out. Still, ASP.NET is little more than a special case of the service profiling.

Unfortunately, it turns out that admin level privileges are required in order to control (and therefore profile) services. I’ve decided not to automatically request privilege escalation in SlimTune. Instead, it simply blocks you from selecting service or ASP.NET profiling unless you’re running with administrator privileges (and pops up a message box explaining this). You’ll have to right click -> Run as Administrator in order to select those options, unless you’ve turned off UAC outright. Kind of annoying, but I figured it was the best compromise.

Incidentally, the code to support this is mostly cloned out of CLRProfiler, with some work to integrate it into SlimTune smoothly. I don’t even understand why half of it is there. You know why? It’s because there’s no other documentation about how to do it. This problem is somewhat endemic across all the .NET profiling bits, unfortunately. It may also affect the debugger documentation, but I’m not sure.

SlimTune is essentially patched together using a combination of a helpful CodeProject sample, the official documentation, blog posts, MSDN forum questions, and experimentation. I’m hopefully that by publishing a reasonably full featured open source profiler, I’m also creating a good practical reference on how to handle the guts of .NET. I’ve considered blogging more about the internals as well, but that remains to be seen.

[Update] I would like to mention, though, that this is vastly more documentation than is available for Mono.