[m-rev.] diff: improve memory retention profiling options

Peter Wang novalazy at gmail.com
Wed Nov 9 10:20:48 AEDT 2011


Branches: main, 11.07

Improve command-line options for memory retention profiling.

profiler/options.m:
profiler/snapshots.m:
	Replace `-g type' option by more straightforward `-T' (group by type).

	Replace `-H' (hide details) by more obvious `-b' (brief).

	Fix wrong help text which had `-i' for `-r'.

doc/user_guide.texi:
	As above.

diff --git a/doc/user_guide.texi b/doc/user_guide.texi
index 3a65a94..6d19cb9 100644
--- a/doc/user_guide.texi
+++ b/doc/user_guide.texi
@@ -6075,9 +6075,10 @@ You will see the memory cells which were on the heap at each time
 that @samp{report_memory_attribution} was called: the origin of the cells, and
 their type constructors.
 
-Passing the additional option @samp{-g type} will group the profile first by
-type constructors, then by procedure.  The @samp{-H} option hides the secondary
-level of information.  Memory cells allocated by the Mercury runtime system
+Passing the option @samp{-T} will group the profile first by
+type constructors, then by procedure.  The @samp{-b} option produces a brief
+profile by hiding the secondary level of information.
+Memory cells allocated by the Mercury runtime system
 itself are normally excluded from the profile; they can be viewed by passing
 the @samp{-r} option.
 
diff --git a/profiler/options.m b/profiler/options.m
index 0ba0f79..561c044 100644
--- a/profiler/options.m
+++ b/profiler/options.m
@@ -44,8 +44,8 @@
     % Snapshot (memory attribution profiling) options
     ;       snapshots
     ;       snapshots_file
-    ;       snapshots_grouping
-    ;       snapshots_hide_details
+    ;       snapshots_by_type
+    ;       snapshots_brief
     ;       snapshots_include_runtime
     ;       snapshots_recalc_size       % developers only
     % Miscellaneous Options
@@ -93,8 +93,8 @@ option_default(libraryfile,             string("")).
 option_default(demangle,                bool(yes)).
 option_default(snapshots,               bool(no)).
 option_default(snapshots_file,          string("Prof.Snapshots")).
-option_default(snapshots_grouping,      string("proc")).
-option_default(snapshots_hide_details,  bool(no)).
+option_default(snapshots_by_type,       bool(no)).
+option_default(snapshots_brief,         bool(no)).
 option_default(snapshots_include_runtime, bool(no)).
 option_default(snapshots_recalc_size,   bool(yes)).
 
@@ -103,13 +103,12 @@ option_default(help,                    bool(no)).
 
 
     % please keep this in alphabetic order
+short_option('b', snapshots_brief).
 short_option('C', countfile).
 short_option('c', call_graph).
 short_option('d', dynamic_cg).
 short_option('D', declfile).
-short_option('g', snapshots_grouping).
 short_option('h', help).
-short_option('H', snapshots_hide_details).
 short_option('L', libraryfile).
 short_option('m', profile_memory_words).
 short_option('M', profile_memory_cells).
@@ -118,6 +117,7 @@ short_option('P', pairfile).
 short_option('r', snapshots_include_runtime).
 short_option('s', snapshots).
 short_option('t', profile_time).
+short_option('T', snapshots_by_type).
 short_option('v', verbose).
 short_option('V', very_verbose).
 
@@ -134,9 +134,9 @@ long_option("profile-memory-words", profile_memory_words).
 long_option("profile-memory-cells", profile_memory_cells).
 long_option("profile-time",         profile_time).
 long_option("snapshots",            snapshots).
+long_option("snapshots-brief",      snapshots_brief).
+long_option("snapshots-by-type",    snapshots_by_type).
 long_option("snapshots-file",       snapshots_file).
-long_option("snapshots-grouping",   snapshots_grouping).
-long_option("snapshots-hide-details", snapshots_hide_details).
 long_option("snapshots-include-runtime", snapshots_include_runtime).
 long_option("snapshots-recalc-size", snapshots_recalc_size).
 long_option("use-dynamic",          dynamic_cg).
@@ -203,12 +203,11 @@ options_help -->
     io.write_string("\t\tThis overrides other profiler modes.\n"),
     io.write_string("\t--snapshot-file <file>\n"),
     io.write_string("\t\tName of the snapshots file. Usually `Prof.Snapshots'.\n"),
-    io.write_string("\t-g <type>, --snapshots-grouping <type>\n"),
-    io.write_string("\t\tSelect method of grouping results.\n"),
-    io.write_string("\t\tMay be by ""type"" or ""proc"" (default).\n"),
-    io.write_string("\t-H, --snapshots-hide-details\n"),
+    io.write_string("\t-T, --snapshots-by-type\n"),
+    io.write_string("\t\tGroup results by type.\n"),
+    io.write_string("\t-b, --snapshots-brief\n"),
     io.write_string("\t\tGenerate a brief profile.\n"),
