Ticket #2297 (new bug)

Opened 7 months ago

Last modified 4 days ago

Profiler is inconsistent about biography for GHC's heap

Reported by: igloo Assigned to:
Priority: normal Milestone: 6.10.2
Component: Profiling Version: 6.9
Severity: normal Keywords:
Cc: Difficulty: Unknown
Test Case: Operating System: Unknown/Multiple
Architecture: Unknown/Multiple

Description

My slightly modified rnBind has this clause (i is an Int):

rnBind sig_fn
       trim
       i
       (L loc (FunBind { fun_id = name, 
                         fun_infix = inf, 
                         fun_matches = matches,
                         -- no pattern FVs
                         bind_fvs = _
                       }))
       -- invariant: no free vars here when it's a FunBind
  = i `seq` setSrcSpan loc $
    do  { let plain_name = unLoc name

    ; (matches', fvs) <- bindSigTyVarsFV (sig_fn plain_name) $
                -- bindSigTyVars tests for Opt_ScopedTyVars
                 rnMatchGroup (FunRhs plain_name inf) matches

    ; checkPrecMatch inf plain_name matches'

    ; return
        (L loc (trace ("Using FunBind for " ++ show i)
                (FunBind { fun_id = name, 
                                  fun_infix = inf, 
                                  fun_matches = matches',
                     bind_fvs = trim fvs, 
                                  fun_co_fn = idHsWrapper, 
                                  fun_tick = Nothing })),
          [plain_name],
          fvs)
      }

If I comment out the trace and run

ghc --make J -fforce-recomp +RTS -p -hcrnBind -hyHsBindLR -hb

then I get notrace.png, all VOID. However, with the trace I get trace.png, LAG turning into DRAG. The two graphs are also a slightly different shape, which is curious.

Also attached is the core for with and without the tracing. I think the only interesting difference is

-      a30_ [ALWAYS Just L] :: NameSet.FreeVars
+      a30_ [ALWAYS Just L] :: HsBinds.HsBindLR Name.Name Name.Name
       [Str: DmdType]
-      a30_ = w1_ ww3_ } in
-    let {
-      a31_ :: HsBinds.HsWrapper
-      []
-      a31_ =
-        __scc {rnBind ghc-6.9.20080517:RnBinds !}
-        __scc {idHsWrapper ghc-6.9.20080517:HsBinds} HsBinds.WpHole } in
-    let {
-      a32_ :: HsBinds.HsWrapper
-      []
-      a32_ =
-        __scc {rnBind ghc-6.9.20080517:RnBinds !}
-        __scc {idHsWrapper ghc-6.9.20080517:HsBinds} HsBinds.WpHole } in
-    let {
-      a33_ :: HsBinds.HsBindLR Name.Name Name.Name
-      [Str: DmdType]
-      a33_ =
-        HsBinds.FunBind
-          @ Name.Name
-          @ Name.Name
-          name_
-          inf_
-          ww2_
-          a32_
-          a30_
-          (Data.Maybe.Nothing @ (GHC.Base.Int, [Name.Name])) } in
+      a30_ =
+        Debug.Trace.trace
+          @ (HsBinds.HsBindLR Name.Name Name.Name)
+          lvl45_
+          (HsBinds.FunBind
+             @ Name.Name
+             @ Name.Name
+             name_
+             inf_
+             ww2_
+             (__scc {rnBind ghc-6.9.20080517:RnBinds !}
+              __scc {idHsWrapper ghc-6.9.20080517:HsBinds} HsBinds.WpHole)
+             (w1_ ww3_)
+             (Data.Maybe.Nothing @ (GHC.Base.Int, [Name.Name]))) } in

Attachments

notrace.png (11.5 kB) - added by igloo on 05/19/08 18:09:30.
trace.png (17.7 kB) - added by igloo on 05/19/08 18:09:43.
notrace.core.gz (38.1 kB) - added by igloo on 05/19/08 18:11:16.
trace.core.gz (38.2 kB) - added by igloo on 05/19/08 18:11:25.
J.hs (173.7 kB) - added by igloo on 06/13/08 11:09:23.

Change History

05/19/08 18:09:30 changed by igloo

  • attachment notrace.png added.

05/19/08 18:09:43 changed by igloo

  • attachment trace.png added.

05/19/08 18:11:16 changed by igloo

  • attachment notrace.core.gz added.

05/19/08 18:11:25 changed by igloo

  • attachment trace.core.gz added.

05/19/08 18:16:30 changed by igloo

In case this doesn't get sorted soon, I think these are all the relevant changes I've made:

hunk ./compiler/rename/RnBinds.lhs 40
-import Digraph         ( SCC(..), stronglyConnComp )
+import Digraph
hunk ./compiler/rename/RnBinds.lhs 45
-import Util            ( filterOut )
-import Monad           ( foldM, unless )
+import Util
+import Monad
+import Control.Exception
+import Debug.Trace
hunk ./compiler/rename/RnBinds.lhs 321
-   binds_w_dus <- mapBagM (rnBind (mkSigTvFn sigs') trim) mbinds
+   xs <- zipWithM (rnBind (mkSigTvFn sigs') trim) [1..] (bagToList mbinds)
+   let binds_w_dus = listToBag xs
hunk ./compiler/rename/RnBinds.lhs 498
+       -> Int
hunk ./compiler/rename/RnBinds.lhs 501
-rnBind _ trim (L loc (PatBind { pat_lhs = pat,
-                                pat_rhs = grhss,
-                                -- pat fvs were stored here while
-                                -- processing the LHS
-                                bind_fvs=pat_fvs }))
+rnBind _ trim i (L loc (PatBind { pat_lhs = pat,
+                                  pat_rhs = grhss,
+                                  -- pat fvs were stored here while
+                                  -- processing the LHS
+                                  bind_fvs=pat_fvs }))
hunk ./compiler/rename/RnBinds.lhs 519
-       trim
+       trim
+       i
hunk ./compiler/rename/RnBinds.lhs 528
-  = setSrcSpan loc $
+  = i `seq` setSrcSpan loc $
hunk ./compiler/rename/RnBinds.lhs 537
-       ; return (L loc (FunBind { fun_id = name,
+       ; return
+        (L loc (trace ("Using FunBind for " ++ show i)
+                (FunBind { fun_id = name,
hunk ./compiler/rename/RnBinds.lhs 544
-                                  fun_tick = Nothing }),
+                                  fun_tick = Nothing })),
hunk ./compiler/rename/RnBinds.lhs 549
-rnBind _ _ b = pprPanic "rnBind" (ppr b)
+rnBind _ _ _ b = pprPanic "rnBind" (ppr b)

06/13/08 11:09:23 changed by igloo

  • attachment J.hs added.

06/13/08 12:10:52 changed by igloo

  • priority changed from normal to high.

07/14/08 07:09:05 changed by simonmar

  • milestone changed from 6.10 branch to 6.10.1.

Needed for further profiling of GHC, we should investigate for 6.10.1 if possible.

09/30/08 08:37:12 changed by simonmar

  • architecture changed from Unknown to Unknown/Multiple.

09/30/08 08:50:55 changed by simonmar

  • os changed from Unknown to Unknown/Multiple.

10/04/08 04:39:27 changed by igloo

  • milestone changed from 6.10.1 to 6.10.2.

12/01/08 02:10:54 changed by simonpj

  • priority changed from high to normal.

Decreasing priority. (High cost-to-benefit ratio!) Simon & Simon