[Shootout-list] Process Creation - useless test output
Tomasz Zielonka
t.zielonka@students.mimuw.edu.pl
Mon, 4 Oct 2004 23:00:23 +0200
On Mon, Oct 04, 2004 at 09:22:42AM -0700, Isaac Gouy wrote:
> > we are not interested in the value of
> > creating processes, but the cost.
>
> We are interested in whether the process was really created.
> A useful test output would be the number of processes that have been
> created - not the number of calls that have been made to create a process.
BTW. As far as I understand the benchmark description, the ghc
implementation seems to be cheating. It creates all the processes, but
they are quickly killed with BlockedOnDeadMVar exception, because RTS
sees that the are waiting on MVars which can't be filled by anyone.
One solution is to use the same MVar for all processes:
import Control.Concurrent
import Control.Monad
import System
procinst v = forkIO (takeMVar v)
main = do [num] <- getArgs
v <- newEmptyMVar
replicateM_ (read num) (procinst v)
putStrLn num
Of course the time and memory use will go up drastically.
However, there are some RTS options which greatly improve performance.
The program has to be run this way:
./procinst N +RTS -A20m -k256
With this options the program runs even 200 times faster than without
them !?! :-/
But I don't know if it legal here...
Best,
regards
--
.signature: Too many levels of symbolic links