Reputation: 361732
I'm implementing RayTracingInOneWeekend and I optimized it from 33m
to 23s
for image size 384x216
scene and the parameters as given in the article. However, when I profile it, the entries
(the 5th column from the left in the screenshot below) changes on almost every run. How is that possible? In my program everything stays same, including even the random number generators, as generators are created as (you can see it on github):
g = mkStdGen (i * width + j)
If width
and height
stay same, then all g
(one for each pixel) should stay same as well. However, as you can see the two screenshots have different values in the entries
column.
What could be the reason behind this impurity? Or the profiler is not just able to gather all the information and the numbers are not exact (means, in reality the frequency of function calls are different from the numbers shown above; the docs however does not say anything like that).
My program builds with cabal v2-build -O2 --enable-profiling --enable-executable-profiling
and I dont pass -prof -fprof-auto
to ghc-options
(I guess cabal
takes care of that). I've also used -threaded
and parallel
library.
I'm on GHC 8.6.5 and Cabal 3.2.
Upvotes: 1
Views: 81
Reputation: 361732
It looks like, the profiler in multi-core mode does not run consistently — not sure if that counts as bug. I ran the program couple of times without passing -N
to RTS
and now every time I see the same entries
count:
Not sure if that proves that my program does not have any impurity. I'm stil looking for better and more plausible response (if there is any, at all).
Upvotes: 1