Opened 2 years ago

Closed 23 months ago

#7818 closed task (fixed)

Cost of STACK object should be attributed to CCCS at time of thread creation

Reported by: ezyang Owned by: ezyang
Priority: normal Milestone: 7.8.1
Component: Profiling Version: 7.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

Right now, we always charge STACK objects to the SYSTEM cost centre. I think it makes more sense for us to charge them to the CCCS responsible for creating the thread: it’s more specific and we don’t really lose anything in the trade (it’s easy to ask for a per-closure-type profile). Here’s a strawman patch (obviously this doesn’t do anything when not compiling the profiling way.) Are there any objections?

diff --git a/rts/Threads.c b/rts/Threads.c
index b617616..76ac705 100644
--- a/rts/Threads.c
+++ b/rts/Threads.c
@@ -84,7 +84,7 @@ createThread(Capability *cap, W_ size)
     stack_size = round_to_mblocks(size - sizeofW(StgTSO));
     stack = (StgStack *)allocate(cap, stack_size);
     TICK_ALLOC_STACK(stack_size);
-    SET_HDR(stack, &stg_STACK_info, CCS_SYSTEM);
+    SET_HDR(stack, &stg_STACK_info, cap->r.rCCCS);
     stack->stack_size   = stack_size - sizeofW(StgStack);
     stack->sp           = stack->stack + stack->stack_size;
     stack->dirty        = 1;
@@ -575,7 +575,11 @@ threadStackOverflow (Capability *cap, StgTSO *tso)
                   chunk_size * sizeof(W_));
 
     new_stack = (StgStack*) allocate(cap, chunk_size);
-    SET_HDR(new_stack, &stg_STACK_info, CCS_SYSTEM);
+#ifdef PROFILING
+    SET_HDR(new_stack, &stg_STACK_info, old_stack->header.prof.ccs);
+#else
+    SET_HDR(new_stack, &stg_STACK_info, CCCS_SYSTEM);
+#endif
     TICK_ALLOC_STACK(chunk_size);
 
     new_stack->dirty = 0; // begin clean, we'll mark it dirty below

Change History (4)

comment:1 Changed 23 months ago by simonpj

  • difficulty set to Unknown

No objections from me. If you don't hear from Simon in a few days, go ahead and commit. I'm sure you've thought about it mroe than anyone else! Thanks Edward.

Simon

comment:2 Changed 23 months ago by igloo

  • Milestone set to 7.8.1

comment:3 Changed 23 months ago by ezyang@…

commit 5724ea01c943bbc78b6c8b6bfa01a5d026d42f5a

Author: Edward Z. Yang <[email protected]>
Date:   Sun Apr 7 16:31:44 2013 -0700

    More accurate cost attribution for stacks.  Fixes #7818.
    
    Previously, stacks were always attributed to CCCS_SYSTEM.  Now, we
    attribute them to the CCS when the stack was allocated.  If a stack
    grows, new stack chunks inherit the CCS of the old stack.
    
    Signed-off-by: Edward Z. Yang <[email protected]>

 rts/Threads.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

comment:4 Changed 23 months ago by ezyang

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.