
#10260: last uses too much space with optimizations disabled -------------------------------------+------------------------------------- Reporter: rwbarton | Owner: ekmett Type: bug | Status: new Priority: normal | Milestone: Component: Core Libraries | Version: 7.10.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Description changed by simonpj: Old description:
I know we don't worry too much about performance when optimizations are disabled, but `last [1..n]` using O(n) space when the naive definition would run in O(1) space is a bit too much I think.
Can we split out the new definition to a separate function and use a rule to rewrite `last` to that function when optimizations are enabled? I'm not expert enough on the use of rules and inlining phases etc. to write the patch myself, but I think it should be simple.
New description: I know we don't worry too much about performance when optimizations are disabled, but `last [1..n]` using O(n) space when the naive definition would run in O(1) space is a bit too much I think. Can we split out the new definition to a separate function and use a rule to rewrite `last` to that function when optimizations are enabled? I'm not expert enough on the use of rules and inlining phases etc. to write the patch myself, but I think it should be simple. This showed up when investigating #10247 -- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10260#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler