diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2020-11-18 11:23:00 +0000 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2021-02-02 08:57:07 +0000 |
commit | 4eefc5ed13148cbaf8376b3ba0c1c23572bba961 (patch) | |
tree | e08f43f99a4b66edfc07217643d013f5c20e170e | |
parent | baff2bc47d62a797574ccce79f6fd67f94aa76ef (diff) | |
download | haskell-4eefc5ed13148cbaf8376b3ba0c1c23572bba961.tar.gz |
Profiling by info table mode (-hi)
This profiling mode creates bands by the address of the info table for
each closure. This provides a much more fine-grained profiling output
than any of the other profiling modes.
The `-hi` profiling mode does not require a profiling build.
-rw-r--r-- | docs/users_guide/profiling.rst | 5 | ||||
-rw-r--r-- | includes/rts/EventLogFormat.h | 3 | ||||
-rw-r--r-- | includes/rts/Flags.h | 11 | ||||
-rw-r--r-- | libraries/base/GHC/RTS/Flags.hsc | 3 | ||||
-rw-r--r-- | rts/ProfHeap.c | 9 | ||||
-rw-r--r-- | rts/RtsFlags.c | 8 | ||||
-rw-r--r-- | rts/eventlog/EventLog.c | 2 |
7 files changed, 35 insertions, 6 deletions
diff --git a/docs/users_guide/profiling.rst b/docs/users_guide/profiling.rst index 2463654837..8e2050d5fb 100644 --- a/docs/users_guide/profiling.rst +++ b/docs/users_guide/profiling.rst @@ -800,6 +800,11 @@ following RTS options select which break-down to use: Biographical profiling is described in more detail below (:ref:`biography-prof`). +.. rts-flag:: -hi + + Break down the graph by the address of the info table of a closure. This + profiling mode is intended to be used with :ghc-flag:`-finfo-table-map`. + .. rts-flag:: -l :noindex: diff --git a/includes/rts/EventLogFormat.h b/includes/rts/EventLogFormat.h index 340a12d4e9..4b50adfe5b 100644 --- a/includes/rts/EventLogFormat.h +++ b/includes/rts/EventLogFormat.h @@ -221,7 +221,8 @@ typedef enum { HEAP_PROF_BREAKDOWN_TYPE_DESCR, HEAP_PROF_BREAKDOWN_RETAINER, HEAP_PROF_BREAKDOWN_BIOGRAPHY, - HEAP_PROF_BREAKDOWN_CLOSURE_TYPE + HEAP_PROF_BREAKDOWN_CLOSURE_TYPE, + HEAP_PROF_BREAKDOWN_INFO_TABLE } HeapProfBreakdown; #if !defined(EVENTLOG_CONSTANTS_ONLY) diff --git a/includes/rts/Flags.h b/includes/rts/Flags.h index 35b45b0940..fd75e5933a 100644 --- a/includes/rts/Flags.h +++ b/includes/rts/Flags.h @@ -132,15 +132,16 @@ typedef struct _COST_CENTRE_FLAGS { /* See Note [Synchronization of flags and base APIs] */ typedef struct _PROFILING_FLAGS { uint32_t doHeapProfile; -# define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */ -# define HEAP_BY_CCS 1 -# define HEAP_BY_MOD 2 -# define HEAP_BY_DESCR 4 -# define HEAP_BY_TYPE 5 +# define NO_HEAP_PROFILING 0 /* N.B. Used as indexes into arrays */ +# define HEAP_BY_CCS 1 +# define HEAP_BY_MOD 2 +# define HEAP_BY_DESCR 4 +# define HEAP_BY_TYPE 5 # define HEAP_BY_RETAINER 6 # define HEAP_BY_LDV 7 # define HEAP_BY_CLOSURE_TYPE 8 +# define HEAP_BY_INFO_TABLE 9 Time heapProfileInterval; /* time between samples */ uint32_t heapProfileIntervalTicks; /* ticks between samples (derived) */ diff --git a/libraries/base/GHC/RTS/Flags.hsc b/libraries/base/GHC/RTS/Flags.hsc index b23ae34165..4c039ee69a 100644 --- a/libraries/base/GHC/RTS/Flags.hsc +++ b/libraries/base/GHC/RTS/Flags.hsc @@ -256,6 +256,7 @@ data DoHeapProfile | HeapByRetainer | HeapByLDV | HeapByClosureType + | HeapByInfoTable deriving ( Show -- ^ @since 4.8.0.0 , Generic -- ^ @since 4.15.0.0 ) @@ -270,6 +271,7 @@ instance Enum DoHeapProfile where fromEnum HeapByRetainer = #{const HEAP_BY_RETAINER} fromEnum HeapByLDV = #{const HEAP_BY_LDV} fromEnum HeapByClosureType = #{const HEAP_BY_CLOSURE_TYPE} + fromEnum HeapByInfoTable = #{const HEAP_BY_INFO_TABLE} toEnum #{const NO_HEAP_PROFILING} = NoHeapProfiling toEnum #{const HEAP_BY_CCS} = HeapByCCS @@ -279,6 +281,7 @@ instance Enum DoHeapProfile where toEnum #{const HEAP_BY_RETAINER} = HeapByRetainer toEnum #{const HEAP_BY_LDV} = HeapByLDV toEnum #{const HEAP_BY_CLOSURE_TYPE} = HeapByClosureType + toEnum #{const HEAP_BY_INFO_TABLE} = HeapByInfoTable toEnum e = errorWithoutStackTrace ("invalid enum for DoHeapProfile: " ++ show e) -- | Parameters of the cost-center profiler diff --git a/rts/ProfHeap.c b/rts/ProfHeap.c index 195a6b6af2..081714638f 100644 --- a/rts/ProfHeap.c +++ b/rts/ProfHeap.c @@ -238,6 +238,9 @@ closureIdentity( const StgClosure *p ) return closure_type_names[info->type]; } } + case HEAP_BY_INFO_TABLE: { + return get_itbl(p); + } default: barf("closureIdentity"); @@ -955,6 +958,12 @@ dumpCensus( Census *census ) traceHeapProfSampleString(0, (char *)ctr->identity, count * sizeof(W_)); break; + case HEAP_BY_INFO_TABLE: + fprintf(hp_file, "%p", ctr->identity); + char str[100]; + sprintf(str, "%p", ctr->identity); + traceHeapProfSampleString(0, str, count * sizeof(W_)); + break; #if defined(PROFILING) case HEAP_BY_CCS: fprint_ccs(hp_file, (CostCentreStack *)ctr->identity, diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index ddd561b29c..ab4e556b45 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -1388,6 +1388,10 @@ error = true; OPTION_UNSAFE; RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_CLOSURE_TYPE; break; + case 'i': + OPTION_UNSAFE; + RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_INFO_TABLE; + break; default: OPTION_SAFE; PROFILING_BUILD_ONLY(); @@ -2146,6 +2150,7 @@ static bool read_heap_profiling_flag(const char *arg) case 'd': case 'Y': case 'y': + case 'i': case 'R': case 'r': case 'B': @@ -2226,6 +2231,9 @@ static bool read_heap_profiling_flag(const char *arg) case 'y': RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_TYPE; break; + case 'i': + RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_INFO_TABLE; + break; case 'R': case 'r': RtsFlags.ProfFlags.doHeapProfile = HEAP_BY_RETAINER; diff --git a/rts/eventlog/EventLog.c b/rts/eventlog/EventLog.c index 8aeea789e6..981d2dd3ff 100644 --- a/rts/eventlog/EventLog.c +++ b/rts/eventlog/EventLog.c @@ -1313,6 +1313,8 @@ static HeapProfBreakdown getHeapProfBreakdown(void) return HEAP_PROF_BREAKDOWN_BIOGRAPHY; case HEAP_BY_CLOSURE_TYPE: return HEAP_PROF_BREAKDOWN_CLOSURE_TYPE; + case HEAP_BY_INFO_TABLE: + return HEAP_PROF_BREAKDOWN_INFO_TABLE; default: barf("getHeapProfBreakdown: unknown heap profiling mode"); } |