#7258: Compiling DynFlags is jolly slow -------------------------------------+------------------------------------- Reporter: simonpj | Owner: simonpj Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Resolution: | Keywords: deriving-perf Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by alexbiehl): Replying to [comment:66 simonpj]:
What about using a different kind of data structure like a map or similar
Of course that the first thing we should do, once we are convinced that's where the time is going! (We only ave suggestive evidence so far.) Small maps should be cheap; that's the business of the containers library.
`LocalReg` is `Uniquable` so something like this should work: {{{ type LocalRegSet = UniqSet LocalReg emptyLocalRegSet :: LocalRegSet emptyLocalRegSet = emptyUniqSet nullLocalRegSet :: LocalRegSet -> Bool nullLocalRegSet = isEmptyUniqSet elemLocalRegSet :: LocalReg -> LocalRegSet -> Bool elemLocalRegSet = elementOfUniqSet insertLocalRegSet :: LocalRegSet -> LocalReg -> LocalRegSet insertLocalRegSet = addOneToUniqSet cannot_inline = skipped `regsUsedIn` rhs -- Note [dependent assignments] || l `elemLocalRegSet` skipped || not (okToInline dflags rhs node) regsUsedIn :: LocalRegSet -> CmmExpr -> Bool regsUsedIn ls _ | nullLocalRegSet ls = False regsUsedIn ls e = wrapRecExpf f e False where f (CmmReg (CmmLocal l)) _ | l `elemLocalRegSet` ls = True f (CmmRegOff (CmmLocal l) _) _ | l `elemLocalRegSet` ls = True f _ z = z }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7258#comment:67> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler