Thursday, March 30, 2006

Multitasking on MacIntel fails in presence of bugs

Right at the moment (as you may have learnt from some of my previous posts) I'm working on numerical libraries. I'm developing a (hopefully) efficient version of the aks algorithm to test primality.

I'm not here to describe AKS, nor to describe multitasking or any particular algorithm. It is sufficient to say that they are programs that make extensive use of the CPU.

On my old Powerbook G4 when I run a CPU expensive task the GUI keeps responding. Of course the task uses a lot of CPU: opening a new application takes more time, and so other tasks do. However applications respond as usual. The computer is noy "hung".

This is one of the things I love more of MacOS. The system remains usable even if under heavy stress. This is no longer true. My brand new iMac Core Duo simply becomes unusable. Applications do not respond (they reaction time can be counted in tens of seconds). This is plainly unacceptable. Of course this does not happen normally: it happens only with some software (and buggy software). However the very same program does not create problems on my Powerbook (the machine slows but remains usable).

This makes me think there is something in the scheduler that just does not work as expected and is fooled by some bugs in the software.

I want to make clear that well written software has't this problem. I can run heavy compilations and have the CPU (both cores) 100% and the system is responsive as usual. It gets stuck when something goes wrong.

The software that hung the mac had bugs (it's iper-alpha and I'm still working on it). But while the old MacOS X PPC responded to me relatively quickly (allowing me for example to kill the bugged software), the new MacOS X Intel seems to prefer letting the bugged software finish. The point is that those bug should not slow the system to that point (and in fact the PowerBook wasn't slowed): they were just a couple of memory leaks.

Now I'm trying to develop a software that has the similar behaviour to the one I'm writing (that is to say uses lots of memory, lots of computation and lots of logging -> I/O), to see what of the three things that stresses more the system. Appearently it is memory.

edit: I just wrote a heavy computation/loging software. This has no troubles at all. You can read what does it do here
Anyway sorry for being allarmistic. I'm trying to figure out what the problem is.

No comments: