[GHC] #8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion ------------------------------------+------------------------------------- Reporter: ion1 | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: libraries/random | Version: 7.6.3 Keywords: fusion | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #4218 | ------------------------------------+------------------------------------- randoms, randomRs could take advantage of list fusion. A commit is attached for consideration. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: Type: feature request | Status: patch Priority: normal | Milestone: Component: libraries/random | Version: 7.6.3 Resolution: | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Changes (by jstolarek): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: Type: feature request | Status: patch Priority: normal | Milestone: Component: libraries/random | Version: 7.6.3 Resolution: | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Comment (by nomeata): Thanks for the patch, ion1. Just checking: Did you make sure that the fusion works as desired, e.g. by writing a very small example and comparing the resulting Core before and after? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: Type: feature request | Status: patch Priority: normal | Milestone: Component: libraries/random | Version: 7.6.3 Resolution: | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Comment (by ion1): Yes, I tested with {{{ main = do { gen <- newStdGen; mapM_ print (randoms gen) } }}} which resulted in the list data structure being optimized away entirely (along with the pattern match for the empty case in `mapM_`). I got around to doing some benchmarking after posting the patch and I seem unable to come up with code for which `randoms` fusion makes a difference in performance, though. Unless someone else thinks of something I didn’t, this might not be worth it. The `seq` fix for part of #4218 can be done independently. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: Type: feature request | Status: patch Priority: normal | Milestone: Component: libraries/random | Version: 7.6.3 Resolution: | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Comment (by nomeata): Thanks. From my POV it is worth adding even if you can’t measure a performance gain; it is still good to know that nice code is being generated. But of course it is up to Ryan Newton (random maintainer) to decide this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: rrnewton Type: feature request | Status: patch Priority: normal | Milestone: Component: libraries/random | Version: 7.6.3 Resolution: | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Changes (by rrnewton): * owner: => rrnewton -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: rrnewton Type: feature request | Status: closed Priority: normal | Milestone: 7.8.4 Component: libraries/random | Version: 7.9 Resolution: fixed | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Changes (by thomie): * cc: rrnewton (added) * status: patch => closed * version: 7.6.3 => 7.9 * resolution: => fixed * milestone: => 7.8.4 Comment: This has been committed in [http://git.haskell.org/packages/random.git/commit/4695ffa366f659940369f05e41... 4695ffa366f659940369f05e419a4f2249c3a776]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion -------------------------------------+------------------------------------ Reporter: ion1 | Owner: rrnewton Type: feature request | Status: closed Priority: normal | Milestone: 7.10.1 Component: libraries/random | Version: 7.9 Resolution: fixed | Keywords: fusion Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #4218 -------------------------------------+------------------------------------ Changes (by thoughtpolice): * milestone: 7.8.4 => 7.10.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8704#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC