[GHC] #9798: Frustrating behaviour of the INLINE pragma

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: Runtime Difficulty: Unknown | performance bug Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- So I have a function "a", which uses another function "b" from another module. * Step 1. I benchmark its performance and get 250ns. * Step 2. I go and put the "INLINE" pragma on the function "b", run the benchmark again and get 500ns. That is twice as long. * Step 3. I go and add an explicit invocation of the [http://hackage.haskell.org/package/base-4.7.0.1/docs/GHC- Exts.html#v:inline inline] function over function "b" in function "a" and finally get the desired optimization: 208ns. You can reproduce the issue by executing {{{cabal bench decoding --benchmark-options=numeric}}} after cloning the trees of the following commits: * [https://github.com/nikita-volkov/postgresql- binary/commit/31e08b4f6887445c28118d25f9da808e7ca9fc86 Step 1] * [https://github.com/nikita-volkov/postgresql- binary/commit/8f29b8daebc3161dc0fa35fbd70d3f3305370a4e Step 2] * [https://github.com/nikita-volkov/postgresql- binary/commit/3d3e4378bcd8ea85cda868d6a4bf07a76a9cad2c Step 3] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): I can see that is frustrating. There are a lot of dependencies here. (Though, happily, I believe that one can run your benchmark without having any C stuff installed eg postgres. Is that right?) But still, there's a lot of stuff. Could you * compile just the offending module (which is `Decoder.hs` I think), * on its own, * preferably with only the definition for `numeric` (which is the offending one I think) * with the extra flags `-dverbose-core2core -ddump-inlinings` and save the three results for Step 1/2/3 attached to this ticket? That would mean I could take a look without reproducing the setup. Another thing that would be revealing would be to add `-ticky` to the command line when compiling; and `+RTS -rstep1.ticky` to the command line when running. And then add the `.ticky` files to the ticket. That should show up where the performance differences are occurring without affecting anything. Thanks Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mojojojo):
I believe that one can run your benchmark without having any C stuff installed eg postgres. Is that right?
Yes. Only Haskell dependencies in the benchmark build target.
But still, there's a lot of stuff.
I'll try to approach this some time soon. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mojojojo): I've narrowed the code down as much as possible and [https://github.com /nikita-volkov/postgresql-binary/tree/ghc-issue-9798 published it in a dedicated branch]. You'll find that latest commits reproduce the issue in the narrowed down code step by step. Also you'll find the according dumps and ticky reports attached to this issue. I've generated them by passing the according GHC and runtime flags to Cabal, I hope this doesn't matter. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by simonpj): Did you use `-ddump-inlinings`? Could you add `-ddump-occur-anal -ddump- stg`. Can you combine stdout and stderr together? I'm not sure which is which, because directory `step2/` contains files labelled `step3` and vice versa! Since you are zipping, you could bundle all three in one. Thanks! As you'll see, the ticky numbers are revealing. But it looks as if step1 allocates least. Is step3 really faster? Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mojojojo): I actually tried to upload it as a single archive, only to find out that you have a limit of 250KB for a single upload here. So I might have messed up with the archive titles later, the dump and picky files though should have been correct. Concerning your request I'll try to post back with updates soon. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mojojojo): I bet it won't be a problem for you to inspect the problem yourself now though, since the codebase is quite narrowed down now: https://github.com/nikita-volkov/postgresql-binary/tree/ghc-issue-9798 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: Runtime | Difficulty: Unknown performance bug | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Comment (by mojojojo): I've ran this thing with the new flags and capturing stderr too. You'll find the files in the root of the tree on the same branch: https://github.com/nikita-volkov/postgresql-binary/tree/ghc-issue-9798 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: | Architecture: Unknown/Multiple Unknown/Multiple | Difficulty: Unknown Type of failure: Runtime | Blocked By: performance bug | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * os: MacOS X => Unknown/Multiple * architecture: x86_64 (amd64) => Unknown/Multiple -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9798: Frustrating behaviour of the INLINE pragma -------------------------------------+------------------------------------- Reporter: mojojojo | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Inlining Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by mpickering): * keywords: => Inlining -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9798#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC