[m-rev.] for post-commit review: move two deep prof cmds to use reports
Zoltan Somogyi
zs at csse.unimelb.edu.au
Mon Aug 4 18:46:46 AEST 2008
For post-commit review by Paul.
Zoltan.
Use reports to handle the proc_static and proc_dynamic queries.
deep_profiler/report.m:
Add the two new report types.
Change the report type to give each query its own answer, without
needing to use the report_message for reporting errors. Also, group
each kind of report into a single data structure that can be
manipulated independently of the other kinds of answers (like I did
some time ago for items in the compiler.)
deep_profiler/create_report.m:
Add the code for the two new report types.
Conform to the other changes in report.m.
Inline some unnecessary intermediate predicates.
deep_profiler/display.m:
deep_profiler/html_format.m:
Rename one table_class that is now used not just by the menu command.
deep_profiler/display_report.m:
Add the code to handle the two new report types.
Refactor some existing code to allow it to called by the new code.
Conform to the other changes in report.m.
Fix several predicate names that would have become misleading as soon
as we added new kinds of reports. The fix is to give them the prefix
"top_procs_", since they all generate parts of top_procs pages.
deep_profiler/query.m:
Use the new method to handle the two query types.
cvs diff: Diffing .
Index: create_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/create_report.m,v
retrieving revision 1.2
diff -u -b -r1.2 create_report.m
--- create_report.m 4 Aug 2008 03:17:45 -0000 1.2
+++ create_report.m 4 Aug 2008 08:07:57 -0000
@@ -47,22 +47,35 @@
Cmd = deep_cmd_quit,
Msg = string.format("Shutting down deep profile server for %s.",
[s(Deep ^ data_file_name)]),
- Report = report_message(Msg)
+ MessageInfo = message_info(Msg),
+ Report = report_message(MessageInfo)
;
Cmd = deep_cmd_timeout(Timeout),
Msg = string.format("Timeout set to %d minutes.", [i(Timeout)]),
- Report = report_message(Msg)
+ MessageInfo = message_info(Msg),
+ Report = report_message(MessageInfo)
;
Cmd = deep_cmd_menu,
Deep ^ profile_stats = profile_stats(NumCSD, NumCSS, NumPD, NumPS,
QuantaPerSec, InstrumentationQuanta, UserQuanta, NumCallsequs,
_, _),
NumCliques = array.max(Deep ^ clique_members),
- Report = report_menu(QuantaPerSec, UserQuanta, InstrumentationQuanta,
- NumCallsequs, NumCSD, NumCSS, NumPD, NumPS, NumCliques)
+ MenuInfo = menu_info(QuantaPerSec, UserQuanta, InstrumentationQuanta,
+ NumCallsequs, NumCSD, NumCSS, NumPD, NumPS, NumCliques),
+ Report = report_menu(ok(MenuInfo))
;
Cmd = deep_cmd_top_procs(Limit, CostKind, InclDesc, Scope),
- create_top_procs_report(Deep, Limit, CostKind, InclDesc, Scope, Report)
+ create_top_procs_report(Deep, Limit, CostKind, InclDesc, Scope,
+ MaybeTopProcsInfo),
+ Report = report_top_procs(MaybeTopProcsInfo)
+ ;
+ Cmd = deep_cmd_proc_static(PSI),
+ generate_proc_static_dump_report(Deep, PSI, MaybeProcStaticDumpInfo),
+ Report = report_proc_static_dump(MaybeProcStaticDumpInfo)
+ ;
+ Cmd = deep_cmd_proc_dynamic(PDI),
+ generate_proc_dynamic_dump_report(Deep, PDI, MaybeProcDynamicDumpInfo),
+ Report = report_proc_dynamic_dump(MaybeProcDynamicDumpInfo)
;
Cmd = deep_cmd_restart,
error("create_report/3", "unexpected restart command")
@@ -73,8 +86,6 @@
; Cmd = deep_cmd_proc_callers(_, _, _)
; Cmd = deep_cmd_modules
; Cmd = deep_cmd_module(_)
- ; Cmd = deep_cmd_proc_static(_)
- ; Cmd = deep_cmd_proc_dynamic(_)
; Cmd = deep_cmd_call_site_static(_)
; Cmd = deep_cmd_call_site_dynamic(_)
; Cmd = deep_cmd_raw_clique(_)
@@ -91,9 +102,11 @@
% parameters.
%
:- pred create_top_procs_report(deep::in, display_limit::in, cost_kind::in,
- include_descendants::in, measurement_scope::in, deep_report::out) is det.
+ include_descendants::in, measurement_scope::in,
+ maybe_error(top_procs_info)::out) is det.
-create_top_procs_report(Deep, Limit, CostKind, InclDesc0, Scope0, Report) :-
+create_top_procs_report(Deep, Limit, CostKind, InclDesc0, Scope0,
+ MaybeTopProcsInfo) :-
(
CostKind = cost_calls,
% Counting calls is incompatible both with self_and_desc
@@ -113,12 +126,56 @@
MaybeTopPSIs = find_top_procs(CostKind, InclDesc, Scope, Limit, Deep),
(
MaybeTopPSIs = error(ErrorMessage),
- Report = report_message("Internal error: " ++ ErrorMessage)
+ MaybeTopProcsInfo = error("Internal error: " ++ ErrorMessage)
;
MaybeTopPSIs = ok(TopPSIs),
Ordering = report_ordering(Limit, CostKind, InclDesc, Scope),
list.map(psi_to_perf_row_data(Deep), TopPSIs, RowData),
- Report = report_top_procs(Ordering, RowData)
+ TopProcsInfo = top_procs_info(Ordering, RowData),
+ MaybeTopProcsInfo = ok(TopProcsInfo)
+ ).
+
+%-----------------------------------------------------------------------------%
+%
+% Code to build the dump reports.
+%
+
+:- pred generate_proc_static_dump_report(deep::in, int::in,
+ maybe_error(proc_static_dump_info)::out) is det.
+
+generate_proc_static_dump_report(Deep, PSI, MaybeProcStaticDumpInfo) :-
+ PSPtr = proc_static_ptr(PSI),
+ ( valid_proc_static_ptr(Deep, PSPtr) ->
+ deep_lookup_proc_statics(Deep, PSPtr, PS),
+ RawName = PS ^ ps_raw_id,
+ RefinedName = PS ^ ps_refined_id,
+ FileName = PS ^ ps_file_name,
+ LineNumber = PS ^ ps_line_number,
+ array.max(PS ^ ps_sites, NumCallSites),
+ ProcStaticDumpInfo = proc_static_dump_info(PSPtr, RawName, RefinedName,
+ FileName, LineNumber, NumCallSites),
+ MaybeProcStaticDumpInfo = ok(ProcStaticDumpInfo)
+ ;
+ MaybeProcStaticDumpInfo = error("invalid proc_static index")
+ ).
+
+:- pred generate_proc_dynamic_dump_report(deep::in, int::in,
+ maybe_error(proc_dynamic_dump_info)::out) is det.
+
+generate_proc_dynamic_dump_report(Deep, PDI, MaybeProcDynamicDumpInfo) :-
+ PDPtr = proc_dynamic_ptr(PDI),
+ ( valid_proc_dynamic_ptr(Deep, PDPtr) ->
+ deep_lookup_proc_dynamics(Deep, PDPtr, PD),
+ PD = proc_dynamic(PSPtr, CallSiteArray),
+ deep_lookup_proc_statics(Deep, PSPtr, PS),
+ RawName = PS ^ ps_raw_id,
+ RefinedName = PS ^ ps_refined_id,
+ array.to_list(CallSiteArray, CallSites),
+ ProcDynamicDumpInfo = proc_dynamic_dump_info(PDPtr, PSPtr,
+ RawName, RefinedName, CallSites),
+ MaybeProcDynamicDumpInfo = ok(ProcDynamicDumpInfo)
+ ;
+ MaybeProcDynamicDumpInfo = error("invalid proc_dynamic index")
).
%-----------------------------------------------------------------------------%
@@ -237,28 +294,18 @@
:- pred psptr_to_report_proc(deep::in, proc_static_ptr::in, report_proc::out)
is det.
-psptr_to_report_proc(Deep, PSPtr, report_proc(PSPtr, Filename, Lineno, Name))
- :-
- proc_static_get_proc_info(Deep, PSPtr, Filename, Lineno, Name).
-
-%-----------------------------------------------------------------------------%
-
- % Get appropriate source location information for a proc static pointer.
- %
-:- pred proc_static_get_proc_info(deep::in, proc_static_ptr::in, string::out,
- int::out, string::out) is det.
-
-proc_static_get_proc_info(Deep, PSPtr, FileName, LineNumber, Name) :-
+psptr_to_report_proc(Deep, PSPtr, Report) :-
( valid_proc_static_ptr(Deep, PSPtr) ->
deep_lookup_proc_statics(Deep, PSPtr, PS),
FileName = PS ^ ps_file_name,
LineNumber = PS ^ ps_line_number,
- Name = PS ^ ps_refined_id
+ RefinedName = PS ^ ps_refined_id
;
FileName = "",
LineNumber = 0,
- Name = "mercury_runtime"
- ).
+ RefinedName = "mercury_runtime"
+ ),
+ Report = report_proc(PSPtr, FileName, LineNumber, RefinedName).
%-----------------------------------------------------------------------------%
%
Index: display.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/display.m,v
retrieving revision 1.2
diff -u -b -r1.2 display.m
--- display.m 4 Aug 2008 03:17:45 -0000 1.2
+++ display.m 4 Aug 2008 05:14:03 -0000
@@ -110,7 +110,7 @@
; table_empty_cell.
:- type table_class
- ---> table_class_menu
+ ---> table_class_plain
; table_class_top_procs.
:- type table_col_class
@@ -205,7 +205,6 @@
:- import_module int.
-
table_maybe_add_header_col(no, !Cols, !NumCols).
table_maybe_add_header_col(yes(HeaderCol), !Cols, !NumCols) :-
Index: display_report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/display_report.m,v
retrieving revision 1.2
diff -u -b -r1.2 display_report.m
--- display_report.m 4 Aug 2008 03:17:45 -0000 1.2
+++ display_report.m 4 Aug 2008 08:35:46 -0000
@@ -37,7 +37,9 @@
:- import_module measurement_units.
+:- import_module array.
:- import_module bool.
+:- import_module counter.
:- import_module float.
:- import_module int.
:- import_module list.
@@ -49,16 +51,45 @@
report_to_display(Deep, Prefs, Report) = Display :-
(
- Report = report_message(Msg),
+ Report = report_message(message_info(Msg)),
Display = display(no, [display_message(Msg)])
;
- Report = report_menu(QuantaPerSec, UserQuanta, InstQuanta,
- NumCallseqs, NumCSD, NumCSS, NumPD, NumPS, NumClique),
- display_report_menu(Deep, QuantaPerSec, UserQuanta, InstQuanta,
- NumCallseqs, NumCSD, NumCSS, NumPD, NumPS, NumClique, Display)
+ Report = report_menu(MaybeMenuInfo),
+ (
+ MaybeMenuInfo = ok(MenuInfo),
+ display_report_menu(Deep, MenuInfo, Display)
+ ;
+ MaybeMenuInfo = error(Msg),
+ Display = display(no, [display_message(Msg)])
+ )
;
- Report = report_top_procs(Ordering, TopProcs),
- display_report_top_procs(Prefs, Ordering, TopProcs, Display)
+ Report = report_top_procs(MaybeTopProcsInfo),
+ (
+ MaybeTopProcsInfo = ok(TopProcsInfo),
+ display_report_top_procs(Prefs, TopProcsInfo, Display)
+ ;
+ MaybeTopProcsInfo = error(Msg),
+ Display = display(no, [display_message(Msg)])
+ )
+ ;
+ Report = report_proc_static_dump(MaybeProcStaticDumpInfo),
+ (
+ MaybeProcStaticDumpInfo = ok(ProcStaticDumpInfo),
+ display_report_proc_static_dump(ProcStaticDumpInfo, Display)
+ ;
+ MaybeProcStaticDumpInfo = error(Msg),
+ Display = display(no, [display_message(Msg)])
+ )
+ ;
+ Report = report_proc_dynamic_dump(MaybeProcDynamicDumpInfo),
+ (
+ MaybeProcDynamicDumpInfo = ok(ProcDynamicDumpInfo),
+ display_report_proc_dynamic_dump(Deep, Prefs, ProcDynamicDumpInfo,
+ Display)
+ ;
+ MaybeProcDynamicDumpInfo = error(Msg),
+ Display = display(no, [display_message(Msg)])
+ )
).
%-----------------------------------------------------------------------------%
@@ -66,12 +97,12 @@
% Code to display menu report.
%
-:- pred display_report_menu(deep::in, int::in, int::in, int::in, int::in,
- int::in, int::in, int::in, int::in, int::in, display::out)
- is det.
+:- pred display_report_menu(deep::in, menu_info::in, display::out) is det.
+
+display_report_menu(Deep, MenuInfo, Display) :-
+ MenuInfo = menu_info(QuantaPerSec, UserQuanta, InstQuanta,
+ NumCallseqs, NumCSD, NumCSS, NumPD, NumPS, NumClique),
-display_report_menu(Deep, QuantaPerSec, UserQuanta, InstQuanta, NumCallseqs,
- NumCSD, NumCSS, NumPD, NumPS, NumClique, Display) :-
ShouldDisplayTimes = should_display_times(Deep),
% Display the links section of the report.
@@ -159,18 +190,18 @@
% Display the table section of the report.
ProfilingStatistics =
- [("Quanta per second:" - QuantaPerSec),
- ("Quanta in user code:" - UserQuanta),
- ("Quanta in instrumentation:" - InstQuanta),
- ("Call sequence numbers:" - NumCallseqs),
- ("CallSiteDyanic structures:" - NumCSD),
- ("ProcDynamic structures:" - NumPD),
- ("CallSiteStatic structures:" - NumCSS),
- ("ProcStatic structures:" - NumPS),
- ("Cliques:" - NumClique)],
+ [("Quanta per second:" - i(QuantaPerSec)),
+ ("Quanta in user code:" - i(UserQuanta)),
+ ("Quanta in instrumentation:" - i(InstQuanta)),
+ ("Call sequence numbers:" - i(NumCallseqs)),
+ ("CallSiteDyanic structures:" - i(NumCSD)),
+ ("ProcDynamic structures:" - i(NumPD)),
+ ("CallSiteStatic structures:" - i(NumCSS)),
+ ("ProcStatic structures:" - i(NumPS)),
+ ("Cliques:" - i(NumClique))],
- list.map(make_menu_table_row, ProfilingStatistics, Rows),
- Table = table(table_class_menu, 2, no, Rows),
+ Rows = list.map(make_labelled_table_row, ProfilingStatistics),
+ Table = table(table_class_plain, 2, no, Rows),
% Display the Controls section of the report.
Controls = display_list(list_class_horizontal, no, cmds_menu_restart_quit),
@@ -180,34 +211,17 @@
[Links, display_table(Table), Controls]).
%-----------------------------------------------------------------------------%
-
- % Make a table row as used in the menu report.
- %
-:- pred make_menu_table_row(pair(string, int)::in, table_row::out) is det.
-
-make_menu_table_row((Label - Value), Row) :-
- Row = table_row([table_cell(s(Label)), table_cell(i(Value))]).
-
-%-----------------------------------------------------------------------------%
-
- % Make a link for use in the menu report.
- %
-:- pred make_command_link(pair(cmd, string)::in, display_item::out) is det.
-
-make_command_link((Cmd - Label), Item) :-
- Item = display_command_link(deep_link(Cmd, no, Label, link_class_link)).
-
-%-----------------------------------------------------------------------------%
%
% Code to display a top procedures report.
%
% Create a display_report structure for a top_procedures report.
%
-:- pred display_report_top_procs(preferences::in, report_ordering::in,
- list(perf_row_data(report_proc))::in, display::out) is det.
+:- pred display_report_top_procs(preferences::in, top_procs_info::in,
+ display::out) is det.
-display_report_top_procs(Prefs, Ordering, TopProcs, Display) :-
+display_report_top_procs(Prefs, TopProcsInfo, Display) :-
+ TopProcsInfo = top_procs_info(Ordering, TopProcs),
Ordering = report_ordering(DisplayLimit, CostKind, InclDesc, Scope),
Desc = cost_criteria_to_description(CostKind, InclDesc, Scope),
Title = "Top procedures " ++ Desc,
@@ -236,6 +250,111 @@
[TableAndLabel, Controls1, Controls2, Controls3, Controls4]).
%-----------------------------------------------------------------------------%
+%
+% Code to display proc_static and proc_dynamic dumps.
+%
+
+ % Create a display_report structure for a proc_static_dump report.
+ %
+:- pred display_report_proc_static_dump(proc_static_dump_info::in,
+ display::out) is det.
+
+display_report_proc_static_dump(ProcStaticDumpInfo, Display) :-
+ ProcStaticDumpInfo = proc_static_dump_info(PSPtr, RawName, RefinedName,
+ FileName, LineNumber, NumCallSites),
+ PSPtr = proc_static_ptr(PSI),
+ string.format("Dump of proc_static %d", [i(PSI)], Title),
+
+ Values =
+ [("Raw name:" - s(RawName)),
+ ("Refined name:" - s(RefinedName)),
+ ("File name:" - s(FileName)),
+ ("Line number:" - i(LineNumber)),
+ ("Number of call sites:" - i(NumCallSites))],
+
+ Rows = list.map(make_labelled_table_row, Values),
+ Table = table(table_class_plain, 2, no, Rows),
+ Display = display(yes(Title), [display_table(Table)]).
+
+ % Create a display_report structure for a proc_dynamic_dump report.
+ %
+:- pred display_report_proc_dynamic_dump(deep::in, preferences::in,
+ proc_dynamic_dump_info::in, display::out) is det.
+
+display_report_proc_dynamic_dump(_Deep, Prefs, ProcDynamicDumpInfo, Display) :-
+ ProcDynamicDumpInfo = proc_dynamic_dump_info(PDPtr, PSPtr,
+ RawName, RefinedName, CallSites),
+ PDPtr = proc_dynamic_ptr(PDI),
+ PSPtr = proc_static_ptr(PSI),
+ string.format("Dump of proc_dynamic %d", [i(PDI)], Title),
+
+ ProcStaticLink = deep_link(deep_cmd_proc_static(PSI), yes(Prefs),
+ string.int_to_string(PSI), link_class_link),
+ MainValues =
+ [("Proc static:" - l(ProcStaticLink)),
+ ("Raw name:" - s(RawName)),
+ ("Refined name:" - s(RefinedName))],
+
+ MainRows = list.map(make_labelled_table_row, MainValues),
+ MainTable = table(table_class_plain, 2, no, MainRows),
+
+ list.map_foldl(dump_psd_call_site(Prefs), CallSites, CallSitesRowsList,
+ counter.init(1), _),
+ list.condense(CallSitesRowsList, CallSitesRows),
+ CallSitesTitle = "Call site dynamics:",
+ CallSitesTable =
+ table(table_class_plain, 2, no, CallSitesRows),
+
+ Display = display(yes(Title),
+ [display_table(MainTable), display_message(CallSitesTitle),
+ display_table(CallSitesTable)]).
+
+:- pred dump_psd_call_site(preferences::in,
+ call_site_array_slot::in, list(table_row)::out,
+ counter::in, counter::out) is det.
+
+dump_psd_call_site(Prefs, CallSite, Rows, !CallSiteCounter) :-
+ counter.allocate(CallSiteNum, !CallSiteCounter),
+ CallSiteNumCell = table_cell(i(CallSiteNum)),
+ (
+ CallSite = slot_normal(CSDPtr),
+ CSDPtr = call_site_dynamic_ptr(CSDI),
+ CSDLink = deep_link(deep_cmd_call_site_dynamic(CSDI), yes(Prefs),
+ string.int_to_string(CSDI), link_class_link),
+ CSDCell = table_cell(l(CSDLink)),
+ FirstRow = table_row([CallSiteNumCell, CSDCell]),
+ Rows = [FirstRow]
+ ;
+ CallSite = slot_multi(IsZeroed, CSDPtrArray),
+ (
+ IsZeroed = zeroed,
+ IsZeroedStr = "zeroed"
+ ;
+ IsZeroed = not_zeroed,
+ IsZeroedStr = "not_zeroed"
+ ),
+ array.to_list(CSDPtrArray, CSDPtrs),
+ NumCSDPtrs = list.length(CSDPtrs),
+ string.format("multi, %d csds (%s)", [i(NumCSDPtrs), s(IsZeroedStr)],
+ MultiCellStr),
+ MultiCell = table_cell(s(MultiCellStr)),
+ FirstRow = table_row([CallSiteNumCell, MultiCell]),
+ list.map(dump_psd_call_site_multi_entry(Prefs), CSDPtrs, LaterRows),
+ Rows = [FirstRow | LaterRows]
+ ).
+
+:- pred dump_psd_call_site_multi_entry(preferences::in,
+ call_site_dynamic_ptr::in, table_row::out) is det.
+
+dump_psd_call_site_multi_entry(Prefs, CSDPtr, Row) :-
+ CSDPtr = call_site_dynamic_ptr(CSDI),
+ CSDLink = deep_link(deep_cmd_call_site_dynamic(CSDI), yes(Prefs),
+ string.int_to_string(CSDI), link_class_link),
+ CSDCell = table_cell(l(CSDLink)),
+ EmptyCell = table_cell(s("")),
+ Row = table_row([EmptyCell, CSDCell]).
+
+%-----------------------------------------------------------------------------%
% Create a phrase describing how the top procedures may be sorted.
%
@@ -344,61 +463,64 @@
%-----------------------------------------------------------------------------%
-:- func make_link(report_ordering, preferences, string, cost_kind,
- include_descendants, measurement_scope) = deep_link.
+:- func top_procs_self_link(table_info, cost_kind) = table_data.
-make_link(Ordering, Prefs, Label, CostKind, InclDesc, Scope) =
- make_link(Ordering, Prefs, Label, CostKind, InclDesc, Scope,
- link_class_link).
+top_procs_self_link(TableInfo, CostKind) =
+ top_procs_make_table_link(TableInfo, "Self",
+ CostKind, self, overall).
-:- func make_link(report_ordering, preferences, string, cost_kind,
- include_descendants, measurement_scope, link_class) = deep_link.
+:- func top_procs_self_percall_link(table_info, cost_kind) = table_data.
- % It might be nice to improve this so that if a user is looking up a
- % different cost kind compared to the current run it resets the display
- % limit. This requires more thought, as different values may not make
- % sense for different limits. So perhaps it's best to only reset the limit
- % if it was a range that didn't start at one.
- %
-make_link(Ordering, Prefs, Label, CostKind, InclDesc, Scope, Class) = Link :-
- DisplayLimit = Ordering ^ display_limit,
- Link = deep_link(
- deep_cmd_top_procs(DisplayLimit, CostKind, InclDesc, Scope),
- yes(Prefs), Label, Class).
+top_procs_self_percall_link(TableInfo, CostKind) =
+ top_procs_make_table_link(TableInfo, "/call",
+ CostKind, self, per_call).
-:- func make_table_link(table_info, string, cost_kind, include_descendants,
- measurement_scope) = table_data.
+:- func top_procs_total_link(table_info, cost_kind) = table_data.
-make_table_link(TableInfo, Label, CostKind, InclDesc, Scope) =
- l(make_link(Ordering, Prefs, Label, CostKind, InclDesc, Scope)) :-
- Ordering = TableInfo ^ table_ordering,
- Prefs = TableInfo ^ prefs.
+top_procs_total_link(TableInfo, CostKind) =
+ top_procs_make_table_link(TableInfo, "Total",
+ CostKind, self_and_desc, overall).
-%-----------------------------------------------------------------------------%
+:- func top_procs_total_percall_link(table_info, cost_kind) = table_data.
+
+top_procs_total_percall_link(TableInfo, CostKind) =
+ top_procs_make_table_link(TableInfo, "/call",
+ CostKind, self_and_desc, per_call).
+
+:- func top_procs_time_link(table_info) = table_data.
+
+top_procs_time_link(TableInfo) =
+ top_procs_make_table_link(TableInfo, "Time",
+ cost_time, self, overall).
+
+:- func top_procs_total_time_link(table_info) = table_data.
-:- func self_link(table_info, cost_kind) = table_data.
-self_link(TableInfo, CostKind) = Link :-
- make_table_link(TableInfo, "Self", CostKind, self, overall) = Link.
+top_procs_total_time_link(TableInfo) =
+ top_procs_make_table_link(TableInfo, "Time",
+ cost_time, self_and_desc, overall).
-:- func self_percall_link(table_info, cost_kind) = table_data.
-self_percall_link(TableInfo, CostKind) = Link :-
- make_table_link(TableInfo, "/call", CostKind, self, per_call) = Link.
+%-----------------------------------------------------------------------------%
-:- func total_link(table_info, cost_kind) = table_data.
-total_link(TableInfo, CostKind) =
- make_table_link(TableInfo, "Total", CostKind, self_and_desc, overall).
+:- func top_procs_make_table_link(table_info, string, cost_kind,
+ include_descendants, measurement_scope) = table_data.
-:- func total_percall_link(table_info, cost_kind) = table_data.
-total_percall_link(TableInfo, CostKind) =
- make_table_link(TableInfo, "/call", CostKind, self_and_desc, per_call).
+top_procs_make_table_link(TableInfo, Label, CostKind, InclDesc, Scope)
+ = TableData :-
+ Ordering = TableInfo ^ table_ordering,
+ Prefs = TableInfo ^ prefs,
+ DisplayLimit = Ordering ^ display_limit,
+ Cmd = deep_cmd_top_procs(DisplayLimit, CostKind, InclDesc, Scope),
+ Link = deep_link(Cmd, yes(Prefs), Label, link_class_link),
+ TableData = l(Link).
-:- func time_link(table_info) = table_data.
-time_link(TableInfo) =
- make_table_link(TableInfo, "Time", cost_time, self, overall).
+:- func top_procs_make_link(report_ordering, preferences, string, cost_kind,
+ include_descendants, measurement_scope, link_class) = deep_link.
-:- func total_time_link(table_info) = table_data.
-total_time_link(TableInfo) =
- make_table_link(TableInfo, "Time", cost_time, self_and_desc, overall).
+top_procs_make_link(Ordering, Prefs, Label, CostKind, InclDesc, Scope, Class)
+ = Link :-
+ DisplayLimit = Ordering ^ display_limit,
+ Cmd = deep_cmd_top_procs(DisplayLimit, CostKind, InclDesc, Scope),
+ Link = deep_link(Cmd, yes(Prefs), Label, Class).
%-----------------------------------------------------------------------------%
@@ -545,7 +667,8 @@
MemoryCells = []
;
( MemoryFields = memory(Units)
- ; MemoryFields = memory_and_percall(Units) ),
+ ; MemoryFields = memory_and_percall(Units)
+ ),
SelfMemCell = table_cell(m(RowData ^ self_mem, Units, 0)),
SelfMemPercallCell =
table_cell(m(RowData ^ self_mem_percall, Units, 2)),
@@ -585,12 +708,12 @@
proc_table_time_header(TableInfo, Fields, MaybeHeaderCell) :-
TimeFields = Fields ^ time_fields,
- Self = self_link(TableInfo, cost_time),
- Time = time_link(TableInfo),
- SelfPercall = self_percall_link(TableInfo, cost_time),
- Total = total_link(TableInfo, cost_time),
- TotalTime = total_time_link(TableInfo),
- TotalPercall = total_percall_link(TableInfo, cost_time),
+ Self = top_procs_self_link(TableInfo, cost_time),
+ Time = top_procs_time_link(TableInfo),
+ SelfPercall = top_procs_self_percall_link(TableInfo, cost_time),
+ Total = top_procs_total_link(TableInfo, cost_time),
+ TotalTime = top_procs_total_time_link(TableInfo),
+ TotalPercall = top_procs_total_percall_link(TableInfo, cost_time),
(
TimeFields = no_time,
@@ -634,8 +757,10 @@
proc_table_ports_header(TableInfo, Fields, MaybePortsHeader) :-
(
Fields ^ port_fields = port,
- Calls = make_table_link(TableInfo, "Calls", cost_calls, self, overall),
- Redos = make_table_link(TableInfo, "Redos", cost_redos, self, overall),
+ Calls = top_procs_make_table_link(TableInfo, "Calls",
+ cost_calls, self, overall),
+ Redos = top_procs_make_table_link(TableInfo, "Redos",
+ cost_redos, self, overall),
MaybePortsHeader = yes(table_header_group("Port counts",
[Calls, s("Exits"), s("Fails"), Redos, s("Excps")],
table_col_class_port_counts))
@@ -651,8 +776,8 @@
proc_table_callseqs_header(TableInfo, Fields, MaybeCallseqsHeader) :-
Callseqs = Fields ^ callseqs_fields,
- Self = self_link(TableInfo, cost_callseqs),
- Total = total_link(TableInfo, cost_callseqs),
+ Self = top_procs_self_link(TableInfo, cost_callseqs),
+ Total = top_procs_total_link(TableInfo, cost_callseqs),
(
Callseqs = no_callseqs,
MaybeCallseqsHeader = no
@@ -662,8 +787,10 @@
SubTitles = [Self, percent_label, Total, percent_label]
;
Callseqs = callseqs_and_percall,
- SelfPercall = self_percall_link(TableInfo, cost_callseqs),
- TotalPercall = total_percall_link(TableInfo, cost_callseqs),
+ SelfPercall =
+ top_procs_self_percall_link(TableInfo, cost_callseqs),
+ TotalPercall =
+ top_procs_total_percall_link(TableInfo, cost_callseqs),
SubTitles =
[Self, percent_label, SelfPercall,
Total, percent_label, TotalPercall]
@@ -679,8 +806,8 @@
proc_table_allocations_header(TableInfo, Fields, MaybeHeader) :-
AllocFields = Fields ^ alloc_fields,
- Self = self_link(TableInfo, cost_allocs),
- Total = total_link(TableInfo, cost_allocs),
+ Self = top_procs_self_link(TableInfo, cost_allocs),
+ Total = top_procs_total_link(TableInfo, cost_allocs),
(
AllocFields = no_alloc,
MaybeHeader = no
@@ -690,8 +817,10 @@
SubTitles = [Self, percent_label, Total, percent_label]
;
AllocFields = alloc_and_percall,
- SelfPercall = self_percall_link(TableInfo, cost_allocs),
- TotalPercall = total_percall_link(TableInfo, cost_allocs),
+ SelfPercall =
+ top_procs_self_percall_link(TableInfo, cost_allocs),
+ TotalPercall =
+ top_procs_total_percall_link(TableInfo, cost_allocs),
SubTitles =
[Self, percent_label, SelfPercall,
Total, percent_label, TotalPercall]
@@ -707,8 +836,8 @@
proc_table_memory_header(TableInfo, Fields, MaybeHeader) :-
Memory = Fields ^ memory_fields,
- Self = self_link(TableInfo, cost_words),
- Total = total_link(TableInfo, cost_words),
+ Self = top_procs_self_link(TableInfo, cost_words),
+ Total = top_procs_total_link(TableInfo, cost_words),
Percent = percent_label,
(
Memory = no_memory,
@@ -719,8 +848,8 @@
SubTitles = [Self, Percent, Total, Percent]
;
Memory = memory_and_percall(Units),
- SelfPercall = self_percall_link(TableInfo, cost_words),
- TotalPercall = total_percall_link(TableInfo, cost_words),
+ SelfPercall = top_procs_self_percall_link(TableInfo, cost_words),
+ TotalPercall = top_procs_total_percall_link(TableInfo, cost_words),
SubTitles =
[Self, Percent, SelfPercall,
Total, Percent, TotalPercall]
@@ -736,7 +865,6 @@
table_col_class_memory))
).
-
% Build a header for a table of procedures.
%
:- pred proc_table_header(table_info::in, int::out, table_header::out) is det.
@@ -751,9 +879,9 @@
!:Cols = [],
(
Ranked = ranked,
- table_add_header_col(
+ RankedHeaderCell =
table_header_cell(s("Rank"), table_col_class_ordinal_rank),
- !Cols, !NumCols)
+ table_add_header_col(RankedHeaderCell, !Cols, !NumCols)
;
Ranked = non_ranked
),
@@ -816,9 +944,8 @@
InclDesc = Ordering ^ incl_desc,
Scope = Ordering ^ scope,
cost_kind_label(CostKind, Label),
- Control =
- make_link(Ordering, Prefs, Label, CostKind, InclDesc, Scope,
- link_class_control).
+ Control = top_procs_make_link(Ordering, Prefs, Label, CostKind, InclDesc,
+ Scope, link_class_control).
%-----------------------------------------------------------------------------%
@@ -841,9 +968,10 @@
InclDescLabel = "Exclude descendants",
InclDesc = self
),
- InclDescControl = deep_link(
+ InclDescCmd =
deep_cmd_top_procs(DisplayLimit, CostKind, InclDesc, CurrentScope),
- yes(Prefs), InclDescLabel, link_class_control),
+ InclDescControl = deep_link(InclDescCmd, yes(Prefs), InclDescLabel,
+ link_class_control),
% Build Scope Control.
(
@@ -855,9 +983,11 @@
ScopeLabel = "Count overall cost",
Scope = overall
),
- ScopeControl = deep_link(
+
+ ScopeCmd =
deep_cmd_top_procs(DisplayLimit, CostKind, CurrentInclDesc, Scope),
- yes(Prefs), ScopeLabel, link_class_control),
+ ScopeControl = deep_link(ScopeCmd, yes(Prefs), ScopeLabel,
+ link_class_control),
list.map(link_to_display, [InclDescControl, ScopeControl], Controls),
ControlsList = display_list(list_class_horizontal, no, Controls).
@@ -868,7 +998,7 @@
:- pred link_to_display(deep_link::in, display_item::out) is det.
link_to_display(Link, Display) :-
- display_command_link(Link) = Display.
+ Display = display_command_link(Link).
%-----------------------------------------------------------------------------%
@@ -1117,7 +1247,21 @@
%-----------------------------------------------------------------------------%
- % Make a mercury list of display items into a display item representing
+ % Make a table row with two columns: a label and a value.
+ %
+:- func make_labelled_table_row(pair(string, table_data)) = table_row.
+
+make_labelled_table_row(Label - Value) =
+ table_row([table_cell(s(Label)), table_cell(Value)]).
+
+ % Make a link for use in the menu report.
+ %
+:- pred make_command_link(pair(cmd, string)::in, display_item::out) is det.
+
+make_command_link(Cmd - Label, Item) :-
+ Item = display_command_link(deep_link(Cmd, no, Label, link_class_link)).
+
+ % Make a Mercury list of display items into a display item representing
% a horizontal list of these items.
%
:- pred make_horizontal_list(list(display_item)::in, display_item::out) is det.
Index: html_format.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/html_format.m,v
retrieving revision 1.23
diff -u -b -r1.23 html_format.m
--- html_format.m 4 Aug 2008 03:17:45 -0000 1.23
+++ html_format.m 4 Aug 2008 05:15:26 -0000
@@ -261,7 +261,7 @@
margin: 5px;
text-decoration: none;
}
- table.menu
+ table.plain
{
border-style: none;
}
@@ -625,7 +625,7 @@
:- func table_class_to_string(table_class) = string.
-table_class_to_string(table_class_menu) = "menu".
+table_class_to_string(table_class_plain) = "plain".
table_class_to_string(table_class_top_procs) = "top_procs".
%-----------------------------------------------------------------------------%
Index: query.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/query.m,v
retrieving revision 1.22
diff -u -b -r1.22 query.m
--- query.m 4 Aug 2008 03:17:45 -0000 1.22
+++ query.m 4 Aug 2008 08:44:35 -0000
@@ -306,6 +306,8 @@
; Cmd = deep_cmd_restart
; Cmd = deep_cmd_menu
; Cmd = deep_cmd_top_procs(_, _, _, _)
+ ; Cmd = deep_cmd_proc_static(_)
+ ; Cmd = deep_cmd_proc_dynamic(_)
),
create_report(Cmd, Deep, Report),
Display = report_to_display(Deep, Prefs, Report),
@@ -322,6 +324,10 @@
% Cmd = deep_cmd_top_procs(Limit, CostKind, InclDesc, Scope),
% HTML = generate_top_procs_page(Cmd, Limit, CostKind, InclDesc, Scope,
% Pref, Deep).
+% exec(deep_cmd_proc_static(PSI), _Pref, Deep, HTML, !IO) :-
+% HTML = generate_proc_static_debug_page(PSI, Deep).
+% exec(deep_cmd_proc_dynamic(PDI), _Pref, Deep, HTML, !IO) :-
+% HTML = generate_proc_dynamic_debug_page(PDI, Deep).
exec(Cmd, Pref, Deep, HTML, !IO) :-
Cmd = deep_cmd_root(MaybePercent),
@@ -381,10 +387,6 @@
"There is no procedure with that number.\n" ++
page_footer(Cmd, Pref, Deep)
).
-exec(deep_cmd_proc_static(PSI), _Pref, Deep, HTML, !IO) :-
- HTML = generate_proc_static_debug_page(PSI, Deep).
-exec(deep_cmd_proc_dynamic(PDI), _Pref, Deep, HTML, !IO) :-
- HTML = generate_proc_dynamic_debug_page(PDI, Deep).
exec(deep_cmd_call_site_static(CSSI), _Pref, Deep, HTML, !IO) :-
HTML = generate_call_site_static_debug_page(CSSI, Deep).
exec(deep_cmd_call_site_dynamic(CSDI), _Pref, Deep, HTML, !IO) :-
@@ -2289,8 +2291,10 @@
Time = no_time
),
Fields = fields(port, Time, callseqs, no_alloc, memory(units_words)).
+
all_fields = fields(port, ticks_and_time_and_percall, callseqs_and_percall,
alloc, memory(units_words)).
+
default_box = box.
default_colour_scheme = colour_column_groups.
default_ancestor_limit = yes(5).
@@ -2302,6 +2306,7 @@
default_contour = no_contour.
default_time_format = scale_by_thousands.
default_inactive_items = inactive_items(inactive_hide, inactive_hide).
+
%-----------------------------------------------------------------------------%
:- func cmd_separator_char = char.
@@ -2419,8 +2424,7 @@
c(pref_separator_char), s(order_criteria_to_string(Order)),
c(pref_separator_char), s(contour_to_string(Contour)),
c(pref_separator_char), s(time_format_to_string(Time)),
- c(pref_separator_char),
- s(inactive_items_to_string(InactiveItems))
+ c(pref_separator_char), s(inactive_items_to_string(InactiveItems))
]).
string_to_cmd(QueryString, DefaultCmd) = Cmd :-
@@ -2528,8 +2532,7 @@
split(QueryString, pref_separator_char, Pieces),
(
Pieces = [FieldsStr, BoxStr, ColourStr, MaybeAncestorLimitStr,
- SummarizeStr, OrderStr, ContourStr, TimeStr,
- InactiveItemsStr],
+ SummarizeStr, OrderStr, ContourStr, TimeStr, InactiveItemsStr],
string_to_fields(FieldsStr, Fields),
string_to_box(BoxStr, Box),
string_to_colour_scheme(ColourStr, Colour),
Index: report.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/deep_profiler/report.m,v
retrieving revision 1.2
diff -u -b -r1.2 report.m
--- report.m 4 Aug 2008 03:17:45 -0000 1.2
+++ report.m 4 Aug 2008 08:38:14 -0000
@@ -21,6 +21,7 @@
:- interface.
:- import_module list.
+:- import_module maybe.
:- import_module string.
:- import_module measurement_units.
@@ -33,11 +34,22 @@
%-----------------------------------------------------------------------------%
:- type deep_report
- ---> report_message(string)
+ ---> report_message(message_info)
+ ; report_menu(maybe_error(menu_info))
+ ; report_top_procs(maybe_error(top_procs_info))
+ ; report_proc_static_dump(maybe_error(proc_static_dump_info))
+ ; report_proc_dynamic_dump(maybe_error(proc_dynamic_dump_info)).
+
+:- type message_info
+ ---> message_info(
% A simple message, this may be used in response to the
% 'shutdown' and similar queries.
- ; report_menu(
+ string
+ ).
+
+:- type menu_info
+ ---> menu_info(
% Statistics about the deep profiling data. Gives simple
% information about the size of the program and its runtime.
% These statistics are displayed on the menu of the mdprof_cgi
@@ -52,8 +64,10 @@
num_pd :: int,
num_ps :: int,
num_clique :: int
- )
- ; report_top_procs(
+ ).
+
+:- type top_procs_info
+ ---> top_procs_info(
% Information about the most expensive procedures. The ordering
% field defines what measurements are used to select and order
% the procedures in this report.
@@ -62,6 +76,26 @@
top_procs :: list(perf_row_data(report_proc))
).
+:- type proc_static_dump_info
+ ---> proc_static_dump_info(
+ psdi_psptr :: proc_static_ptr,
+ psdi_raw_name :: string,
+ psdi_refined_name :: string,
+ psdi_filename :: string,
+ psdi_linenumber :: int,
+ % Should we list the call_site_statics themselves?
+ psdi_num_call_sites :: int
+ ).
+
+:- type proc_dynamic_dump_info
+ ---> proc_dynamic_dump_info(
+ pddi_pdptr :: proc_dynamic_ptr,
+ pddi_psptr :: proc_static_ptr,
+ pddi_ps_raw_name :: string,
+ pddi_ps_refined_name :: string,
+ pddi_call_sites :: list(call_site_array_slot)
+ ).
+
:- type perf_row_data(T)
---> perf_row_data(
% The item represented by this data row.
cvs diff: Diffing notes
--------------------------------------------------------------------------
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