On Mar 17, 2012, at 8:07 PM, Zane H. Healy wrote:
As a Mac user, it pains me to say this, but the
problem could simply
be that you're running it on Mac OS X. A few years ago someone did
some speed comparisons of Mac OS X, Linux, and Windows. While I
forget the specific's, it boiled down to the problem is the Mach
Micorkernel. Does anyone else remember this, and have any pointers
to the article, or more current testing on this?
This is a little late, but I recall testing some of my own code on
Linux vs. OS X (probably 10.4) and found that dynamic memory
allocation had a very high per-call overhead on OS X compared to Linux
because it went straight into a kernel call (ISTR Linux dumped at
least a portion of the allocation into userland, but it could have
been just that you weren't making a highly abstracted microkernel
call, which does carry a lot of overhead).
If you find (through profiling) that you're spending an ungodly amount
of time on malloc() calls, there are a few options:
- Try to do more malloc()s at startup instead of at run-time, if
it's possible; they'll be less noticed at startup.
- Pre-allocate a huge chunk of memory for your heap, then use your
own allocator (either write one or use nedmalloc, which is great).
This is typically how most games do it, because you can't rely on
malloc() to be speedy on any given OS (plus, for games, you can put
in all sorts of tags to see who allocated what so you can find
leaks more easily).
I've found every operating system slows down as time progresses. The
first iteration of Windows XP ran fine on a Pentium III. Update it to
Service Pack 3, though, and you have problems. Modern NetBSD is
painfully slow on what used to be "big iron" (my Power Mac 9500 with
gobs of RAM), and I imagine Linux is no picnic on it either. As for
OS X, 10.4.1 is quite speedy on my MDD G4, but the last version of
10.4 (whatever it is) was about half the speed.
The OS, however, will not slow *everything* down. Self-contained apps
that didn't do much interaction with the OS (e.g. I/O) didn't take much
of a hit. Apps bundled with and upgraded with the OS did, however.
What finally got intolerable for me with the MDD G4 was Safari and its
monotonically decreasing Javascript performance; Google Maps became
nearly unusable, and that was that.
- Dave