[GHC] #11725: Performance Regression from 7.8.3 to 7.10.3
GHC
ghc-devs at haskell.org
Sun Mar 20 08:13:00 UTC 2016
#11725: Performance Regression from 7.8.3 to 7.10.3
-------------------------------------+-------------------------------------
Reporter: dominic | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.3
Keywords: | Operating System: Linux
Architecture: | Type of failure: Runtime
Unknown/Multiple | performance bug
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Some time ago I wrote a little test program for random number generation.
Under 7.8.3 I get
{{{
Total time 9.03s ( 9.15s elapsed)
}}}
Under 7.10.3 I get
{{{
Total time 24.773s ( 25.288s elapsed)
}}}
Now of course it could be the libraries that I am using rather than GHC
itself so I have tried to make them as similar as possible. For 7.8.3 I
have
{{{
build-depends: base ==4.7.0.1,
mtl ==2.1.3.1,
primitive == 0.6,
mwc-random == 0.13.3.2,
vector == 0.10.12.3,
random ==1.1,
random-fu == 0.2.6.2,
random-source == 0.3.0.6
}}}
For 7.10.3 I have
{{{
build-depends: base ==4.8.2.0,
mtl ==2.2,
primitive == 0.6,
mwc-random == 0.13.3.2,
vector == 0.10.12.3,
random ==1.1,
random-fu == 0.2.6.2,
random-source == 0.3.0.6
}}}
So the only differences are in mtl and base. I don’t seem to be able to
coax cabal into using mtl-2.2 for 7.8.3 with all the other required
libraries.
{{{
dominic at ghcPerformance:~$ cabal install 'random-source ==0.3.0.6' 'random-
fu ==0.2.6.2' 'random ==1.1' 'primitive ==0.6' 'mwc-random ==0.13.3.2'
'mtl ==2.2' 'vector ==0.10.12.3' --with-ghc=ghc-7.10.3
Resolving dependencies...
All the requested packages are already installed:
mtl-2.2
mwc-random-0.13.3.2
primitive-0.6
random-1.1
random-fu-0.2.6.2
random-source-0.3.0.6
vector-0.10.12.3
Use --reinstall if you want to reinstall anyway.
dominic at ghcPerformance:~$ cabal install 'random-source ==0.3.0.6' 'random-
fu ==0.2.6.2' 'random ==1.1' 'primitive ==0.6' 'mwc-random ==0.13.3.2'
'mtl ==2.2' 'vector ==0.10.12.3' --with-ghc=ghc-7.8.3
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: random-source-0.3.0.6/installed-70e... (user goal)
next goal: mtl (user goal)
rejecting: mtl-2.2.1, 2.2.0.1 (global constraint requires ==2.2)
rejecting: mtl-2.2/installed-cc5..., 2.2 (conflict: random-source =>
mtl==2.1.3.1/installed-8bc...)
rejecting: mtl-2.1.3.1/installed-8bc..., 2.1.3.1, 2.1.2, 2.1.1, 2.1,
2.0.1.1,
2.0.1.0, 2.0.0.0, 1.1.1.1, 1.1.1.0, 1.1.0.2, 1.1.0.1, 1.1.0.0, 1.0 (global
constraint requires ==2.2)
Backjump limit reached (change with --max-backjumps).
}}}
Cabal seems to be telling me that random-source-0.3.0.6 is the problem but
if I look at the constraints for that package here
https://hackage.haskell.org/package/random-source then I see
{{{
mtl (>=1 && <3)
}}}
I am not sure how to proceed from here. I’d like to solve this myself but
I don’t want to start building versions of ghc to see which change caused
the regression without first eliminating mtl.
Any ideas would be gratefully received.
{{{
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE FlexibleInstances #-}
import Data.Random
import Data.Random.Source
import qualified System.Random.MWC as MWC
import Control.Monad.Reader
import Control.Monad.Primitive
$(monadRandom [d|
instance (PrimMonad m, s ~ PrimState m) => MonadRandom (ReaderT (MWC.Gen
s) m) where
getRandomWord16 = ask >>= lift . MWC.uniform
getRandomWord32 = ask >>= lift . MWC.uniform
getRandomWord64 = ask >>= lift . MWC.uniform
|])
testUniform :: MonadRandom m => Int -> m [Double]
testUniform n = replicateM (fromIntegral n) (sample stdUniform)
n :: Int
n = 10^7
main :: IO ()
main = do
seed <- MWC.create
xs <- runReaderT (testUniform n) seed
print (sum xs / fromIntegral n)
}}}
This cabal file will build this on 7.8.3
{{{
name: PerfTest8
version: 0.1.0.0
homepage: TBD
license: MIT
author: Dominic Steinitz
maintainer: idontgetoutmuch at gmail.com
category: System
build-type: Simple
cabal-version: >=1.10
executable Random8
main-is: TestMwcViaRandomSource.hs
build-depends: base ==4.7.0.1,
mtl ==2.1.3.1,
primitive == 0.6,
mwc-random == 0.13.3.2,
vector == 0.10.12.3,
random ==1.1,
random-fu == 0.2.6.2,
random-source == 0.3.0.6
default-language: Haskell2010
}}}
This cabal file will build this on 7.10.3
{{{
name: PerfTest10
version: 0.1.0.0
homepage: TBD
license: MIT
author: Dominic Steinitz
maintainer: idontgetoutmuch at gmail.com
category: System
build-type: Simple
cabal-version: >=1.10
executable Random10
main-is: TestMwcViaRandomSource.hs
build-depends: base ==4.8.2.0,
mtl ==2.2,
primitive == 0.6,
mwc-random == 0.13.3.2,
vector == 0.10.12.3,
random ==1.1,
random-fu == 0.2.6.2,
random-source == 0.3.0.6
default-language: Haskell2010
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11725>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list