Commit Graph

43 Commits

Author SHA1 Message Date
Zoltan Somogyi
9095985aa8 Fix more warnings from --warn-inconsistent-pred-order-clauses.
deep_profiler/*.m:
    Fix inconsistencies between (a) the order in which functions and predicates
    are declared, and (b) the order in which they are defined.

    In most modules, either the order of the declarations or the order
    of the definitions made sense, and I changed the other to match.
    In some modules, neither made sense, so I changed *both* to an order
    that *does* make sense (i.e. it has related predicates together).

    In query.m, put the various commands in the same sensible order
    as the code processing them.

    In html_format.m, merge two exported functions together, since
    they can't be used separately.

    In some places, put dividers between groups of related
    functions/predicates, to make the groups themselves more visible.

    In some places, fix comments or programming style.

deep_profiler/DEEP_FLAGS.in:
    Since all the modules in this directory are now free from any warnings
    generated by --warn-inconsistent-pred-order-clauses, specify that option
    by default in this directory to keep it that way.
2017-04-30 15:48:13 +10:00
Zoltan Somogyi
270170416d Bring the style of deep_profiler/* up-to-date.
deep_profiler/*.m:
    Replace ( C -> T ; E ) if-then-elses with (if C then T else E ).

    Replace calls to error/1 with calls to unexpected/3.

    Add some module qualifications where this makes the code easier to read.
2015-07-15 15:30:22 +02:00
Zoltan Somogyi
aa60524d71 Eliminate redundant output from tools/bootcheck.
runtime/mercury_goto.h:
    Cast the "const MR_LabelLayout *" argument of calls
    MR_insert_internal_label, since without this cast, we get C compiler
    warnings in the bootcheck output when the caller passes a
    "const MR_LabelLayoutNoVarInfo *" for this argument.

tests/hard_coded/Mmakefile:
    Redirect the output of the weak_ptr test to a file instead of including it
    in the output of bootcheck itself. The output is maybe be needed in a rare
    cases, but is not needed most of the time.

tests/hard_coded/weak_ptr.m:
    Fix white space.

tests/feedback/Mmakefile:
    Specify verbosity level 0 when invoking mdprof_create_feedback.

deep_profiling/mdprof_create_feedback.m:
    Record the verbosity level when we postprocess the options. We used to
    record it *after* creating the feedback file, and before printing the
    messages gathered during this process. This *mostly* worked, but some
    messages are printed using trace goals *during* the creation of the
    feedback file, and these ignored the specified verbosity level.

deep_profiling/query.m:
    Remove the IO arguments from exec and try_exec, since they do not use them.

deep_profiling/var_use_analysis.m:
    Eliminate some ambiguities by renaming two predicates.

    Simplify some overly complex code.

deep_profiling/autopar_costs.m:
deep_profiling/create_report.m:
deep_profiling/mdprof_cgi.m:
deep_profiling/mdprof_test.m:
    Conform to the above changes.

mdbcomp/feedback.m:
    Fix a typo.
2015-01-22 02:18:08 +11:00
Zoltan Somogyi
340c5300e6 Fix spelling in the deep profiler.
Fix some other issues as well that I found while fixing the spelling.

mdbcomp/feedback.automatic_parallelism.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/mdprof_create_feedback.m:
    Rename the best_par_algorithm type to alg_for_finding_best_par,
    since the old name was misleading. Perform the same rename for
    another type based on it, and the option specifying it.

    Remove the functor estimate_speedup_by_num_vars, since it hasn't
    been used by anything in a long time, and won't in the future.

deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_costs.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/coverage.m:
deep_profiler/create_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_report_feedback.m:
deep_profiler/measurement_units.m:
deep_profiler/measurements.m:
deep_profiler/message.m:
deep_profiler/query.m:
deep_profiler/recursion_patterns.m:
deep_profiler/report.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
mdbcomp/mdbcomp.goal_path.m:
mdbcomp/program_representation.m:
    Conform to the above. Fix spelling errors. In some places, improve
    comments and/or variable names.
2014-12-20 23:05:38 +11:00
Zoltan Somogyi
48473e23b8 On the module summary page, display the link to the module representation page
Estimated hours taken: 0.3
Branches: main

On the module summary page, display the link to the module representation page
only if we actually have access to the module representation.

deep_profiler/report.m:
	Add a field giving this information to the data structure representing
	the module summary page.

deep_profiler/create_report.m:
	Fill in this field when generating module summary information.

deep_profiler/display_report.m:
	Act on this field when displaying module summary pages.
2012-10-24 05:33:07 +00:00
Zoltan Somogyi
2d0bfc0674 The algorithm that decides whether the order independent state update
Estimated hours taken: 120
Branches: main

The algorithm that decides whether the order independent state update
transformation is applicable in a given module needs access to the list
of oisu pragmas in that module, and to information about the types
of variables in the procedures named in those pragmas. This diff
puts this information in Deep.procrep files, to make them available
to the autoparallelization feedback program, to which that algorithm
will later be added.

Compilers that have this diff will generate Deep.procrep files in a new,
slightly different format, but the deep profiler will be able to read
Deep.procrep files not just in the new format, but in the old format as well.

runtime/mercury_stack_layout.h:
	Add to module layout structures the fields holding the new information
	we want to put into Deep.procrep files. This means three things:

	- a bytecode array in module layout structures encoding the list
	  of oisu pragmas in the module;
	- additions to the bytecode arrays in procedure layout structures
	  mapping the procedure's variables to their types; and
	- a bytecode array containing the encoded versions of those types
	  themselves in the module layout structure. This allows us to
	  represent each type used in the module just once.

	Since there is now information in module layout structures that
	is needed only for deep profiling, as well as information that is
	needed only for debugging, the old arrangement that split a module's
	information between two structures, MR_ModuleLayout (debug specific
	info) and MR_ModuleCommonLayout (info used by both debugging and
	profiling), is no longer approriate. We could add a third structure
	containing profiling-specific info, but it is simpler to move
	all the info into just one structure, some of whose fields
	may not be used. This wastes only a few words of memory per module,
	but allows the runtime system to avoid unnecessary indirections.

runtime/mercury_types.h:
	Remove the type synonym for the deleted type.

runtime/mercury_grade.h:
	The change in mercury_stack_layout.h destroys binary compatibility
	with previous versions of Mercury for debug and deep profiling grades,
	so bump their grade-component-specific version numbers.

runtime/mercury_deep_profiling.c:
	Write out the information in the new fields in module layout
	structures, if they are filled in.

	Since this changes the format of the Deep.procrep file, bump
	its version number.

runtime/mercury_deep_profiling.h:
runtime/mercury_stack_layout.c:
	Conform to the change to mercury_stack_layout.h.

mdbcomp/program_representation.m:
	Add to module representations information about the oisu pragmas
	defined in that module, and the type table of the module.
	Optionally add to procedure representations a map mapping
	the variables of the procedure to their types.

	Rename the old var_table type to be the var_name_table type,
	since it contains just names. Make the var to type map separate,
	since it will be there only for selected procedures.

	Modify the predicates reading in module and procedure representations
	to allow them to read in the new representation, while still accepting
	the old one. Use the version number in the Deep.procrep file to decide
	which format to expect.

mdbcomp/rtti_access.m:
	Add functions to encode the data representations that this module
	also decodes.

	Conform to the changes above.

mdbcomp/feedback.automatic_parallelism.m:
	Conform the changes above.

mdbcomp/prim_data.m:
	Fix layout.

compiler/layout.m:
	Update the compiler's representation of layout structures
	to conform to the change to runtime/mercury_stack_layout.h.

compiler/layout_out.m:
	Output the new parts of module layout structures.

compiler/opt_debug.m:
	Allow the debugging of code referring to the new parts of
	module layout structures.

compiler/llds_out_file.m:
	Conform to the move to a single module layout structure.

compiler/prog_rep_tables.m:
	This new module provided mechanisms for building the string table
	and the type table components of module layouts. The string table
	part is old (it is moved here from stack_layout.m); the type table
	part is new.

	Putting this code in a module of its own allows us to remove
	a circular dependency between prog_rep.m and stack_layout.m;
	instead, both now just depend on prog_rep_tables.m.

compiler/ll_backend.m:
	Add the new module.

compiler/notes/compiler_design.html:
	Describe the new module.

compiler/prog_rep.m:
	When generating the representation of a module for deep profiling,
	include the information needed by the order independent state update
	analysis: the list of oisu pragmas in the module, if any, and
	information about the types of variables in selected procedures.

	To avoid having these additions increasing the size of the bytecode
	representation too much, convert some fixed 32 bit numbers in the
	bytecode to use variable sized numbers, which will usually be 8 or 16
	bits.

	Do not use predicates from bytecode_gen.m to encode numbers,
	since there is nothing keeping these in sync with the code that
	reads them in mdbcomp/program_representation.m. Instead, use
	new predicates in program_representation.m itself.

compiler/stack_layout.m:
	Generate the new parts of module layouts.

	Remove the code moved to prog_rep_tables.m.

compiler/continuation_info.m:
compiler/proc_gen.m:
	Make some more information available to stack_layout.m.

compiler/prog_data.m:
	Fix some formatting.

compiler/introduce_parallelism.m:
	Conform to the renaming of the var_table type.

compiler/follow_code.m:
	Fix the bug that used to cause the failure of the
	hard_coded/mode_check_clauses test case in deep profiling grades.

deep_profiler/program_representation_utils.m:
	Output the new parts of module and procedure representations,
	to allow the correctness of this change to be tested.

deep_profiler/mdprof_create_feedback.m:
	If we cannot read the Deep.procrep file, print a single error message
	and exit, instead of continuing with an analysis that will generate
	a whole bunch of error messages, one for each attempt to access
	a procedure's representation.

deep_profiler/mdprof_procrep.m:
	Give this program an option that specifies what file it is to
	look at; do not hardwire in "Deep.procrep" in the current directory.

deep_profiler/report.m:
	Add a report type that just prints the representation of a module.
	It returns the same information as mdprof_procrep, but from within
	the deep profiler, which can be more convenient.

deep_profiler/create_report.m:
deep_profiler/display_report.m:
	Respectively create and display the new report type.

deep_profiler/query.m:
	Recognize a query asking for the new report type.

deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/autopar_types.m:
deep_profiler/branch_and_bound.m:
deep_profiler/coverage.m:
deep_profiler/display.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/query.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/top_procs.m:
deep_profiler/top_procs.m:
	Conform to the changes above.

	Fix layout.

tests/debugger/declarative/dependency.exp2:
	Add this file as a possible expected output. It contains the new
	field added to module representations.
2012-10-24 04:59:55 +00:00
Paul Bone
4a8ff92940 Add extra data to the procedure report in the form of an extra row of data
in the table for the calls into the procedure from its parent call sites.
Note that since this report shows proc static data parent call sites are
defined as calls to the procedure from other procedures (they may include
mutual recursion).  As this may be a point of confusion this information is
only shown in developer mode.

report.m:
    As above.

    We also count the number of calls into this procedure, including the
    numbers of unique ProcStatic and ProcDynamic structures seen.
    The later is trivially the number of calls into the procedure.

create_report.m:
    Generate this data.

display_report.m:
    Handle the new report data.

display.m:
    So that we only show this table row in developer mode, add a new table
    row type (table_developer_row) that contains the real table row.

html_format.m:
    Handle the new table row type.
2012-10-20 12:17:16 +00:00
Zoltan Somogyi
d013a4cfcf Change the types that represent forward and reverse goal paths from being
Estimated hours taken: 20
Branches: main

Change the types that represent forward and reverse goal paths from being
wrappers around lists of steps, to being full discriminated union types.
This is meant to accomplish two objectives.

First, since taking the wrappers off and putting them back on is inconvenient,
code often dealt with naked lists of steps, with the meaning of those steps
sometimes being unclear.

Second, in a future change I intend to change the way the debugger represents
goal paths from being strings to being statically allocated terms of the
reverse_goal_path type. This should have two benefits. One is reduced memory
consumption, since two different goal path strings cannot share memory
but two different reverse goal paths can share the memory containing their
common tail (the goal paths steps near the root). The other is that the
declarative debugger won't need to do any conversion from string to structure,
and should therefore be faster.

Having the compiler generate static terms of the reverse_goal_path type into
the .c files it generates for every Mercury program being compiled with
debugging requires it to have access to the definition of that type and all
its components. The best way to do this is to put all those types into a new
builtin module in the library (a debugging equivalent of e.g.
profiling_builtin.m). We cannot put the definition of the list type into
that module without causing considerable backward incompatibilities.

mdbcomp/mdbcomp.goal_path.m:
	Make the change described above.

	Add some more predicates implementing abstract operations on goal
	paths.

browser/declarative_tree.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_goal.m:
compiler/introduce_parallelism.m:
compiler/mode_ordering.m:
compiler/push_goals_together.m:
compiler/rbmm.condition_renaming.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/unneeded_code.m:
deep_profiler/autopar_costs.m:
deep_profiler/autopar_reports.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/autopar_search_goals.m:
deep_profiler/create_report.m:
deep_profiler/message.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
	Conform to the change in representation. In some cases, remove
	predicates whose only job was to manipulate wrappers. In others,
	replace concrete operations on lists of steps with abstract operations
	on goal paths.

compiler/mode_constraints.m:
	Comment out some code that I do not understand, which I think never
	worked (not surprising, since the whole module has never been
	operational).

mdbcomp/slice_and_dice.m:
	Since this diff changes the types representing goal paths, it also
	changes their default ordering, as implemented by builtin.compare.
	When ordering slices and dices by goal paths, make the ordering
	explicitly work on the forward goal path, since ordering by the
	reverse goal path (the actual data being used) gives nonintuitive
	results.

library/list.m:
	Speed up some code.

mdbcomp/feedback.automatic_parallelism.m:
	Fix some formatting.
2011-09-26 07:08:58 +00:00
Julien Fischer
9f68c330f0 Change the argument order of many of the predicates in the map, bimap, and
Branches: main

Change the argument order of many of the predicates in the map, bimap, and
multi_map modules so they are more conducive to the use of state variable
notation, i.e. make the order the same as in the sv* modules.

Prepare for the deprecation of the sv{bimap,map,multi_map} modules by
removing their use throughout the system.

library/bimap.m:
library/map.m:
library/multi_map.m:
	As above.
NEWS:
	Announce the change.

	Separate out the "highlights" from the "detailed listing" for
	the post-11.01 NEWS.

	Reorganise the announcement of the Unicode support.

benchmarks/*/*.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
extras/*/*.m:
mdbcomp/*.m:
profiler/*.m:
tests/*/*.m:
ssdb/*.m:
samples/*/*.m
slice/*.m:
	Conform to the above change.

	Remove any dependencies on the sv{bimap,map,multi_map} modules.
2011-05-03 04:35:04 +00:00
Zoltan Somogyi
59b0edacbe New module for calculating the overlap between the conjuncts of a
Estimated hours taken: 2

deep_profiler/autopar_calc_overlap.m:
	New module for calculating the overlap between the conjuncts of a
	parallelised conjunction. Its contents are taken from the old
	autopar_search_callgraph.m.

deep_profiler/autopar_costs.m:
	New module for calculating the costs of goals. Its contents
	are taken from the old autopar_search_callgraph.m.

deep_profiler/autopar_reports.m:
	New module for creating reports. Its contents are taken from
	the old autopar_search_callgraph.m.

deep_profiler/autopar_search_goals.m:
	New module for searching goals for parallelizable conjunctions.
	Its contents are taken from the old autopar_search_callgraph.m.

deep_profiler/autopar_search_callgraph.m:
	Remove the code moved to other modules.

deep_profiler/mdprof_fb.automatic_parallelism.m:
	Add the new modules.

deep_profiler/*.m:
	Remove unnecessary imports.
	Fix copyright years on the new modules.

browser/*.m:
compiler/*.m:
mdbcomp/*.m:
	Remove unnecessary imports.

library/Mercury.options:
	Make it possible to compile a whole workspace with
	--warn-unused-imports by turning that option off for type_desc.m
	(which has a necessary import that --warn-unused-imports thinks
	is unused).
2011-01-27 08:03:54 +00:00
Paul Bone
2070f42b24 Refactor goal annotations in the deep profiler.
Goal annotations have previously been attached to goals using type-polymorphism
and in some cases type classes.  This has become clumsy as new annotations are
created.  Using the goal_id code introduced recently, this change associates
annotations with goals by storing them in an array indexed by goal ids.  Many
analyses have been updated to make use of this code.  This code should also be
faster as less allocation is done when annotating a goal as the goal
representation does not have to be reconstructed.

mdbcomp/mdbcomp.goal_path.m:
    Add predicates for working with goal attribute arrays.  These are
    polymorphic arrays that are indexed by goal id and can be used to associate
    information with goals.

deep_profiler/report.m:
    The procrep coverage info report now stores the coverage annotations in a
    goal_attr_array.

deep_profiler/coverage.m:
    The coverage analysis now returns its result in a goal_attr_array rather
    than by annotation the goal directly.

    The interface for the coverage module has changed, it now allows
    programmers to pass a goal_rep to it directly.  This makes it easier to
    call from other analyses.

    The coverage analysis no longer uses the calls_and_exits structure.
    Instead it uses the cost_and_callees structure like many other analyses.
    This also makes it easier to perform this annotation and others using only
    a single call site map structure.

    Moved add_coverage_point_to_map/5 from create_report.m to coverage.m.

deep_profiler/analysis_utils.m:
    Made cost_and_callees structure polymorphic so that any type can be used to
    represent the callees.  (So that either static or dynamic callees can be
    used).

    Added the number of exit port counts to the cost_and_callees structure.

    Added build_static_call_site_cost_and_callees_map/4.

    Rename build_call_site_cost_and_callees_map/4 to
    build_dynamic_call_site_cost_and_callees_map/4.

deep_profiler/var_use_analysis.m:
    Update the var_use_analysis to use coverage information provided in a
    goal_attr_array.

deep_profiler/recursion_patterns.m:
    Update the recursion analysis to use coverage information provided in a
    goal_attr_array.

deep_profiler/program_representation_utils.m:
    Add label_goals/4 to label goals with goal ids and build a map of goal ids
    to goal paths.

    Update pretty printing fucntions to work with either annotation on the
    goals themselves or provided by a higher order value.  The higher order
    argument maps nicly to the function goal_get_attribute/3 in goal_path.m

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Modify goal_annotate_with_instmap, it now returns the instmap annotations
    in a goal_attr_array.

    Conform to changes in:
        program_representation_utils.m
        coverage.m
        var_use_analysis.m

deep_profiler/message.m:
    Updated messagee to more correctly express the problems that
    mdprof_fb.automatic_parallelism.m may encounter.

deep_profiler/create_report.m:
    Conform to changes in coverage.m.

    Make use of code in analysis_utils.m to prepare call site maps for coverage
    analysis.

deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
    Conform to changes in analysis_utils.m.

deep_profiler/display_report.m:
    Conform to changes in program_representation_utils.m.
2011-01-17 01:47:19 +00:00
Paul Bone
d43239d6a7 Move some of the goal path code from compiler/goal_path.m to the mdbcomp
library where it can be used by the deep profiler.

Also move the goal path code from program_representation.m to the new module,
goal_path.m in mdbcomp/

mdbcomp/goal_path.m:
    New module containing goal path code.

mdbcomp/program_representation.m:
    Original location of goal path code.

compiler/goal_path.m:
    Move some of this goal_path code into mdbcomp/goal_path.m

mdbcomp/feedback.automatic_parallelisation.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
browser/debugger_interface.m:
browser/declarative_execution.m:
browser/declarative_tree.m:
compiler/build_mode_constraints.m:
compiler/call_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/coverage_profiling.m:
compiler/deep_profiling.m:
compiler/format_call.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_data.m:
compiler/hlds_goal.m:
compiler/hlds_out_goal.m:
compiler/hlds_out_pred.m:
compiler/hlds_pred.m:
compiler/interval.m:
compiler/introduce_parallelism.m:
compiler/layout_out.m:
compiler/llds.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_ordering.m:
compiler/ordering_mode_constraints.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prop_mode_constraints.m:
compiler/push_goals_together.m:
compiler/rbmm.condition_renaming.m:
compiler/smm_common.m:
compiler/stack_layout.m:
compiler/stack_opt.m:
compiler/trace_gen.m:
compiler/tupling.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unify_gen.m:
compiler/unneeded_code.m:
deep_profiler/Mmakefile:
deep_profiler/analysis_utils.m:
deep_profiler/coverage.m:
deep_profiler/create_report.m:
deep_profiler/display_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/message.m:
deep_profiler/old_query.m:
deep_profiler/profile.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/report.m:
deep_profiler/var_use_analysis.m:
slice/Mmakefile:
slice/mcov.m:
    Conform to the move of the goal path code.
2011-01-13 00:36:56 +00:00
Paul Bone
436d37cc8d Fix a regression that affected coverage profiling and automatic parallelism
analysis.

When instrumenting a program for deep and coverage profiling the compiler adds
goal path information to the program.  The compiler also writes out a bytecode
representation of the program.  The step_switch goal path step includes a field
for the number of functors of the type of the variable that is being switched
upon.  When this is included in the deep profiling data (as it is now) and
these goals paths are used as the indexes in tables the deep profiler cannot
reconstruct matching goal paths from the program representation bytecode,
causing many important map lookups to fail or throw an exception.

We fix this not by preventing the compiler from writing out this information,
but by stripping it out of goal paths before the analysis tool uses those goal
paths.

mdbcomp/program_representation.m:
    Add a new predicate rev_goal_path_remove_type_info/2 that removes
    type-dependant information from goals.

deep_profiler/profile.m:
    Change the goal_path string in the call_site_static type to contain a
    reverse_goal_path rather than a string.  This hides the abstraction of the
    stripping of type dependant information within read_profile.m

deep_profiler/read_profile.m:
    Strip type dependant information from goal path strings as they are read in.

    Conform to changes in profile.m

deep_profiler/report.m:
    In the call site static dump information use a goal_path field rather than
    a string.

deep_profiler/analysis_utils.m:
deep_profiler/create_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/old_query.m:
    Conform to changes in profile.m.

deep_profiler/display_report.m:
    Conform to changes in report.m.
2011-01-06 11:23:44 +00:00
Zoltan Somogyi
a2cd0da5b3 The existing representation of goal_paths is suboptimal for several reasons.
Estimated hours taken: 80
Branches: main

The existing representation of goal_paths is suboptimal for several reasons.

- Sometimes we need forward goal paths (e.g. to look up goals), and sometimes
  we need reverse goal paths (e.g. when computing goal paths in the first
  place). We had two types for them, but

  - their names, goal_path and goal_path_consable, were not expressive, and
  - we could store only one of them in goal_infos.

- Testing whether goal A is a subgoal of goal B is quite error-prone using
  either form of goal paths.

- Using a goal path as a key in a map, which several compiler passes want to
  do, requires lots of expensive comparisons.

This diff replaces most uses of goal paths with goal ids. A goal id is an
integer, so it can be used as a key in faster maps, or even in arrays.
Every goal in the body of a procedure gets its id allocated in a depth first
search. Since we process each goal before we dive into is descendants,
the goal representing the whole body of a procedure always gets goal id 0.
The depth first traversal also builds up a map (the containing goal map)
that tells us the parent goal of ever subgoal, with the obvious exception
of the root goal itself. From the containing goal map, one can compute
both reverse and forward goal paths. It can also serve as the basis of an
efficient test of whether the goal identified by goal id A is an ancestor
of another goal identified by goal id B. We don't yet use this test,
but I expect we will in the future.

mdbcomp/program_representation.m:
	Add the goal_id type.

	Replace the existing goal_path and goal_path_consable types
	with two new types, forward_goal_path and reverse_goal_path.
	Since these now have wrappers around the list of goal path steps
	that identify each kind of goal path, it is now ok to expose their
	representations. This makes several compiler passes easier to code.

	Update the set of operations on goal paths to work on the new data
	structures.

	Add a couple of step types to represent lambdas and try goals.
	Their omission prior to this would have been a bug for constraint-based
	mode analysis, or any other compiler pass prior to the expansion out
	of lambda and try goals that wanted to use goal paths to identify
	subgoals.

browser/declarative_tree.m:
mdbcomp/rtti_access.m:
mdbcomp/slice_and_dice.m:
mdbcomp/trace_counts.m:
slice/mcov.m:
deep_profiler/*.m:
	Conform to the changes in goal path representation.

compiler/hlds_goal:
	Replace the goal_path field with a goal_id field in the goal_info,
	indicating that from now on, this should be used to identify goals.

	Keep a reverse_goal_path field in the goal_info for use by RBMM and
	CTGC. Those analyses were too hard to convert to using goal_ids,
	especially since RBMM uses goal_paths to identify goals in multi-pass
	algorithms that should be one-pass and should not NEED to identify
	any goals for later processing.

compiler/goal_path:
	Add predicates to fill in goal_ids, and update the predicates
	filling in the now deprecated reverse goal path fields.

	Add the operations needed by the rest of the compiler
	on goal ids and containing goal maps.

	Remove the option to set goal paths using "mode equivalent steps".
	Constraint based mode analysis now uses goal ids, and can now
	do its own equivalent optimization quite simply.

	Move the goal_path module from the check_hlds package to the hlds
	package.

compiler/*.m:
	Conform to the changes in goal path representation.

	Most modules now use goal_ids to identify goals, and use a containing
	goal map to convert the goal ids to goal paths when needed.
	However, the ctgc and rbmm modules still use (reverse) goal paths.

library/digraph.m:
library/group.m:
library/injection.m:
library/pprint.m:
library/pretty_printer.m:
library/term_to_xml.m:
	Minor style improvements.
2010-12-20 07:47:49 +00:00
Zoltan Somogyi
8a28e40c9b Add the predicates sorry, unexpected and expect to library/error.m.
Estimated hours taken: 2
Branches: main

Add the predicates sorry, unexpected and expect to library/error.m.

compiler/compiler_util.m:
library/error.m:
	Move the predicates sorry, unexpected and expect from compiler_util
	to error.

	Put the predicates in error.m into the same order as their
	declarations.

compiler/*.m:
	Change imports as needed.

compiler/lp.m:
compiler/lp_rational.m:
	Change imports as needed, and some minor cleanups.

deep_profiler/*.m:
	Switch to using the new library predicates, instead of calling error
	directly. Some other minor cleanups.

NEWS:
	Mention the new predicates in the standard library.
2010-12-15 06:30:36 +00:00
Paul Bone
887a55f783 Make variable use analysis assume that the compiler cannot push signals or
waits for futures across module boundaries, which is usually true.

Add a new option to the feedback tool
--implicit-parallelism-intermodule-var-use.  This option re-enables the old
behaviour.

Fix a number of bugs and improve the pretty-printing of candidate parallel
conjunctions.

deep_profiler/var_use_analysis.m:
    Implement the new behaviour and allow it to be controlled.

    Refactor some code to slightly reduce the number of arguments passed to
    predicates.

deep_profiler/mdprof_feedback.m:
    Implement the new command line option.

    Conform to changes in feedback.automatic_parallelism.m.

deep_profiler/recursion_patterns.m:
    Fixed a bug in the handling of can-fail switches.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Fix a bug in the calculation of dependency graphs.  All goals are
    represented by vertexes and dependencies are edges.  The program failed to
    create a vertex for a goal that had no edges.

    Fix a crash when trying to compute variable use information for a goal that
    is never called.  This was triggered by providing the new variable use
    information in the feedback format.

    Using the extra feedback information improve the pretty-printing of
    candidate parallelisations.

    Conform to changes in feedback.automatic_parallelism.m

    Conform to changes in var_use_analysis.m

mdbcomp/feedback.automatic_parallelism.m:
    Add the new option to control intermodule variable use analysis.

    Provided more information in the candidate parallel conjunctions feedback.

        The costs of the goals before and after the parallel conjunction are
        now provided.

        The cost of every goal is now provided (not just calls)

        Variable production and consumption times of the shared variables are
        provided for each goal if the analysis evaluated them.

    Modified convert_candidate_par_conjunctions_proc/3 and
    convert_candidate_par_conjunction/3 to pass a reference to the current
    parallel conjunction to their higher order argument.

mdbcomp/feedback.m:
    Increment feedback file version number.

deep_profiler/program_representation_utils.m:
    Improve the pretty-printing of goal representations, in particular, their
    annotations.

deep_profiler/create_report.m:
    Conform to changes in var_use_analysis.m.

deep_profiler/display_report.m:
    Conform to changes in program_representation_utils.m.

library/lazy.m:
    Added a new predicate, read_if_val(Lazy, Value) which is true of Lazy has
    already been forced and produced Value.
    (No update to NEWS necessary).
2010-10-16 04:11:05 +00:00
Zoltan Somogyi
58211e2f2e Allow more than 2^15 vars in a procedure representation.
Estimated hours taken: 12
Branches: main

Allow more than 2^15 vars in a procedure representation.

mdbcomp/program_representation.m:
	Allow a variable number to be represented by four bytes as well as
	two and one. This means that we also have to represent the number
	of variables in a procedure using a four-byte number, not a two-byte
	number.

	Use four bytes to represent line numbers. Programs that overflow
	16-bit var numbers may also overflow 16 bit line numbers.

	These requires a change in the deep profiler data's binary
	compatibility version number.

compiler/prog_rep.m:
	Encode vars using four bytes if necessary. Be consistent in using
	only signed 8-bit as well as signed 16-bit numbers.

compiler/implicit_parallelism.m:
	Conform to the change in program_representation.m.

deep_profiler/profile.m:
deep_profiler/read_profile.m:
	Add a compression flag to the set of flags read from the data file.
	Put the flags into the profile_stats as a group, not one-by-one.

deep_profiler/canonical.m:
deep_profiler/create_report.m:
deep_profiler/dump.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
deep_profiler/query.m:
	Conform to the change in profile.m.

runtime/mercury_deep_profiling.c:
	Prepare for compression of profiling data files being implemented.

runtime/mercury_stack_layout.h:
	Fix some documentation rot.

runtime/mercury_conf_param.h:
	Add an implication between debug flags to make debugging easier.
2010-10-11 00:49:27 +00:00
Paul Bone
881039cfed Correct problems in the automatic parallelism analysis.
This patch fixes various problems, the most significant is the calculation of
variable use information.  The parallelisation analysis uses deep profiling
data.  In other words, profiling data that is attached to context information
referring to not just the procedure but the chain of calls leading to that
invocation of that procedure (modulo recursion).  The variable use analysis did
not use deep profiling data, therefore comparing the time that a variable is
produced with a call to the time in total of that call was not sound, and
sometimes resulted in information that is not possible, such as a variable
being produced or consumed after the call that produces or consumes it has
exited.

This change-set updates the variable use analysis to use deep profiling data to
avoid these problems.  At the same time it provides more accurate information
to the automatic parallelisation pass.  This is possible because of an earlier
change that allowed the coverage data to use deep profiling data.

In its current state, the parallelisation analysis now finishes without errors
and computes meaningful results when analysing a profile of the mercury
compiler's execution.

deep_profiler/report.m:
    The proc var use report is now a call site dynamic var use report.
       1) It now uses deep profiling data.
       2) It makes more sense from the callers perspective so it's now based
          around a call site rather than a proc.

    Add inst subtypes to the recursion_type type.

deep_profiler/query.m:
    The proc var use query is now a call site dynamic var use query, see
    report.m.

deep_profiler/var_use_analysis.m:
    Fix a bug here and in mdprof_fb.automatic_parallelism.m: If a
    variable is consumed by a call and appears in it's argument list more than
    once, take the earliest consumption time rather than the one for the
    earliest argument.

    Variable use analysis now uses recursion_patterns.m to correctly compute
    the cost of recursive calls.  It also uses 'deep' profiler data.

    Only measure variable use relative to the entry into a procedure, rather
    than either relative to the entry or exit.  This allows us to simplify a
    lot of code.

deep_profiler/create_report.m:
    The proc var use info report is now a call site dynamic var use info
    report.

    Move some utility code from here to the new analysis_utils.m module.

deep_profiler/display_report.m:
    Conform to changes in report.m.

    Improve the information displayed for variable first-use time
    reports.

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Conform to changes in report.m

    Refactored the walk down the clique tree.  This no-longer uses the
    clique reports from the deep profiling tool.

    We now explore the same static procedure more than once.  It may be best to
    parallelise it in some contexts rather than others but for now we assume
    that the benefits in some context are worth the costs without benefit in
    the other contexts.  This is better than reaching a context where it is
    undesirable first and never visiting a case where parallelisation is
    desirable.

    Fix a bug in the calculation of how much parallelisation is used by
    parallelisations in a clique's parents.  This used to trigger an
    assertion.

    Don't try to parallelize anything in the "exception" module.
    There's probably other builtin code we should skip over here.

    Removed an overzealous assertion that was too easily triggered by the
    inaccuracies of IEEE-754 arithmetic.

    Compute variable use information lazily for each variable in each call.  I
    believe that this has made our implementation much faster as it no-longer
    computes information that is never used.

    Refactor and move build_recursive_call_site_cost_map to the new
    module analysis_utils.m where it can be used by other analyses.

    Call site cost maps now use the cs_cost_csq type to store costs,
    code in this module now conforms to this change.

    Conform to changes in messages.m

deep_profiler/recursion_patterns.m:
    Export a new predicate, recursion_type_get_maybe_avg_max_depth/2.  This
    retrieves the average maximum recursion depth from recursion types that know
    this information.

    Move code that builds a call site cost map for a procedure to
    analysis_utils.m where it can be used by other analyses.

deep_profiler/analysis_utils.m:
    Added a new module containing various utility predicates for profile
    analysis.

deep_profiler/coverage.m:
    Added an extra utility predicate get_coverage_after/2.

deep_profiler/message.m:
    Each message has a location that it refers to, a new location type has
    been added: call_site_dynamic.

    Added a new warning that can be used to describe when a call site's
    argument's use time cannot be computed.

    Added new predicates for printing out messages whose level is below a
    certain threshold.  These predicates can be called from io trace goals.
    Message levels start at 0 and currently go to 4, more critical messages
    have lower levels.  The desired verbosity level is stored in a module local
    mutable.

deep_profiler/mdprof_feedback.m:
    Move the message printing code from here to message.m.

deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
    Conform to changes in query.m.

mdbcomp/feedback.automatic_parallelism.m:
    Added a new function for computing the 'cpu time' of a parallel
    computation.

library/lazy.m:
    Moved lazy.m from extras to the standard library.

library/list.m:
    Add a new predicate member_index0/3.  Like member/2 except it also gives
    the zero-based index of the current element within the list.

library/maybe.m:
    Add two new insts.
        maybe_yes(I) for the maybe type's yes/1 constructor.
        maybe_error_ok(I) for the maybe_error type's ok/1 constructor.

library/Mercury.options:
    Add a work around for compiling lazy.m with intermodule optimisations.

NEWS:
    Update news file for the addition of lazy.m and the member_index0 predicate
    in list.m

deep_profiler/.cvsignore:
    Ignore feedback.automatic_parallelism.m which is copied by Mmakefile from
    the mdbcomp/ directory.
2010-10-07 02:38:10 +00:00
Paul Bone
cb03062118 Fix a coverage propagation bug.
Coverage propagation only relies on coverage points for code that it cannot
infer coverage from call site port counts alone.  However since using dynamic
coverage points I had not updated this code to also use port counts from
dynamic call sites rather than static call sites.

This patch fixes this by using port counts from dynamic call sites when doing
coverage propagation with dynamic coverage points.

deep_profiler/coverage.m:
    Introduce a new type calls_and_exits which stores the number of calls and
    exits for a given call site.

    procrep_annotate_with_coverage now uses calls_and_exits rather than
    own_prof_info structures to represent call sites.

deep_profiler/create_report.m:
    Use port counts from dynamic call sites when creating dynamic coverage
    reports.

deep_profiler/mdprof_test.m:
    Add functionality that allows us to test creation of dynamic call site
2010-09-23 04:33:19 +00:00
Paul Bone
067934f008 Start using the new dynamic coverage information in the deep profiler.
This patch separates the coverage annotated procedure report into two
reports, one with dynamic coverage data and one with static coverage data.
This restores the functionality of the static coverage report since my last
change, and provides access to the dynamic report via new controls only
visible to developers.

deep_profiler/query.m:
    In the cmd data-type:

        Rename deep_cmd_procrep_coverage constructor to
        deep_cmd_static_procrep_coverage.

        Add deep_cmd_procrep_dynamic_coverage.

    In the preferences data-type:

        Add a new field pref_developer_mode which indicates if developer-only
        options are visible or not.

    Add code to parse and print the new command and preference option.

deep_profiler/create_report.m:
    Specialise create_procrep_coverage_report/3 into
    create_{static,dynamic}_coverage_report/4.

    Created a new exported function deep_get_maybe_procrep.  This is useful for
    getting a procedure representation from the deep data-structure in one
    step.

deep_profiler/display.m:
    Add a new display item, display_developer.  This wraps another display
    item but is only displayed when developer mode is active.

deep_profiler/display_report.m:
    Add a control to the main screen that enables or disabled developer mode.
    This control has been placed at the bottom of the screen so that it's out
    of the way.

    Put the developer controls on the main screen into their own list (there's
    only one at the moment).

    For now the coverage-annotated procedure representation link on a (static)
    procedure's page is not a developer option.  Should this be a developer
    option?

    Added a link to the dynamic coverage annotated procedure representation
    report from the dump proc dynamic report.

    Added a link to the clique dump report from the clique report, the dynamic
    coverage annotated procedure representation report can be accessed
    transitively through this link.

    Added a link the variable use analysis report and proc static report to the
    procedure report and static coverage annotated procedure representation
    report.

deep_profiler/html_format.m:
    Support the new display_developer item.

    Refactor the item_to_html code for lists.

deep_profiler/profile.m:
    Include a new field in the deep data-structure for storing coverage data
    that is indexed by a proc_static_ptr.  When dynamic coverage information is
    used this field is populated by adding per ProcDynamic data for each static
    procedure.

deep_profiler/startup.m:
    Fill in the per ProcStatic coverage data when the deep profiler starts up.

deep_profiler/measurements.m:
    Create a new data type static_coverage_info which represents per ProcStatic
    coverage information.

    Include functions that are used when calculating per ProcStatic coverage
    information from per ProcDynamic coverage information.

deep_profiler/mdprof_cgi.m:
    Remove rarely used command line option rather making it conform to changes
    in query.m.

deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
    Conform to changes in query.m.

deep_profiler/mdprof_test.m:
deep_profiler/mdprof_fb.automatic_parallelism.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
    Conform to changes in create_report.

deep_profiler/array_util.m:
    Add a new predicate, array_foldl3_from_1 to support propagation of coverage
    information from proc dynamics to proc statics.
2010-09-22 12:56:54 +00:00
Paul Bone
7e7d77e23f Make coverage profiling data 'deep'.
The deep profiler associates measurements with their context in the call graph
modulo recursion.  This has been true for all measurements except for coverage
profiling data.  This patch allows coverage data to be associated with
ProcDynamic structures so that it is keyed by this context not just the static
procedure.  This new behaviour is the default the old option of static coverage
profiling is still available for testing, as is no coverage profiling.  Note
that, as before, coverage profiling is supported by default however coverage
points are not inserted by default.

This change will be used to measure the depth of recursion, and therefore the
average cost of recursion as well as the likely times when variables are
produced in calls for the automatic parallelisation analysis.

runtime/mercury_conf_param.h:
    Create three new preprocessor macros:
        MR_DEEP_PROFILING_COVERAGE - defined when coverage profiling is
            enabled.
        MR_DEEP_PROFILING_COVERAGE_STATIC - defined when static coverage
            profiling is being used.
        MR_DEEP_PROFILING_COVERAGE_DYNAMIC - defined when dynamic coverage
            profiling is being used.

runtime/mercury_deep_profiling.h:
    Update data structures to support dynamic coverage profiling.

    Use conditional compilation to allow us to test the deep profiler in three
    different modes, without coverage profiling, with static coverage profiling
    and with dynamic coverage profiling.

    Rename MR_PROFILING_MALLOC, since it takes a type rather than a size in
    bytes it should be called MR_PROFILING_NEW to conform with existing malloc
    and new functions.

runtime/mercury_deep_profiling.c:
    Avoid a C compiler warning.

    MR_write_out_coverage_point has been removed, it's replaced with:
        MR_write_out_coverage_points_static and
        MR_write_out_coverage_points_dynamic.
    These write out more than one coverage point and write out either static or
    dynamic coverage points.

    Write a 64bit flags value (a bitfield) to the header of the Deep.data file.
    This replaces the canonical byte (with a bit).  and the byte that describes
    the word size.  This value also includes two bits describing the whether no
    coverage data, static coverage data or dynamic coverage data is present in
    the file.  A bit is reserved ti indicate if the data is compressed (which
    is not yet supported).

    MR_write_fixed_size_int now writes out 8 byte integers, this is only used
    for some counts present at the beginning of the data file along with the
    new flags value.  It now takes a MR_uint_least64_t integer as it's
    parameter.  The assertion to test for negative numbers has been removed
    since this type is unsigned.

    Increment the Deep.data file format version number.

compiler/layout_out.m:
    Conditionally compile the NULL pointer that represents the coverage points
    list in proc statics.  This is conditional on the
    MR_DEEP_PROFILING_COVERAGE_STATIC macro being defined.

compiler/coverage_profiling.m:
    Add support for generating dynamic coverage points.

compiler/options.m:
compiler/handle_options.m:
    Implement the new developer options for controlling coverage profiling.

library/profiling_builtin.m:
    Specialize increment_coverage_point_count for both static and dynamic
    coverage profiling.  This creates
    increment_{static,dynamic}_coverage_point_count.

deep_profiler/profile.m:
    Add an extra field to profile_stats, this tracks whether the file reader
    should try to read none, static or dynamic coverage data.

    Add an extra field to proc_dynamic, An array of coverage counts wrapped by
    a maybe type.  It's indexed the same as the array of coverage infos in
    proc_static.  This array is present if dynamic coverage profiling is being
    done (the default).

    Modify the coverage_points field in proc static, now there are two fields,
    an array of coverage_point_info values which store compile-time data.  And
    an optional array of coverage points (present if static coverage profiling
    was performed).

    Updated the formatting of the proc static structure.

    Moved the coverage_point type to coverage.m.

    Created a new type, coverage_data_type which enumerates the possibilities
    for coverage profiling: none, static and dynamic.

deep_profiler/coverage.m:
    Move the coverage point type here from profile.m, as the profile data
    structure no longer refers to it directly.

    Create a predicate coverage_point_arrays_to_list/3 which merges coverage
    point information and the counts themselves into coverage points.  This can
    be used to construct a list of coverage points regardless of whether static
    or dynamic coverage points are being used.

deep_profiler/read_profile.m:
    Conform to changes in runtime/mercury_deep_profiling.c.

    Refactored reading of the file header, a new named predicate is now used
    rather than a lambda expression.

    Incremented the Deep.data version number.

deep_profiler/report.m:
    Updated the proc dynamic dump report structure to include a list of
    coverage points.

deep_profiler/create_report.m:
deep_profiler/display_report.m:
    Conform to changes in profile.m.

    The proc dynamic dump now shows coverage information that was contained in
    that proc dynamic.

deep_profiler/canonical.m:
deep_profiler/dump.m:
    Conform to changes in profile.m.

deep_profiler/io_combinator.m:
    Add a 13-arg version of maybe_error_sequence.

deep_profiler/Mercury.options:
    Documented another trace flag.
2010-09-21 01:09:17 +00:00
Paul Bone
6aee01800e Improve the performance of coverage propagation.
Modify coverage propagation code so that it uses less memory.  This makes the
recursion frequency query roughly 8% faster.

Avoid generating call site summary reports for every call site in a procedure
when doing coverage propagation.  Coverage propagation only needs the number of
calls and exits, generating the other data was overkill and expensive.  This
makes the recursion frequency query roughly 46 times faster.  It now finishes
in roughly 50 rather than 36 minutes.  This was tested once the above change
had already been made.  It's possible that the above change had more of an
impact than was measured.

These speed improvements where measured using a profile for the Mercury
compiler's execution.

deep_profiler/coverage.m:
    Create special constructor symbols in our data types for cases where
    execution counts are zero because the code is never executed.  This is
    relatively common.  This uses less memory and causes fewer dereferences
    during execution.

    Change the type of the call sites map passed to the coverage propagation
    code.  It now uses values of the type own_prof_info rather than
    call_site_perf.  The own_prof_info structures are already available in the
    deep data-structure where as the call_site_perf structures must be
    generated manually.

deep_profiler/create_report.m:
    Conform to changes in coverage.m.

    In particular build a call site map mapping goal paths to own_prof_info
    values rather than call_site_perf values.  This is where the second
    performance improvement has been made.

deep_profiler/display_report.m:
    Conform to changes in coverage.m.
2010-08-30 01:12:25 +00:00
Paul Bone
699663e5e2 Deep profiler enhancements.
Create two new deep profiler reports: the first calculates the costs of
recursive calls at any depth of recursion for a clique.  The second summarises
the types of recursion seen in a program.

deep_profiler/query.m:
    Introduce new cmd types.

    Conform to changes of the cmd type.

    Add a new preference: the maximum number of proc statics to display for
    each recursion type.

    Memoize the creation of the recursion types histogram report as it can take
    a while to generate, 39 minutes on a Core 4 when generating a report for
    the compiler it's self.

deep_profiler/report.m:
    Define the new report structures.

deep_profiler/create_report.m:
    Handle creation of the new reports.

    Export describe_proc and own_and_inherit_to_perf_row_data so that the
    recursion_patterns module can use them.

    Write a find_clique_first_and_other_procs predicate to find the first
    procedure in a clique, it also returns a list of the remaining procedures.
    This is exported so that recursion_patterns can use it but it belongs here
    as it is generally used for creating reports.

    Refactor the retrieval of the progrep data from the deep data structure.

    Make a note about a change that could be made to speed up large analyses.

deep_profiler/profile.m:
    Refactor the retrieval of the progrep data from the deep data structure.

deep_profiler/display_report.m:
    Handle translation of the new reports to the display data type.

    Link to this report from clique reports, and to clique reports from the new
    clique recursion costs report.

    Refactor the code that constructs the lists of related reports.

deep_profiler/recursion_patterns.m:
    Create a new module to contain the recursion pattern analysis code.

deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
    Conform to changes in query.m

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Remove add_call_site_to_map it is a duplicate of add_call_site_report_to_map.

    Move add_call_site_report_to_map and proc_label_from_proc_desc to report.m

deep_profiler/measurement_units.m:
    Include functions to manipulate probabilities of conjoint and disjoint events.

    Allow percentages to be greater than 100% and less than 0% this can occur
    legitimately in some cases.

deep_profiler/measurements.m:
deep_profiler/var_use_analysis.m:
    Move weighted_average/3 from var_use_analysis.m to measurements.m where it
    can be used globally.

deep_profiler/mdprof_test.m:
    Modify the mdprof_test program so that it can generate the recursion types
    histogram report, this is useful for profiling and debugging.
2010-08-26 06:29:27 +00:00
Paul Bone
f16e8118bd Implement a linear alternative to the exponential algorithm that determines how
best to parallelise a conjunction.

Made other performance improvements.

mdbcomp/feedback.m:
    Add a field to the candidate_parallel_conjunction_params structure giving
    the preference of algorithm.

    Simplify the parallel exec metrics type here.  It is now used only to
    summarise information that has already been calculated.  The original code
    has been moved into deep_profiler/measurements.m

    Add a field to the candidate_par_conjunction structure giving the index
    within the conjunction of the first goal in the partition.  This is used
    for pretty-printing parallelisation reports.

    Incremented the feedback format version number.

deep_profiler/measurements.m:
    Move the original parallel exec metrics type and code here from
    mdbcomp/feedback.m

deep_profiler/create_report.m:
    Avoid a performance issue by memoizing create_proc_var_use_dump_report
    which is called by the analysis for the same procedure (at different
    dynamic call sites) many times.  In simple cases this more than doubled the
    execution time, in more complicated cases it should perform even better.

    Conform to changes in coverage.m

deep_profiler/mdprof_fb.automatic_parallelism.m:
    Implement the linear algorithm for parallelising a conjunction.

    Since we don't to parallelism specialisation don't try to parallelise the
    same procedure more than once.  This should avoid some performance problems
    but I haven't tested it.

    If it is impossible to generate an independent parallelisation generate a
    dependent one and then report it as something we cannot parallelise.  This
    can help programmers write more independent code.

    Use directed graphs rather than lookup maps to track dependencies.  This
    simplifies some code as the digraph standard library module already has
    code to compute reverse graphs and transitive closures of the graphs.

    Since there are now two parallelisation algorithms; code common to both of
    them has been factored out.

    The objective function used by the branch and bound search has been
    modified to take into account the overheads of parallel execution.  It is:
        minimise(ParTime + ParOverheads X 2.0)
    This way we allow the overheads to increase by 1csc provided that it
    reduces ParTime by more than 2csc.  (csc = call sequence counts)

    When pretty-printing parallelisation reports print each goal in the
    parallelised conjunction with it's new goal path.  This makes debugging
    easier for large procedures.

    Fix a bug where the goal path of scope goals was calculated incorrectly,
    this lead to a thrown exception in the coverage analysis code when it used
    the goalpath to lookup the call site of a call.

deep_profiler/mdprof_feedback.m:
    Support a new command line option for choosing which algorithm to use.
    Additionally the linear algorithm will be used if the problem is above a
    certain size and the exponential algorithm was chosen.  This can be
    configured including the fallback threshold.

    Print the user's choice of algorithm as part of the candidate parallel
    conjunctions report.

deep_profiler/message.m:
    Add an extra log message type for exceptions thrown during auto
    parallelisation.

deep_profiler/program_representation_utils.m:
    The goal_rep pretty printer now prints the goal path for each goal.

deep_profiler/coverage.m:
    procrep_annotate_with_coverage now catches and returns exceptions in a
    maybe_error result.

deep_profiler/cliques.m:
    Copy predicates from the standard library into cliques.m to prevent the
    lack of tail recursion from blowing the stack in some cases.  (cliques.m is
    compiled with --trace minimum).

deep_profiler/callgraph.m:
    Copy list.foldl from the standard library into callgraph.m and transform it
    so that it is less likely to smash the stack in non tail-recursive grades.

deep_profiler/read_profile.m:
    Transform read_nodes so that it is less likely to smash the stack in non
    tail-recursive grades.

deep_profiler/Mercury.options:
    Removed old options that where used to work around a bug.  The bug still
    exists but the work-around moved into the compiler long ago.
2010-08-04 02:25:02 +00:00
Zoltan Somogyi
190764a083 Fix some usability problems in the deep profiler.
Estimated hours taken: 8
Branches: main

Fix some usability problems in the deep profiler.

deep_profiler/exclude.m:
	Provide a better, more explicit representation of the contour exclusion
	file. This representation allows the application of contour exclusion
	even if the contour exclusion file contains some unrecognized module
	names. This is useful, because some modules of the Mercury standard
	library, such as profiling_builtin and mer_std, are unrecognized.
	They are unrecognized because either they export no predicates,
	or because deep profiling is turned off for them.

deep_profiler/query.m:
	Make a provision for controlling the number of a procedure's callers
	displayed at a time.

deep_profiler/create_report.m:
	Take advantage of the new capabilities listed above.

deep_profiler/display_report.m:
	When listing a procedure's callers, print any warning messages
	generated at startup about recognized modules.

	When listing a procedure's callers, list the application of contour
	exclusion among the links only if contour exclusion is in fact
	applicable.

	When listing a procedure's callers, allow the user to control how
	many callers are shown at a time. Make the default bunch size 20,
	instead of previous hardwired (and too small) 5.

	Fix some counterintuitive behavior. When clicking on one of the fields
	in the header of a table, in all but one of the displayed reports, this
	sorts the data being displayed on the selected column. The exception
	was top_procs, in which it changed the criterion on which the top_procs
	were selected, and thus changed the procedures being displayed as well.
	This diff eliminates the exception. The links in the header cells now
	do the expected thing, obeying the law of least astonishment. The
	criterion for selected what procs are top can still be changed using
	the already existing (and previously mostly redundant) links below
	the table.

deep_profiler/startup.m:
	Look for contour exclusion files not in Deep.data.contour, but in
	Deep.contour, since this is more consistent with what we do for other
	auxiliary files, like Data.procrep.

	Make the reading of the exclusion file and the program representation
	file part of the normal startup process, instead of setting their
	fields to dummies and filling them in with real values later.

	If there is a program representation file, make sure that the names
	of the modules in it are not unrecognized by contour exclusion.

	Fix a minor old bug: don't count the time spent reading Deep.contour
	as part of the propagation pass.

	Print meaningful messages (to the log file in /var/tmp) about
	any problems in reading Deep.contour files.

deep_profiler/apply_exclusion.m:
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
deep_profiler/profile.m:
deep_profiler/report.m:
	Conform to the changes above.

doc/user_guide.texi:
	Document contour exclusion, and to make this possible, expand
	considerably the documentation of the deep profiler as a whole.

doc/Mmakefile:
	Ensure that invocations of latex cannot hang waiting for user input.
2009-10-02 04:38:22 +00:00
Zoltan Somogyi
a34eb73d2d Several improvements to make the deep profiler more convenient to use.
Estimated hours taken: 6
Branches: main

Several improvements to make the deep profiler more convenient to use.

deep_profiler/mdprof_cgi.m:
	If the data file does not end in .data, generate an explicit error
	message. Without this, the deep profiler just hangs forever on such
	filenames.

deep_profiler/query.m:
	Add a couple more categories of user preferences. The first new
	category controls whether, in reports for procedures and cliques,
	the deep profiler will display call sites through which there were no
	calls. The second new category controls whether the deep profiler
	includes module qualifications in the names of procedures. Module
	qualifying everything, as we did before, can clutter up the output,
	so the new default is to module qualify only the names of procedures
	that are in different modules from the module that defines the current
	procedure.

deep_profiler/profile.m:
deep_profiler/report.m:
	Remember module names and unqualified as well as qualified names
	of procedures.

deep_profiler/create_report.m:
deep_profiler/read_profile.m:
	Remember the newly needed information.

deep_profiler/display_report.m:
	Implement the two new categories of preferences.

	When generating the menu, make the "follow the action" links
	more useful by implicitly preferring to (a) hide inactive call sites,
	and (b) sort by overall time.

	When sorting by time, if two times (clock ticks) are equal,
	try to use call sequence numbers to resolve the order.

	When generating the menu, print the total quanta as well as the total
	runtime computed from it.

deep_profiler/dump.m:
deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
	Conform to the changes above.
2009-09-08 02:37:15 +00:00
Paul Bone
bc58393e31 Fix an issue when displaying a clique report.
Estimated hours taken: 2.5
Branches: main

Fix an issue when displaying a clique report.  Calls from the current clique
into the same clique should be labeled with the procedure that they call
rather than the cliques entry procedure.  These are not-always the same thing.

deep_profiler/create_report.m:
	As above.
2009-02-07 07:13:15 +00:00
Zoltan Somogyi
dd5de9e8e5 Add a query to the deep profiler for reporting on the getter and setter
Estimated hours taken: 12
Branches: main

Add a query to the deep profiler for reporting on the getter and setter
predicates in a module. This can be used to decide whether a data structure
should be split in two, and if so, which fields should go into the
substructure.

At the same time, improve the displays we generate for some other queries
by making more table column headers capable of sorting the table.

deep_profiler/query.m:
	Add the new query type.

deep_profiler/report.m:
	Add the definition of the new report.

	Include the identity of the callee, if known, in call site
	descriptions, to allow sorting on this.

deep_profiler/create_report.m:
	Add code to execute the new kind of query.

	Include the new field in call site descriptions.

	Remove "dump" from the name of the predicate that builds
	procrep_coverage reports, since the result isn't a raw dump.

deep_profiler/display_report.m:
	Add code to display the new kind of report.

	Add a link to the new report to display we generate for the module
	query.

	Allow the table in the procedure report to be sorted by context
	or by callee.

deep_profiler/display.m:
	Add a new table column class for displaying field names.

deep_profiler/html_format.m:
	Handle the new table column class.

deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
	"Handle" the new query.
2009-01-02 02:59:36 +00:00
Zoltan Somogyi
3ad840ebb2 Increase the deep profiler's cohesion by dividing the
Estimated hours taken: 1
Branches: main

Increase the deep profiler's cohesion by dividing the
program_representation_utils.m module into three files:

- coverage.m containing the coverage analysis algorithm,
- var_use_analysis.m containing the variable use analysis algorithm, and
- program_representation_utils.m itself containing generally useful predicates
  working on program representations.

The last is actually the smallest file.

There are no algorithm changes, only the movement of code and a few minor
fixes of white space and typos in comments.

deep_profiler/coverage.m:
deep_profiler/var_use_analysis.m:
	New modules, as described above.

deep_profiler/program_representation_utils.m:
	Delete the code moved to the new modules.

mdbcomp/program_representation.m:
	Move some utility types and predicates here from
	deep_profiler/program_representation_utils.m, since they may be useful
	for other tasks.

deep_profiler/report.m:
	Move the data types specific to coverage and var use analysis to the
	new modules, along with the utility predicates operating on them.

	Import the new modules as needed.

deep_profiler/create_report.m:
deep_profiler/displayreport.m:
deep_profiler/mdprof_feedback.m:
	Import the new modules as needed.
2008-11-05 03:38:40 +00:00
Paul Bone
f23dc12e7b Add an analysis report to the deep profiler that can determine when an
Estimated Hours Taken: 15
Branches: main

Add an analysis report to the deep profiler that can determine when an
argument to a procedure is likely to be consumed or produced.  This is useful
for determining the parallelism within dependant conjunctions.

Due to limitations in the deep profiler recursive code cannot be handled well,
the following two problems (and workarounds) exist.

	If the variable we're searching for uses of is consumed or produced within
	a recursive (or mutually recursive) call, we do not follow this recursion.
	Instead assume a pessimistic default, that if the call produces the
	variable assume it's produced at the end of the call, if the call consumes
	the variable assume it's consumed at the beginning of the call.

	When calculating the cost of a goal that occurs before a consumption or
	after a production we cannot relative an accurate cost of a recursive call
	from the deep profiler (A cost of 1.0 is returned).

deep_profiler/report.m:
	Add the new report structure.

deep_profiler/program_representation_utils.m:
	The code for the new analysis depends on the program representation
	bytecode, it has been added to this module.

deep_profiler/create_report.m:
	Code to create the new report.

deep_profiler/display_report.m:
	Basic code to display the report.

deep_profiler/query.m:
	Include support for parsing and running the commands that refer to this
	new report.
	Conform to changes in report.m

deep_profiler/old_html_format.m:
deep_profiler/old_query.m:
	Conform to changes in report.m
2008-10-16 01:16:36 +00:00
Paul Bone
4338d32859 Remove the goal path field from from the call_site_perf structure since it's
Estimated hours taken: 0.5
Branches: main

Remove the goal path field from from the call_site_perf structure since it's
superfluous.

deep_profiler/report.m:
    As above.
    Make the goal_path field in the call_site_desc structure store a goal path
    rather than a string representing one.

deep_profiler/create_report.m:
deep_profiler/display_report.m:
    Conform to changes in report.m
2008-10-05 06:31:06 +00:00
Zoltan Somogyi
c91f385afc Put the program representation inside the deep profiler's main data structure,
Estimated hours taken: 1
Branches: main

Put the program representation inside the deep profiler's main data structure,
since this simplifies things. (We already handled the contents of the
exclusion threshold file this way.)

deep_profiler/profile.m:
	Change the data structure's type definition as above.

deep_profiler/create_report.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/query.m:
	Conform to the change above.

deep_profiler/startup.m:
	Conform to the change above.

	Rename a predicate to avoid ambiguity.
2008-10-03 07:39:04 +00:00
Zoltan Somogyi
be95a5c643 Move the remaining deep profiler commands, dump_clique, clique and root,
Estimated hours taken: 20
Branches: main

Move the remaining deep profiler commands, dump_clique, clique and root,
to the report mechanism.

deep_profiler/report.m:
	Define the representation of the new reports.

	Change some names to be more consistent.

deep_profiler/create_report.m:
	Add code to create the new reports.

deep_profiler/measurement units.m:
	Add a predicate to needed by the root command.

deep_profiler/display_report.m:
	Add code for converting the new reports to displays.

	Factor out some previously duplicated code for describing procedures
	and call sites and for comparing them by name and by context.

	Conform to the changes in display.m.

deep_profiler/display.m:
	Expand the display representation to allow the specification of
	attributed text, with the available attributes being bold, italic
	and underlined. We now use bold in clique reports.

deep_profiler/html_format.m:
	Handle the changes in display.m.

	Generate HTML with more structured line breaks.

deep_profiler/query.m:
	Switch the default handling of the three commands over to the new
	mechanism.

	Remove a long unused function.

deep_profiler/profile.m:
	Parameterize the call_site_and_callee type, to allow report.m
	to associate a procedure description, not a proc_static_ptr,
	with a normal call site.
2008-09-25 03:47:03 +00:00
Paul Bone
93abae4b7b Changes to coverage profiling system. Remove the 3 'solution count' style
Estimated hours taken: 0.5
Branches: main

Changes to coverage profiling system.  Remove the 3 'solution count' style
coverage point type and replace them with a single 'coverage after goal'
coverage point type.  Insert a coverage point after a goal even if the goal is
deterministic, therefor the separate coverage points used for goals of
different determinisms no-longer make sense.

mdbcomp/program_representation.m:
    Modify the coverage point types, and their foreign enumeration.

runtime/mercury_deep_profiling.h:
    Modify C enumeration of coverage point types.

compiler/options.m:
compiler/handle_options.m:
    Update coverage profiling options to match available coverage point types.

compiler/deep_profiling.m:
    Conform to changes in mdbcomp/program_representation.m and
    compiler/options.m.
    Insert coverage points after goals regardless of their determinism.

deep_profiler/create_report.m:
    Conform to changes in mdbcomp/program_representation.m
2008-09-20 11:38:05 +00:00
Paul Bone
8658fc1cc9 Introduce a new report type in the deep profiler tools.
Branches: main

Introduce a new report type in the deep profiler tools.  The procedure
representation coverage report displays a representation of the procedure,
annotated with determinism and coverage information.  This allows a programmer
to view the most frequently taken execution paths through a procedure,

This report is available when the program has been compiled for coverage
profiling, and when a Deep.procrep file is available.

deep_profiler/report.m:
	The coverage profiling dump report is now a coverage_information annotated
	procedure representation structure.
    Add a goal_path field to the call_site_perf type.

deep_profiler/program_representation_utils.m:
    Create procrep_annotate_with_coverage/5 predicate to annotate a procedure
    representation structure with coverage information.
    Use type classes to convert goal annotations to strings used with the
    procedure representation structures.

deep_profiler/create_report.m:
    Call procrep_annotate_with_coverage to build the coverage-annotated
    procedure representation report.

deep_profiler/display_report.m:
    Conform to changes in deep_profiler/report.m
    Implement a goal_annotation typeclass for coverage_info for displaying the
    coverage information.
	Display a link to the procrep_coverage report from the Procedure report.

deep_profiler/mdprof_cgi.m:
	Add the ability to generate a procrep_coverage report to the command line
	interface for debugging.

deep_profiler/mdprof_test.m:
	Add the ability to generate all the procrep coverage reports possible from
	a Deep.data file.
	Make compressing the result (using a separate gzip process) optional,
	since it can slow down the test for a negligible gain.
2008-09-17 03:26:29 +00:00
Paul Bone
cfe35c9cb7 Modify the deep profiling tools, in particular mdprof_cgi, to make use of
Estimated Hours Taken: 10
Branches: main

Modify the deep profiling tools, in particular mdprof_cgi, to make use of
program representation files, and begin implementing the procrep coverage
report.

The mdprof coverage report is incomplete, however it is convenient to post
this for review now.  Currently it can display a pretty-printed procrep
structure without coverage annotations.

mdbcomp/program_representation.m:
	Modified program representation data structures to allow goals to be
	annotated with another type.

deep_profiler/query.m:
	Create new deep profiling command, to display a coverage-annotated
	procedure representation.
	Support use of program representation information by new-style report
	generating code.
	Centralised command parsing to code within this module.
	Created constants for strings shared between cmd_to_string and
	string_to_maybe_cmd.

deep_profiler/report.m:
	Add new report, report_procrep_coverage_dump.
	Modified the proc_static dump report to include the number of coverage
	points in the proc_static.

deep_profiler/create_report.m:
	create_report now accepts an optional program representation structure,
	making it possible for report generation code to use the program
	representation structure.
	Support the new procrep coverage report, which is incomplete.
	Modify the proc static dump report, to display the number of coverage
	points within a proc_static structure.

deep_profiler/display.m:
	Introduce display_verbatim, a new display element that is able to display
	verbatim text, such as source code.

deep_profiler/display_report.m:
	Add support for displaying the new mdbcomp_coverage report.
	Modify the proc static dump display to show the number of coverage points,
	conforming to a change in report.m

deep_profiler/html_format.m:
	Support the display_verbatim element.
	Use query_to_string from query.m to create the query part of a URL.
	Conform to changes in deep_profiler/query.m

deep_profiler/startup.m:
	Modify read_and_startup to also read the program representation data if
	available.

deep_profiler/mdprof_cgi.m:
	Use string_to_maybe_query from query.m to parse a query string.
	Renamed some variables.
	Modified command-loop to pass program representation between commands.

deep_profiler/program_representation_utils.m:
	A new module to hold utilities from working with program representation
	data.
	Pretty printing code from mdprof_procrep has been moved here and modified
	to output a cord of strings rather than write to standard output.

deep_profiler/mdprof_feedback.m:
deep_profiler/mdprof_test.m:
	Conform to changes in query.m

deep_profiler/mdprof_procrep.m:
	Move proc_rep pretty-printing code to program_representation_utils.m

browser/declarative_tree.m:
	Conform to changes in mdbcomp/program_representation.m
2008-08-28 10:26:15 +00:00
Zoltan Somogyi
f637aa2458 Move three deep profiler commands to the new framework: the one that reports
Estimated hours taken: 16
Branches: main

Move three deep profiler commands to the new framework: the one that reports
all of a procedure's callers, the one that lists all the modules, and the one
that lists all the procedures in a module.

deep_profiler/report.m:
	Add report structures for the three newly handled commands.

	Modify the perf_row_data type to allow the representation of rows
	in which the self measures are meaningful, but the self_and_desc
	measures aren't, since this is true for module summaries.

	Remove a redundant field from an existing report structure.

deep_profiler/query.m:
	Change the cmd type slightly to (a) make command names more distinct,
	(b) make it less error prone by replacing ints with purpose-specific
	wrapper types, and (c) to specify whether contour exclusion should be
	applied in the proc_callers command. Change (c) is needed because
	we contour exclusion alters the report we want to generate for the
	proc_callers command, but we don't want to pass the preferences to the
	code that computes reports.

deep_profiler/create_report.m:
	Add code for computing the new report structures.

	Conform to the change to perf_row_data.

deep_profiler/display_report.m:
	Add code for displaying the new report structures.

	Conform to the change to perf_row_data.

deep_profiler/display.m:
	Avoid the need for a number-of-columns field in most table cells
	by having separate function symbols for single- and multi-column cells.

	Add a mechanism that allows us to avoid artifically nested lists
	(horizontal list inside a vertical list).

	Add the column classes needed by the newly implemented commands.

deep_profiler/html_format.m:
	Conform to the changes in display.m and query.m.

deep_profiler/profile.m:
	We used to read in the contour exclusion file just before computing
	and displaying a HTML page whose contents required it. We cannot do
	this with the report framework (since the predicate that computes
	report structures does not take I/O states as arguments), and it is
	better to read the contour exclusion file just once anyway. This diff
	therefore adds a field to the deep structure for holding the result
	of reading in the contour exclusion file (if any).

deep_profiler/startup.m:
	Add code to fill in this new field.

	Switch to using state variables.

deep_profiler/apply_exclusion.m:
	New module. It contains some code that used to be in query.m, but
	is now also needed by create_report.m, slightly modified. The
	modifications are to add some code that used to be in the callers
	of the moved predicates. This code used to be needed only once,
	but is now needed twice (since each predicate now has two callers).

	The reason why I didn't put all this into the existing exclude.m
	is that that would have required profile.m and exclude.m to import
	each other.

deep_profiler/exclude.m:
	Change the return value to separate the case of a non-existent contour
	exclusion file from a file that exists but whose reading yields an
	error.

	Give variables better names.

deep_profiler/mdprof_cgi.m:
deep_profiler/mdprof_test.m:
	Conform to the changes in query.m.

deep_profiler/apply_exclusion.m:
	New module. It contains some code that used to be in query.m, but
	is now also needed by create_report.m, slightly modified. The
	modifications are to add some code that used to be in the callers
	of the moved predicates. This code used to be needed only once,
	but is now needed twice (since each predicate now has two callers).

	The reason why I didn't put all this into the existing exclude.m
	is that that would have required profile.m and exclude.m to import
	each other.

deep_profiler/exclude.m:
	Give variables better names.

deep_profiler/measurements.m:
	Turn a semidet predicate into a function.
2008-08-25 07:19:39 +00:00
Zoltan Somogyi
599e1c2fdb Implement the proc command of the deep profiler using the report mechanism.
Estimated hours taken: 16
Branches: main

Implement the proc command of the deep profiler using the report mechanism.

Some of the detailed changes also address Paul's post-commit review of my
previous diff.

deep_profiler/report.m:
	Define the representation of the proc report.

	Change some names to be more consistent.

deep_profiler/profile.m:
	Add a type for use in report.m.

	Document the fields of an existing type.

deep_profiler/create_report.m:
	Add code to create proc reports.

	Change some names to be more consistent.

	Fix a bug: avoid divide by zero exceptions in some rare cases.

deep_profiler/measurement units.m:
	Fix a bug: avoid divide by zero exceptions in some rare cases.

deep_profiler/display_report.m:
	Add the code for converting proc reports to displays. This required
	rewriting almost everthing in this module to remove the assumption,
	which was previously embedded in many places, that the code is part
	of the implementation of the top_procs command. The new code is
	separated into two parts; the command-specific parts, and the parts
	that should be usable for all commands. (The reusable part is much
	bigger.)

deep_profiler/display.m:
	Expand the display representation to allow the specification of

	- plain text as distinguished from headings
	- paragraph breaks
	- pseudo-links, i.e. text fragments that are formatted like links
	- table separator rows
	- table cells that span more than one column

	which are used in the new version of display_report.m.

	Simplify the mechanism for setting up table header groups.

deep_profiler/html_format.m:
	Handle the changes in display.m.

	Fix some anomalies in the formatting of lists and tables.

	Group related code together.

deep_profiler/query.m:
	Provide a switch for selecting which of the two mechanisms,
	the old direct generation of HTML or the new indirect generation
	through the report and display structures, should generate the HTML
	page for a command that both mechanisms can implement. The default
	is the new mechanism, but it can be overridden by implementors
	by creating a file called "/tmp/old_deep_profiler".

	Switch the default handling of the proc command over to the new
	mechanism.

	Rename some types and function symbols to make them more consistent
	and expressive.

	Generate more informative error messages for domain error exceptions.

deep_profiler/mdprof_cgi.m:
	Add a mechanism for decoding the links in the generated pages.
	The mechanism takes the form of three new options: --decode,
	--decode-cmd, and --decode-prefs. When one or more of these are given,
	mdprof_cgi will not do its usual stuff, instead of just loops waiting
	for lines whose contents it will then try to decode as queries,
	as commands and/or as preferences.

deep_profiler/Mercury.options:
	Try to postpone thrashing in the deep compiler when compiled in
	debug grades, by compiling their contents with shallow tracing.

deep_profiler/array_util.m:
	Make shallow tracing effective by moving the deep recursions
	into non-exported predicates.

deep_profiler/callgraph.m:
deep_profiler/canonical.m:
deep_profiler/startup.m:
	Convert the debugging code to use trace goals.

deep_profiler/cliques.m:
deep_profiler/read_profile.m:
	Convert the debugging code to use trace goals.

	Use more expressive names for lots of variables.

	In read_profile.m, avoid an unnecessary repackaging of data.

deep_profiler/util.m:
	Fix some grammar errors in a comment, and comment some code to use
	state variables.

deep_profiler/interface.m:
	Fix some grammar errors in a comment.

deep_profiler/mdprof_feedback.m:
	Change some variable names to be consistent with the other modules.

library/float.m:
library/int.m:
	Make the messages in the domain errors we throw more expressive.

library/io.m:
	Minor style changes.
2008-08-18 02:14:59 +00:00
Paul Bone
1de09830dc Deep profiling and program representation file format changes.
Estimated hours taken: 7.5
Branches: main

Deep profiling and program representation file format changes.

Include a table of variable names in the program representation used by the
deep profiler (Deep.procrep).  The table shouldn't contain variables
introduced by the compiler.

Include the name of the program from which the deep profile was generated in
the header of the deep profiling data file (Deep.data).

compiler/prog_rep.m:
	Optionally create the variable table within the bytecode generated for
	each procedure, The actual variable names are stored in the string table
	for the module.

compiler/stack_layout.m:
	Enable the variable table only for deep profiling builds.

mdbcomp/program_representation.m:
	Include variable table in each program representation structure.

	Create predicates to read in the variable table if it is present.

	Create predicates to lookup a variable name from a table or generate a
	name automatically.

	Incremented version number for the program representation file format.

runtime/mercury_deep_profiling.c:
	Write out program name in header of deep profiling data.

	Increment version numbers of deep profiling and program representation
	file formats.

browser/declarative_tree.m:
deep_profiler/canonical.m:
tests/debugger/declarative/builtin_call_rep.exp:
tests/debugger/declarative/dependency.exp:
	Conform to changes in mdbcomp/program_representation.m

deep_profiler/mdprof_procrep.m:
	Lookup and display variable names when displaying program representation.

deep_profiler/profile.m:
	Make program name part of the profile_stats structure.

deep_profiler/read_profile.m:
deep_profiler/io_combinator.m:
	Read in program name from deep profiling data.

	Incremented version number for the deep profiling file format.

deep_profiler/report.m:
deep_profiler/create_report.m:
deep_profiler/display_report.m:
	Display program name with the statistics on the menu report.

deep_profiler/dump.m
	Conform to changes in deep_profiler/profile.m.
2008-08-12 02:51:08 +00:00
Zoltan Somogyi
8f0ef48784 Use reports to handle the call_site_static and call_site_dynamic queries.
Estimated hours taken: 3
Branches: main

Use reports to handle the call_site_static and call_site_dynamic queries.

deep_profiler/report.m:
	Add the two new report types.

	Give a better name to a type.

deep_profiler/create_report.m:
	Add the code for the two new report types.

	Make the predicate for creating a perf_row_data more general,
	and avoid defining the perf_row_data field-by-field.

deep_profiler/display.m:
	Rename a table_class that is now used not just by the top_procs
	command.

	Represent columns as cords, to avoid the need for keeping track
	of whether the list of columns is reversed.

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.

deep_profiler/html_format.m:
	Add newlines to the output, in order to make it more readable
	and to make using diff between two versions of the output feasible.

	Print the HTML title as a heading.

	Add a XXX about a disrespected control.

deep_profiler/query.m:
	Use the new method to handle the two query types.
2008-08-05 00:54:18 +00:00
Zoltan Somogyi
3fc2b3f6b6 Use reports to handle the proc_static and proc_dynamic queries.
Estimated hours taken: 4
Branches: main

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.
2008-08-04 08:50:04 +00:00
Zoltan Somogyi
03035ad2e6 Convert Paul's new code to use cords of strings to represent HTML.
Estimated hours taken: 6
Branches: main

Convert Paul's new code to use cords of strings to represent HTML.

deep_profiler/html_format.m:
	Convert to using cords. Restructure the code in a couple of places
	to always put start and end tags around HTML fragments together.

	Fix a missing "=" in a tag.

deep_profiler/interface.m:
deep_profiler/mdprof_cgi.m:
deep_profiler/read_profile.m:
	Provide better diagnostics.

deep_profiler/create_report.m:
deep_profiler/display.m:
deep_profiler/display_report.m:
deep_profiler/mdprof_feedback.m:
deep_profiler/measurement_units.m:
deep_profiler/query.m:
deep_profiler/report.m:
mdbcomp/feedback.m:
	Misc cleanups. They can be considered my post-commit review of Paul's
	diff.

	In mdprof_feedback.m, delete a strange test that prevented the program
	from being used from the command line.

deep_profiler/dump.m:
deep_profiler/mdprof_dump.m:
deep_profiler/timeout.m:
deep_profiler/util.m:
	Misc cleanups of old code.
2008-08-04 03:17:55 +00:00
Paul Bone
4a03798e3c Introduced intermediate data structures to mdprof_cgi.
Estimated Hours Taken: 60
Branches: main

Introduced intermediate data structures to mdprof_cgi.  This will make it
easier to extract deep profiling information for any new tools.  It also
enables other viewers for deep profiling data to more easily be developed.

New code making use of these data structures follows a pipeline pattern
as it is converted between the following data structures in this order:

	Deep -> Report -> Display -> HTML

This work is in progress and only a handful of deep profiler commands have
been converted to use the new data structures.  The old code has been kept for
reference and should be removed in the future.

deep_profiler/report.m:
	Created new module that defines a data structure for a deep profiler report.
	The new report data structure can be used to describe the content of a
	particular report.

deep_profiler/display.m:
	Created new module that defines a data structure for displaying deep
	profiler information.
	The new display data structure can be used to describe the structure and
	content shown when a user views a deep profiler report.

deep_profiler/measurement_units.m:
	Created new module defining data types to represent percentages, amounts
	of computer memory and time.

deep_profiler/query.m:
	Move memory_units type to data_types.m.
	Handling of the following deep profiler commands has been re-written to
	use the new data structures:
		deep_cmd_quit,
		deep_cmd_timeout,
		deep_cmd_restart,
		deep_cmd_menu,
		deep_cmd_top_procs

deep_profiler/create_report.m:
	Created new module for creating reports from the deep data structure.

deep_profiler/display_report.m:
	Created new module for converting a report structure to a display
	structure.

deep_profiler/html_format.m:
	Introduce new code to convert a display data structure into a string of
	HTML formatted text.
	Moved number formatting code to measurement_units.m.
2008-07-29 01:43:00 +00:00