Change in specialisation(?) behaviour since 8.0.2 causes 6x slowdown
I was investigating some benchmarks and I noticed some odd results if I duplicated one of my tests.
Looking at the core, it seems that repeating the definition means that one of the key functions doesn't get specialised as expected which leads to a much slower program.
Observe that in the first two benchmarks there is a worker function
go :: Int# -> Int -> ReaderT Int (StateT Int Identity Int but in the third benchmark this is specialised to
$sgo :: Int# -> Int -> Int -> Int# -> Int# -> Identity (Int, Int). Removing the duplicate benchmark means that specialisation happens properly in the first case as well.
The proper specialisation also happens in 8.0.2.
This causes the first two cases to be 6x slower than the last case.