Notice here that we pass the f flag to the -l. This means that in addition to the events collected by default [(s)cheduler, (g)arbage collector, and s(p)ark events], we also want to collect the (f)ull details for par spark events. See the list of event flags for details.

-lf not recognised? Your GHC is not recent enough

Have a look at the activity profile. What problems do you see?

Some issues you may notice

We are only get half the activity possible from our CPUs

Most of work by HEC 1 after a while

There is also some 'stutter' and interruption for garbage collection (orange)

We know now what some problems are, eg. only one CPU doing any work. Now how do we figure out what we have these problems?

Enable the spark creation and conversion traces

Scroll down to view these traces (shrink the bottom drawer if you need more room). What do you see?

HINT: Remember that the spark creation/conversion graphs represent /rates/ (sparks per ms) and not /quantity/

The creation charts show that a large proportion of attempted sparks overflow. They are not created because of spark pools are full. (It may be useful to have a look at the spark lifecycle if you have not done so already).

Study the parListWHNF function; it sparks the entire list off in parallel, all 100 thousand fibonnaci computations. Maybe we need to generate sparks a little less aggressively.

2.2 Throttling spark creation (parlist1)

Build and run the somewhat revised parlist1 example.

./parlist1 +RTS -N2 -lf
threadscope parlist1.eventlog

Have a look at the activity log. Notice any changes?

We're getting a bit more use out of that second core now, and seem to be using both of them throughout the life of the program.

What's changed? We have swapped out the parallel-everything strategy with a rolling buffer one which creates sparks in such a way that only a buffer-full are in the pool at any time. The list elements are all still evaluated in parallel, but the creation of sparks is throttled by a cunning bit of sequentialness that waits for each successive element of the list to be evaluated (to WHNF) before creating more sparks.