
#14035: Weird performance results. -------------------------------------+------------------------------------- Reporter: danilo2 | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Compiler | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by danilo2): One more important thing to note here is that the provided code was shortened to the limits. It does not use the `XBool` value in any place (it puts `-XFalse` everywhere, even after successful parse). It implies that the problem (2a) is also not very important - it is just an optimization opportunity in a very special and rare use case. We can easily fix the code and make it a real use case by inserting the following code: {{{#!hs class Monad m => ProgressMonad m where returnProgressed :: forall a. a -> m a instance {-# OVERLAPPABLE #-} (ProgressMonad m, Monad (t m), MonadTrans t) => ProgressMonad (t m) where returnProgressed = lift . returnProgressed ; {-# INLINE returnProgressed #-} instance Monad m => ProgressMonad (FailParser m) where returnProgressed a = failParser $ return $ Right $ T XTrue a ; {-# INLINE returnProgressed #-} }}} and replacing the line 125 to: {{{#!hs Just (!t, !s') -> if t == 'a' then put s' >> returnProgressed t else failed }}} The `XBool` value would then be used to implement `Alternative` instance, but we do not need it here. We can observe the same slowdown (`10^6` chars parsed in 15ms with `-XStrict` enabled). Which is expected, based on the results so far, however if we want to base on a real use case, this code help us transform abstract program to real one. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14035#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler