[GHC] #10720: New GHC fails to specialize imported function

#10720: New GHC fails to specialize imported function -------------------------------------+------------------------------------- Reporter: wyager | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Keywords: | Operating System: MacOS X performance, inline, specialize | Architecture: x86_64 | Type of failure: Runtime (amd64) | performance bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- I just installed the new Haskell platform for OS X. It seems to have caused a major performance regression for a program I'm working on, making it well over 25x slower. The culprit appears to be that the new GHC (7.10.2) fails to specialize an imported function. If I manually add a SPECIALIZE pragma, performance goes back to around what it used to be. The code in question is located at https://github.com/wyager/HNet . As it stands, the code takes about 30 seconds to run on my machine. With the previous haskell-platform, it only took about .9 seconds. If I modify Operations.hs and uncomment the SPECIALIZE pragma, runtime goes down to about 1.1 seconds (still slower for some reason, but not awful). To test, compile with -O2 (as the program makes heavy use of Data.Vector, which requires -fspec-constr for performance). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10720 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10720: New GHC fails to specialize imported function -------------------------------------+------------------------------------- Reporter: wyager | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | performance, inline, specialize Operating System: MacOS X | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by wyager): Also see #10721 for a potentially related issue. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10720#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10720: New GHC fails to specialize imported function -------------------------------------+------------------------------------- Reporter: wyager | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: | Keywords: | performance, inline, specialize Operating System: MacOS X | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): I tried this. It's all behaving as advertised * You need an `INLINEABLE` pragma on `(**)`. * If you add that, then `(**)` is getting specialised perfectly well; but it calls `(*)`, which is not. * So you need an `INLINEABLE` pragma on `(*)` too. Admittedly this isn't terribly clear. I'll add some new warnings to point out that this might be happening. Meanwhile, you might just want to confirm that this is indeed ok for you. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10720#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10720: New GHC fails to specialize imported function
-------------------------------------+-------------------------------------
Reporter: wyager | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.10.2
Resolution: | Keywords:
| performance, inline, specialize
Operating System: MacOS X | Architecture: x86_64
Type of failure: Runtime | (amd64)
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#10720: New GHC fails to specialize imported function -------------------------------------+------------------------------------- Reporter: wyager | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: invalid | Keywords: | performance, inline, specialize Operating System: MacOS X | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: I'm going to close this as fixed, but please re-open if you disagree. Thank you for a nice test case that made it easy for me to figure out what was happening. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10720#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10720: New GHC fails to specialize imported function -------------------------------------+------------------------------------- Reporter: wyager | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: invalid | Keywords: | performance, inline, specialize Operating System: MacOS X | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by wyager): Thanks for the explanation. I am curious though; why is the specializing behavior different than it was in the previous Haskell-platform's GHC? Did it start to specialize less aggressively? Will -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10720#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10720: New GHC fails to specialize imported function -------------------------------------+------------------------------------- Reporter: wyager | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 Resolution: invalid | Keywords: | performance, inline, specialize Operating System: MacOS X | Architecture: x86_64 Type of failure: Runtime | (amd64) performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by simonpj): Replying to [comment:5 wyager]:
why is the specializing behavior different than it was in the previous Haskell-platform's GHC? Did it start to specialize less aggressively?
I'm afraid I don't know -- and I am reluctant to invest the time in finding out. But that shouldn't stand in the way of someone else looking. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10720#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC