
we are writing a haskell program that does a calculation for an intranet application. We assume that at peak times, several thousand users are going to use the program at the same time. Our problem is, that our binary file has several MBs and we don't know how to compile it (we are using ghc 5.01) in a way, that all users can share ONE binary file in memory. If every user has one file, we would need several GBs of memory. At the moment we are using Microsoft Windows NT but planning to use Sun Solaris later. Every hint would be a big help,
Most operating systems, including Windows NT and Solaris, will share the text of a binary in memory between several invocations. Only the data section of the binary will be duplicated (and then only the pages that are actually modified). To get slightly better sharing performance you might want to statically link the binary - it'll already be statically linked against the Haskell libraries, but statically linking against the C libraries will mean that you dirty slightly fewer pages for each new instance of the running program. This is a tradeoff with shared libraries: shared libraries are good when lots of different binaries use the same library(*), but don't give you any benefit when you have many running instances of the same binary. (*) I've heard people argue that even in this case shared libraries aren't actually a win, so YMMV. Cheers, Simon