4 December 2007 in Blogging, General | Comments (1)

On my previous post I placed an image at the end that states “kick it”. For those of you who don’t know what this means, it allows you to effectively “digg” my post and have it appear on a .NET specific site that works in a similar manner to digg.com. I’d recommend joining the site and taking part in the community as some really interesting posts can be found on the dot net kicks site.

Check it out here: www.dotnetkicks.com

Getting kicked helps improve the profile of a post and, hopefully, help drive some new traffic to my site. I’m not asking that you kick every post, but simply making you aware what the icon means and, if you do think a post is useful, you can kick it to show your appreciation.

Note that I haven’t placed one on this post because it’s just an internal memo to you, my reader :)

And that ends this short service announcement.

– JD

Average Rating: 4.9 out of 5 based on 256 user reviews.


4 December 2007 in .Net, Code, Tools | Comments (5)

After yesterdays post I thought I should write up a basic sample to test the effectiveness of the Parallel Extensions. Admittedly it is a contrived example and you are unlikely to see this sort of performance increase in a real world since your applications are unlikely to be this primitive.

My sample iterates through a number sequence from 0 upwards and works out if the value is a prime number. There are two implementations, one using a standard loop and the other using a Parallel.For(). Of course, to try and ride out any spikes I iterate the tests 25 times and then average the outcome. This test is of course not run in a clean environment but does give a roughly indicative result of using the Parallel Extensions.

Using a dual core system, checking the numbers up to 100, 000 and running 25 iterations of each run I had the following outcome:

Using a normal for() loop: 3104 milliseconds average per run
Using a Parallel.For() loop: 1607 milliseconds average per run

This speed up is acceptable and, as you can imagine, these sorts of results are only going to become more impressive as we move to 8, 16, 32 core systems.

A few things to consider in a real world application (consider this my “don’t blame me if you think this will solve all your problems” line! :) :

  • Often slowness is caused by some slow resource – a web connection, a database call etc. The parallel extensions library will default to spinning up as many threads as there are cores and therefore if you have a slow dependent resource you may wish to investigate bumping up the thread count or writing your own threading code.
  • The architecture of a solution is more likely to impact the overall performance of the application. Improving the speed of a few loops and LINQ queries will not improve performance by any order of magnitude.
  • Amdahl’s Law applies – effectively this law states that the maximum parallel improvement that is possible for an application is limited by the amount of sequential code remaining. For example, if I can only make 10% of the code run in parallel then even with infinitive parallel processes running I’m still running slow sequential code 80% of the time – this feeds back to the previous point.

Download my sample application here (with source)

Note: You will need .Net 3.5 framework installed + the Parallel Extensions Library installed

– JD

kick it on DotNetKicks.com

Average Rating: 4.9 out of 5 based on 243 user reviews.


3 December 2007 in .Net, Code, Microsoft, Tools | Comments (0)

Just an FYI for anyone that is keeping up parallel computing, Microsoft has released the December CTP of the Parallel Extensions Library.

From my work with it I’ve found it to generally be quite usable however the documentation and general install quality is a little weak at the moment. Even when trying to respond via the email link in the documentation with some suggested documentation changes I found the email was bounced back – not an overly good look but it is early days :)

The extensions provide parallelisation helpers for both general tasks (e.g. making a for loop parallel) as well as providing PLINQ (one quess for what the “P” stands for!). PLINQ, from my reading, applies only to LINQ to Objects but is a useful start. So far my interest has been in the tasks support.

As a simple example of how to make a loop run using all your cores, here is our original code:

foreach(MyClass c in data)
{
  DoHardStuff(c);
}

Here is our code using the Parallel Extensions:

Parallel.ForEach(data, delegate(MyClass c)
{
   DoHardStuff(c);
});

As you can see, the extensions make it easy enough to start getting some elementary parallelism working.

The tide is changing

I haven’t heard developers discussing parallelism all that much yet and that concerns me slightly given the impending dependence on parallelisation that high performance software solutions are going to have in the coming years. I wonder if perhaps this is because Microsoft hasn’t released anything specific about it yet (present post topic excluded) and therefore many in the .NET space simply have ignored the parallelisation issues. Certainly some developers are looking at languages such as Erlang which is designed with parallel development in mind and enables the creation of massively parallel software.

A key thing to remember is that parallisation is not a solved problem. Simply dropping in a Microsoft assembly is not going to mean that your solutions are going to run a lot better all the time, hence my advice that developers everywhere should be sharpening their saw and rediscovering exactly what the long bearded lecturer in their computer science concurrency class was babbling about.

I would urge every developer to, at the very least, do some reading up on threading, concurrency and even perhaps try the Parallel Extensions.

– JD

Average Rating: 4.4 out of 5 based on 165 user reviews.


26 November 2007 in General | Comments (3)

Lena and I got back from our holiday to Rarotonga this weekend.

