diff options
author | Simon Marlow <marlowsd@gmail.com> | 2016-12-15 11:17:19 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2016-12-15 11:17:29 -0500 |
commit | 394231b301efb6b56654b0a480ab794fe3b7e4db (patch) | |
tree | aae8fd1ee76ed8a06b9c87beb5dd2cb1aa8187e7 /compiler/codeGen/StgCmmClosure.hs | |
parent | 5c76f834b5b7f2ee9712d0888a8b1b186b77dee5 (diff) | |
download | haskell-394231b301efb6b56654b0a480ab794fe3b7e4db.tar.gz |
Fix cost-centre-stacks bug (#5654)
This fixes some cases of wrong stacks being generated by the profiler.
For background and details on the fix see
`Note [Evaluating functions with profiling]` in `rts/Apply.cmm`.
This does have an impact on allocations for some programs when
profiling. nofib results:
```
k-nucleotide +0.0% +8.8% +11.0% +11.0% 0.0%
puzzle +0.0% +12.5% 0.244 0.246 0.0%
typecheck 0.0% +8.7% +16.1% +16.2% 0.0%
------------------------------------------------------------------------
--------
Min -0.0% -0.0% -34.4% -35.5% -25.0%
Max +0.0% +12.5% +48.9% +49.4% +10.6%
Geometric Mean +0.0% +0.6% +2.0% +1.8% -0.3%
```
But runtimes don't seem to be affected much, and the examples I looked
at were completely legitimate. For example, in puzzle we have this:
```
position :: ItemType -> StateType -> BankType
position Bono = bonoPos
position Edge = edgePos
position Larry = larryPos
position Adam = adamPos
```
where the identifiers on the rhs are all record selectors. Previously
the profiler gave a stack that looked like
```
position
bonoPos
...
```
i.e. `bonoPos` was at the same level of the call stack as `position`,
but now it looks like
```
position
bonoPos
...
```
I used the normaliser from the testsuite to diff the profiling output
from other nofib programs and they all looked better.
Test Plan:
* the broken test passes
* validate
* compiled and ran all of nofib, measured perf, diff'd several .prof
files
Reviewers: niteria, erikd, austin, scpmw, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2804
GHC Trac Issues: #5654, #10007
Diffstat (limited to 'compiler/codeGen/StgCmmClosure.hs')
-rw-r--r-- | compiler/codeGen/StgCmmClosure.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs index 0ce119b0bb..1943dc4830 100644 --- a/compiler/codeGen/StgCmmClosure.hs +++ b/compiler/codeGen/StgCmmClosure.hs @@ -565,8 +565,10 @@ getCallMethod dflags _ id _ n_args v_args _cg_loc getCallMethod dflags name id (LFReEntrant _ _ arity _ _) n_args _v_args _cg_loc _self_loop_info - | n_args == 0 = ASSERT( arity /= 0 ) - ReturnIt -- No args at all + | n_args == 0 -- No args at all + && not (gopt Opt_SccProfilingOn dflags) + -- See Note [Evaluating functions with profiling] in rts/Apply.cmm + = ASSERT( arity /= 0 ) ReturnIt | n_args < arity = SlowCall -- Not enough args | otherwise = DirectEntry (enterIdLabel dflags name (idCafInfo id)) arity |