[GHC] #10007: Fix misattribution of Cost Centre profiles to lintAnnots

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: | Owner: scpmw thoughtpolice | Status: new Type: bug | Milestone: 7.10.1 Priority: high | Version: 7.10.1-rc1 Component: Profiling | Operating System: Unknown/Multiple Keywords: | Type of failure: Incorrect result Architecture: | at runtime Unknown/Multiple | Blocked By: Test Case: | Related Tickets: #9961 Blocking: | Differential Revisions: Phab:D616 | -------------------------------------+------------------------------------- Split off from #9961 - the profiling results while debugging erroneously reported that most cost centre profiles were a result of `lintAnnots`, as opposed to `CSE`. This is a bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Changes (by simonmar): * differential: Phab:D616 => Phab:D616 Phab:D636 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots
-------------------------------------+-------------------------------------
Reporter: thoughtpolice | Owner: scpmw
Type: bug | Status: new
Priority: high | Milestone: 7.10.1
Component: Profiling | Version: 7.10.1-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: #9961 | Differential Revisions: Phab:D616
| Phab:D636
-------------------------------------+-------------------------------------
Comment (by Simon Marlow

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: merge Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Changes (by hvr): * status: new => merge Comment: ...I assume this is to be merged to 7.10? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: merge Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by scpmw): Well, it's the wrong fix, as far as I'm concerned. Yes, it fixes the erroneous attribution to `lintAnnots`, but only because we change the program's (RTS) cost semantics twice during optimisations, with both instances un-doing each other. This is not guaranteed, see the new test case for `D616`. I also didn't feel it would help the discussion to mention this - but this also doesn't fix rather silly double-annotations on parameters, which (I think) only don't appear because we automatically eliminate repeating cost centres in stacks. If needed, I could produce another test case that demonstrates that. Short version: This is only a band-aid. And as far as those go, I would still prefer `D616`. At least until I have figured out how to *actually* implement `Eval2`, which would fix the whole situation from the RTS end. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: merge Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by simonmar): I respectfully disagree that is is a band-aid. It is not a complete fix, but it does fix a regression since 7.8, so it should definitely go into 7.10. I'll continue to discuss the larger issue on D616. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: closed Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-7.10` (via 1d401b4384b5f9c7429140320e1d0bc120172b8b). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Changes (by simonpj): * owner: scpmw => * status: closed => new * resolution: fixed => Comment: Lots of cost is still attributed to `lintAnnots`, so the original problem doesn't seem to be fixed. So I'll re-open. Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: Type: bug | Status: new Priority: high | Milestone: 7.10.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by scpmw): Yes - I investigated this again a month ago, and found that SM's fix didn't correct the whole problem. In fact, if I remember correctly what we end up with is something like {{{ case scctick<SpecConstr> specConstrProgram of ... }}} In this situation the tick will fail to actually capture any cost in `specConstrProgram`, which will instead end up in the cost-centre next in the hierarchy, which happens to be `lintAnnots` (`Core2Core` before). As explained in D616 and #5654, this is a fairly fundamental problem: GHC simply doesn't implement the cost-centre semantics for function values correctly. Correcting this isn't exactly easy - I have been experimenting in the past weeks, and the best solution I can come up with (still?) involves a new closure type that wraps function values when they escape cost-centre scopes. Two possible solutions here: We could attempt another stopgap measure. For example, the above code should probably in-line as it is only used once. Building the full solution will still need a bit more tinkering, but I might be able to make a proposal soon-ish (... just need to get it to stop crashing. Seems getting register saving right can be surprisingly tricky). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Changes (by bgamari): * cc: bgamari (added) * owner: => scpmw * milestone: 7.10.1 => 7.10.3 Comment: Thanks for the update! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by simonpj): Try the effect of changing (in `SimplCore`): {{{ ; guts' <- lintAnnots (ppr pass) (doCorePass pass) guts }}} to {{{ ; guts' <- lintAnnots (ppr pass) (\p -> doCorePass pass p) guts }}} Simon M speculates that this might work around the problem. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by scpmw): Unfortunately, I am pretty sure I tested that - and it doesn't work. The easiest workaround is updating all `doCorePass` equations as follows: {{{ doCorePass pass@(CoreDoSimplify {}) guts = {-# SCC "Simplify" #-} simplifyPgm pass guts }}} Which avoids this problem by not putting the SCC on a function-type value. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by bgamari): scpmw, I've tested Simon's suggestion on `master` and it appears to work for me. Costs are correctly attributed to cost-centers beneath `lintAnnots`. I'll be merging this to `master`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by scpmw): Interesting. I checked, and the code I used to reproduce the problem was exactly what simonpj suggested, but with an extra SCC on the `doCorePass` call. That way, I could catch exactly the "leaking" costs. Maybe that annotation also changed the compiler behaviour sufficiently to stop this from working. Anyway, all the better. Maybe we should close this ticket then, and continue the discussion of the larger issue in #5654? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961 | Differential Revisions: Phab:D616 | Phab:D636 -------------------------------------+------------------------------------- Comment (by bgamari): Hmm, actually it seems that `master` is now doing the right thing even without my patch. I am quite confused. I'll return to this after the release. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 7.10.3 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616 Wiki Page: | Phab:D636 -------------------------------------+------------------------------------- Changes (by bgamari): * related: #9961 => #9961,#5654 Comment: This may be related to #5654. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616 Wiki Page: | Phab:D636 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 7.10.3 => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 8.4.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616 Wiki Page: | Phab:D636 -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: 8.2.1 => 8.4.1 Comment: This won't be happening for 8.2 either, sadly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: scpmw Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616 Wiki Page: | Phab:D636 -------------------------------------+------------------------------------- Changes (by simonmar): * milestone: 8.4.1 => 8.2.1 Comment: As it happens, I was just working on this! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: simonmar Type: bug | Status: new Priority: high | Milestone: 8.2.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616 Wiki Page: | Phab:D636 -------------------------------------+------------------------------------- Changes (by simonmar): * owner: scpmw => simonmar -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:19 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10007: Fix misattribution of Cost Centre profiles to lintAnnots
-------------------------------------+-------------------------------------
Reporter: thoughtpolice | Owner: simonmar
Type: bug | Status: new
Priority: high | Milestone: 8.2.1
Component: Profiling | Version: 7.10.1-rc1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616
Wiki Page: | Phab:D636
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#10007: Fix misattribution of Cost Centre profiles to lintAnnots -------------------------------------+------------------------------------- Reporter: thoughtpolice | Owner: simonmar Type: bug | Status: closed Priority: high | Milestone: 8.2.1 Component: Profiling | Version: 7.10.1-rc1 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: #9961,#5654 | Differential Rev(s): Phab:D616 Wiki Page: | Phab:D636 -------------------------------------+------------------------------------- Changes (by simonmar): * status: new => closed * resolution: => fixed Comment: Optimistically closing as fixed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10007#comment:21 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC