Sunday, February 10, 2008

Apple Bonjour Pitfalls on Multicore Machines

Many in the software development community rejoiced when Apple announced they were open sourcing Bonjour. I am not ashamed to say I was one of them since I have used the technology in my own projects and have been amazed by the relative ease of use of the technology as compared to something like Jini. However, a problem we ran into recently highlighted some of the unforeseen hiccups technology can run into -

My Bonjour based auto-discovery code written using the new Java libraries was working very reliably in test environments for some time. In fact, we could test it even on VMWare. However, we ran into trouble when some of the non-virtual test machines started displaying erratic auto-discovery behaviour - specifically, discoverable components would not be discovered, or if discovered would soon be spontaneously lost, etc.

Much testing and debugging followed before we narrowed down our problem to the fact that it happened only on multicore machines - Dell Latitude D620s in fact. On Dell Latitude D810s, or any other single core CPU, the applications behaved as expected .

Then we found that the BrowserApp that comes with the 1.0.3+ SDK samples, has similar erratic behaviour on the same machines - and in fact consistently refused to detect nodes on the network. And then most interestingly, we found that the dns-sd.exe program (written in C) based on the same low level libraries that the Java libraries depend on, works perfectly, irrespective of the CPU!!

This seemed to indicate that the Java code we had written modeled on Apple's sample code had inherited some problems from it. Eventually with some re-reading of their documentation and a better understanding of the event based API that Apple provides, we managed to rewrite our Java application so that it too worked as expected.

However, the whole experience suggests that chip manufacturers may be pushing software development to a whole new era of implicit multi-threading with a host of associated issues, that many software developers are just not ready for.

No comments: