
#7818: Cost of STACK object should be attributed to CCCS at time of thread creation -----------------------------+---------------------------------------------- Reporter: ezyang | Owner: ezyang Type: task | Status: new Priority: normal | Component: Profiling Version: 7.7 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- 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 }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7818 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler