
On Mon, Apr 21, 2008 at 07:54:24PM +0100, Andrew Coppin wrote:
Useful references: "What Every Programmer Needs to Know About Memory" http://lwn.net/Articles/250967/ After studying all this material, I do find myself feeling slightly concerned. The article shows how in C / C++ / assembly you can arrange your data and order your computations to make maximum use of the various caches and avoid certain bottlenecks in the system. And the *vast* performance difference it can yield. But what happens if you happen to be writing your
Jim Snow wrote: program in Smalltalk or Java or... Haskell. Up here, you're so far from the hardware that it would seem that you have *no hope* of using the CPU caches effectively. Think about it - data scattered all over the heap in an essentially random pattern, getting moved around periodically by the GC. [Oh, the GC! That sounds like it must nail the hell out of the cache. And even if it doesn't, it more or less negates its usefulness because all the "hot" data is now at a different address.] Just think about trying to process a Haskell list - all those multiple levels of pointer indirection! The CPU has no hope of prefetching that stuff... Damn, it seems as if there's simply no way of ever making Haskell fast. :-(
You're assuming the hardware is constant. "Modern" CPUs were designed back when everyone was using C++; this is changing now, and I for one am still optimistic that CPU designs will follow suit. Stefan