
Hello,
I wanted to use nhc to profile a simple program but ran into a string of
errors. The example I present here is one of four small programs I have played
with. This example is from nhc98-1.18 compilied from source, I have played with
the 1.18 and 1.16 binary versions also. I'm using debian 3. The program is:
#####################strict.hs
module Main where
foldl' f e [] = e
foldl' f e (x:xs) = (foldl' f $! f e x) xs
main = print $ foldl' (+) 0 [1..1000]
{-main = print $ foldr (+) 0 [1..1000]-}
#####################strict.hs
With the aim of showing strict.hs would run in constant space as compared to
the commented out version. I compilied and ran the program thus (I know I can
use hmake instead):
$ nhc98 -p -o strict strict.hs
$ ./strict +RTS -p -i25kb -RTS
500500
$ hp2graph strict.hp
Illegal token JOB at 69
Aborted
This is the most common error encountered. Try again:
$ ./strict +RTS -p -i24kb -RTS
500500
$ hp2graph strict.hp
Segmentation fault
Segmentation faults are the second most common error. It is also possible for
hp2graph to run without error but it produces invalid postscript that cannot
be viewed. Here are the strict.hp files from each run:
#####################strict 25kb interval
JOB ./strict +RTS -p -i25kb -RTS ;
DATE "Tue May 10 21:45:49 2005
"
PROFILE_PRODUCER
MARK 0.00
SAMPLE 0 0.00
344
<APPLY> 72
<Main> 8
Builtin.primIntFromInteger 8
Prelude.primIntegerAdd 8
;
MARK 0.00
SAMPLE 1 0.00
356

Benjamin,
$ ./strict +RTS -p -i25kb -RTS 500500
$ hp2graph strict.hp Illegal token JOB at 69 Aborted
I believe the problem here is that "producer" profiling (the -p runtime option) seems to be slightly broken at the moment. I discovered this a few days ago myself. For instance, in your output .hp file, you see
SAMPLE 1 0.00 356
8 <APPLY> 80 <Main> 8 Builtin.primIntFromInteger 8 Prelude.primIntegerAdd 8 ;
but the first line following "SAMPLE" has no symbol name, just a count! (356). For some reason, the first producer symbol is being rendered as a blank, which confuses the parser in hp2graph.
What am I doing wrong, some option perhaps?
Until we fix this bug, I suggest that you avoid producer profiles and use only the other kinds - construction (-c), retainer (-r) and biographical (-b). Regards, Malcolm
participants (2)
-
Benjamin Fraser
-
Malcolm Wallace