Needless to say, we had a kick ass time and managed to unwind as well as do some really cool things that we couldn’t do here in New Zealand.

I have always been the sort of guy that doesn’t take many holidays, this year I had taken 1 day off prior to this holiday and when I left Intergen I had about a month of solid leave owing to me. What I noticed at the end of this holiday was that by unwinding and having a very relaxing time I was feeling hungry to hit the ground with more vigor upon my return.

I’m finally realising the value of a good holiday: de-stress + come back re-engerised. Certainly will be looking to have proper holidays more frequently in the future (more often than once every three years anyway!).

– JD

P.S. Only 12, 000 spam comments blocked by Akismet while away! :-)

Average Rating: 4.6 out of 5 based on 200 user reviews.


3 November 2007 in .Net, Microsoft | Comments (0)

I’ve just finished my session at Bootcamp in Christchurch, the topic being “C# 3.0 Language Enhancements”. Thanks to everyone who came along, I’m consistently impressed by how laid back things feel when presenting in Christchurch.

As promised, here are my slides and demo’s for download: C# 3.0 Language Enhancements Presentation

Keep in mind that these demo’s are built against Beta 2 of the .NET 3.5 runtime (Orcas Beta 2).

John-Daniel

Average Rating: 4.7 out of 5 based on 286 user reviews.


28 October 2007 in Apple, Code | Comments (2)

Once again, Apple did well with their logistics and our pre-ordered copies of Leopard arrived at the Mindscape office at about 11am Friday. I did my install in the evening and much like Rod’s comments, it took a wee while but was about the most painless OS upgrade I’ve ever done.

I was certainly looking for “wow” features and so far I have not really found any – it is very much just additional polish to the OS. Spaces seem cool, the dock update is nice, having a “current time” line in iCal is finally there. There is apparently 1500+ of these types of changes and I’m sure I’ll keep coming across more of them as time goes on.

So what are some of the more major features for the developer crowd?

XCode 3.0 is included and Leopard also adds support for Objective-C 2.0 which is a nice step up from previous versions which did not have automatic garbage collection. I’ll certainly be having a bit more of a look into what else is lurking in the XCode box (so far I haven’t had the time).

Instruments is an interesting new tool for profiling your applications. I haven’t had a chance to poke around with this tool yet and it looks from screen shots that it’s mostly somewhat “fuzzy” in profiling (e.g. showing cpu load or network load in a graph rather than giving extremely detailed dumps of what is going on). I’m looking forward to seeing how Instruments performs.

Dashcode is a tool for helping build dashboard widgets. I’m not quite sure why it’s not included in XCode which seems to have templates for just about every other sort of project under the sun. I’ve never been a big user of widgets so I doubt I’ll use this tool very much.

One of the pain points with doing any development on the Mac is that the books currently in circulation all seem rather out of date. This could be because the documentation explorer, so far, seems quite impressive. Can anybody suggest a good book on Mac development?

– JD

Average Rating: 4.8 out of 5 based on 247 user reviews.


1 October 2007 in Business | Comments (4)

I’ve been thinking about this for a while – why doesn’t an organisation such as the W3C undertake the development of an HTML rendering engine that can be used by all browser makers? Ignore that they may not have developers or money for a moment.

It strikes me that one of the bigger slow downs in web application development is trying to deliver for multiple browsers that supposedly support all the same standards. There is very very little benefit to any one browser being ahead of the pack in terms of standards support because developers still need to build for all browsers and their employers need to pay for that (read: zero competitive advantage in building the most advanced rendering engine).

If browser makers focused more on the chrome and value-add features I’m sure we should see some terrific innovation in browsers. Feature additions to a renderer, outside the standards support, only serves to splinter said standards.

The same could be extended to elements of that browser, e.g. the javascript engine.

John
believes this would be the worst case scenario – there would be no innovation of the underlying engine. My argument is that standards move slowly and, despite their being 5 major browser makers I can think of, innovation of the renderer is somewhat slow anyway. Perhaps because there is no major competitive advantage for supporting new standards when nobody else supports them yet?

All very pie in the sky but sometimes it is worth pondering the theoretical.

John-Daniel

Average Rating: 4.8 out of 5 based on 289 user reviews.


8 September 2007 in .Net, Code, Windows | Comments (2)

I’m posting this because it escaped my attention initially and I’ve been meaning to post it for any other WPF developers out there who have issues with their bindings.

Whenever doing WPF development make sure that you pay attention to the “output” pane in Visual Studio (or better yet, drag the pane to a second monitor while running the application). Here you will see any errors that are occurring with your WPF bindings. You may even spot some you didn’t know were having problems.

Anybody working with WPF will be using the rich binding capabilities and I’m sure, like me, you get annoyed when things just seem to fail silently behind the scenes. Now you can see what’s really going on.

Hope that helps,

John-Daniel Trask

Average Rating: 4.7 out of 5 based on 270 user reviews.