-    io.write_string("\t-i, --snapshots-include-runtime\n"),
+    io.write_string("\t-r, --snapshots-include-runtime\n"),
     io.write_string("\t\tInclude internal Mercury runtime structures in the\n"),
     io.write_string("\t\tprofile. These are excluded by default.\n"),
 
diff --git a/profiler/snapshots.m b/profiler/snapshots.m
index 4b44bcb..ae9d249 100644
--- a/profiler/snapshots.m
+++ b/profiler/snapshots.m
@@ -86,7 +86,7 @@
 :- type snapshot_options
     --->    snapshot_options(
                 major_axis      :: major_axis,
-                hide_details    :: bool,
+                brief           :: bool,
                 recalc_words    :: bool,
                 include_runtime :: bool
             ).
@@ -99,16 +99,18 @@
 
 show_snapshots(!IO) :-
     globals.io_lookup_string_option(snapshots_file, SnapshotsFile, !IO),
-    globals.io_lookup_string_option(snapshots_grouping, SnapshotsGroup, !IO),
-    globals.io_lookup_bool_option(snapshots_hide_details, HideDetails, !IO),
+    globals.io_lookup_bool_option(snapshots_by_type, ByType, !IO),
+    globals.io_lookup_bool_option(snapshots_brief, Brief, !IO),
     globals.io_lookup_bool_option(snapshots_recalc_size, RecalcSize, !IO),
     globals.io_lookup_bool_option(snapshots_include_runtime, InclRuntime, !IO),
-    ( valid_grouping(SnapshotsGroup, MajorAxis0) ->
-        MajorAxis = MajorAxis0
+    (
+        ByType = yes,
+        MajorAxis = major_axis_type
     ;
-        error("unexpected grouping option `" ++ SnapshotsGroup ++ "'")
+        ByType = no,
+        MajorAxis = major_axis_proc
     ),
-    Options = snapshot_options(MajorAxis, HideDetails, RecalcSize, InclRuntime),
+    Options = snapshot_options(MajorAxis, Brief, RecalcSize, InclRuntime),
     io.open_input(SnapshotsFile, OpenDeclRes, !IO),
     (
         OpenDeclRes = ok(DeclStream),
@@ -132,12 +134,6 @@ show_snapshots(!IO) :-
         error(ErrorStr)
     ).
 
-:- pred valid_grouping(string::in, major_axis::out) is semidet.
-
-valid_grouping("type", major_axis_type).
-valid_grouping("proc", major_axis_proc).
-valid_grouping("procedure", major_axis_proc).
-
 %-----------------------------------------------------------------------------%
 
 :- pred parse_alloc_site_decls(io.input_stream::in,
@@ -378,11 +374,11 @@ output_snapshot(Options, Grouped, !IO) :-
     list.foldl2(sum_groups, Grouped, 0, TotalCells, 0, TotalWords),
     io.format(" %7d%17d%14s  %s\n",
         [i(TotalCells), i(TotalWords), s(""), s("total")], !IO),
-    HideDetails = Options ^ hide_details,
+    Brief = Options ^ brief,
     (
-        HideDetails = yes
+        Brief = yes
     ;
-        HideDetails = no,
+        Brief = no,
         io.nl(!IO)
     ),
     list.foldl2(output_group(Options, TotalCells, TotalWords),
@@ -421,7 +417,7 @@ output_group(Options, TotalCells, TotalWords, Group, !CumulWords, !IO) :-
         true
     ;
         MajorAxis = Options ^ major_axis,
-        HideDetails = Options ^ hide_details,
+        Brief = Options ^ brief,
         (
             MajorAxis = major_axis_proc,
             RightLabel = AllocSite ^ alloc_proc
@@ -430,10 +426,10 @@ output_group(Options, TotalCells, TotalWords, Group, !CumulWords, !IO) :-
             RightLabel = AllocSite ^ alloc_type
         ),
         (
-            HideDetails = yes,
+            Brief = yes,
             Star = ' '
         ;
-            HideDetails = no,
+            Brief = no,
             Star = ('*')
         ),
         io.format("%c%7d/%5.1f%% %9d/%5.1f%% %5.1f%%  %s\n",
@@ -442,9 +438,9 @@ output_group(Options, TotalCells, TotalWords, Group, !CumulWords, !IO) :-
             i(NumWords), f(WordsPercent), f(CumulPercent),
             s(RightLabel)], !IO),
         (
-            HideDetails = yes
+            Brief = yes
         ;
-            HideDetails = no,
+            Brief = no,
             Single = ( Counts = [_] -> yes ; no ),
             list.foldl(output_site(MajorAxis, TotalCells, TotalWords, Single),
                 Counts, !IO),

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list