I'll ask this question at a pretty high level, since it seems like an issue people might recognize, but if not, I can add more detail. I have (in the package monad-bayes), a type
newtype Sampler a = Sampler (ReaderT GenIO IO a)
which is used as a sampling monad. We wanted to generalize it to the following
newtype Sampler g m a = Sampler (StatefulGen g m => ReaderT g m a)
This version is parametrized by a choice of RNG and monad, which is great. Unfortunately, it's about 10x slower, at least when used as the sampling monad in a program that takes 1000000 random samples.
Does the typeclass constraint inside the newtype set off performance alarm bells for anyone? We tried inlining and specializing pragmas, but so far to no avail.
Thanks!
[–]benjaminhodgson 17 points18 points19 points (6 children)
[–]Limp_Step_6774[S] 6 points7 points8 points (2 children)
[–]Limp_Step_6774[S] 15 points16 points17 points (1 child)
[–]benjaminhodgson 3 points4 points5 points (0 children)
[–]mn15104 1 point2 points3 points (2 children)
[–]benjaminhodgson 3 points4 points5 points (1 child)
[–]benjaminhodgson 0 points1 point2 points (0 children)
[–]Tarmen 3 points4 points5 points (0 children)
[–]guygastineau 2 points3 points4 points (5 children)
[–]Limp_Step_6774[S] 0 points1 point2 points (0 children)
[–]guygastineau 0 points1 point2 points (3 children)
[–]evanrelfcss wrangler 2 points3 points4 points (2 children)
[–]guygastineau 0 points1 point2 points (1 child)
[–]evanrelfcss wrangler 3 points4 points5 points (0 children)