Commit Graph

17 Commits

Author SHA1 Message Date
Fergus Henderson
e6ac077bae Add support for memory profiling.
Estimated hours taken: 40 (+ unknown time by Zoltan)

Add support for memory profiling.

(A significant part of this change is actuallly Zoltan's work.  Zoltan
did the changes to the compiler and a first go at the changes to the
runtime and library.  I rewrote much of Zoltan's changes to the runtime
and library, added support for the new options/grades, added code to
interface with mprof, did the changes to the profiler, and wrote the
documentation.)

[TODO: add test cases.]

NEWS:
	Mention support for memory profiling.

runtime/mercury_heap_profile.h:
runtime/mercury_heap_profile.c:
	New files.  These contain code to record heap profiling information.

runtime/mercury_heap.h:
	Add new macros incr_hp_msg(), tag_incr_hp_msg(),
	incr_hp_atomic_msg(), and tag_incr_hp_atomic_msg().
	These are like the non-`msg' versions, except that if
	PROFILE_MEMORY is defined, they also call MR_record_allocation()
	from mercury_heap_profile.h to record heap profiling information.
	Also, fix up the indentation in lots of places.

runtime/mercury_prof.h:
runtime/mercury_prof.c:
	Added code to dump out memory profiling information to files
	`Prof.MemoryWords' and `Prof.MemoryCells' (for use by mprof).
	Change the format of the `Prof.Counts' file so that the
	first line says what it is counting, the units, and a scale
	factor.  Prof.MemoryWords and Prof.MemoryCells can thus have
	exactly the same format as Prof.Counts.
	Also cleaned up the interface to mercury_prof.c a bit, and did
	various other minor cleanups -- indentation changes, changes to
	use MR_ prefixes, additional comments, etc.

runtime/mercury_prof_mem.h:
runtime/mercury_prof_mem.c:
	Rename prof_malloc() as MR_prof_malloc().
	Rename prof_make() as MR_PROF_NEW() and add MR_PROF_NEW_ARRAY().

runtime/mercury_wrapper.h:
	Minor modifications to reflect the new interface to mercury_prof.c.

runtime/mercury_wrapper.c:
runtime/mercury_label.c:
	Rename the old `-p' (primary cache size) option as `-C'.
	Add a new `-p' option to disable profiling.

runtime/Mmakefile:
	Add mercury_heap_profile.[ch].
	Put the list of files in alphabetical order.
	Delete some obsolete stuff for supporting `.mod' files.
	Mention that libmer_dll.h and libmer_globals.h are
	produced by Makefile.DLLs.

runtime/mercury_imp.h:
	Mention that libmer_dll.h is produced by Makefile.DLLs.

runtime/mercury_dummy.c:
	Change a comment to refer to libmer_dll.h rather than
	libmer_globals.h.

compiler/llds.m:
	Add a new field to `create' and `incr_hp' instructions
	holding the name of the type, for heap profiling.

compiler/unify_gen.m:
	Initialize the new field of `create' instructions with
	the appropriate type name.

compiler/llds_out.m:
	Output incr_hp_msg() / tag_incr_hp_msg() instead of
	incr_hp() / tag_incr_hp().

compiler/*.m:
	Minor changes to most files in the compiler back-end to
	accomodate the new field in `incr_hp' and `create' instructions.

library/io.m:
	Add `io__report_full_memory_stats'.

library/benchmarking.m:
	Add `report_full_memory_stats'.  This uses the information saved
	by runtime/mercury_heap_profile.{c,h} to print out a report
	of memory usage by procedures and by types.
	Also modify `report_stats' to print out some of that information.

compiler/mercury_compile.m:
	If `--statistics' is enabled, call io__report_full_memory_stats
	at the end of main/2.  This will print out full memory statistics,
	if the compiler was compiled with memory profiling enabled.

compiler/options.m:
compiler/handle_options.m:
runtime/mercury_grade.h:
scripts/ml.in:
scripts/mgnuc.in:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Add new option `--memory-profiling' and new grade `.memprof'.
	Add `--time-profiling' as a new synonym for `--profiling'.
	Also add `--profile-memory' for more fine-grained control:
	`--memory-profiling' implies both `--profile-memory' and
	`--profile-calls'.

scripts/mprof_merge_runs:
	Update to handle the new format of Prof.Counts and to
	also merge Prof.MemoryWords and Prof.MemoryCells.

profiler/options.m:
profiler/mercury_profile.m:
	Add new options `--profile memory-words' (`-m'),
	`--profile memory-cells' (`-M') and `--profile time' (`-t').
	Thes options make the profiler select a different count file,
	Prof.MemoryWords or Prof.MemoryCells instead of Prof.Counts.
	specific to time profiling.

profiler/read.m:
profiler/process_file.m:
profiler/prof_info.m:
profiler/generate_output.m:
	Update to handle the new format of the counts file.
	When reading the counts file, look at the first line of
	the file to determine what is being profiled.

profiler/globals.m:
	Add a new global variable `what_to_profile' that records
	what is being profiled.

profiler/output.m:
	Change the headings to reflect what is being profiled.

doc/user_guide.texi:
	Document memory profiling.
	Document new options.

doc/user_guide.texi:
compiler/options.m:
	Comment out the documentation for `.proftime'/`--profile-time',
	since doing time and call profiling seperately doesn't work,
	because the code addresses change when you recompile with a
	different grade.  Ditto for `.profmem'/`--profile-memory'.
	Also comment out the documentation for
	`.profcalls'/`--profile-calls', since it is redundant --
	`.memprof' produces the same information and more.

configure.in:
	Build a `.memprof' grade.  (Hmm, should we do this only
	if `--enable-all-grades' is specified?)
	Don't ever build a `.profcalls' grade.
1997-12-05 15:58:34 +00:00
Fergus Henderson
41835fd1b8 Fix some problems with the .profcalls' grade (--profile-calls' option).
Estimated hours taken: 2

Fix some problems with the `.profcalls' grade (`--profile-calls' option).

profiler/process_file.m:
	If the `Prof.Counts' file does not exist, print a warning message
	and then continue, rather than calling error/1.  This is needed
	so that the `.profcalls' grade (or `--profile-calls' option) will
	work.

profiler/generate_output.m:
	Use "number of calls" as a secondary key, after "percent time",
	when creating the flat profile.  This gives more useful results
	for cases where timing information is not available (e.g. in
	the `.profcalls' grade).

profiler/generate_output.m:
profiler/output.m:
	Use `*', `+' etc. functions rather than builtin_float_times, etc.
1997-11-17 12:58:25 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Fergus Henderson
9ee35e25e8 Fix some places where `__' as module qualifier broke the profiler.
Estimated hours taken: 0.25

Fix some places where `__' as module qualifier broke the profiler.

generate_output.m:
process_file.m:
prof_info.m:
propagate.m:
	s/prof__/prof_/g
	s/prof_node__/prof_node_/g
	s/pred_info__/pred_info_/g
	s/cycle_info__/cycle_info_/g
	since the part before `__' was not a module qualifier.

read.m:
	s/replace/read__replace/ (where appropriate)
	to avoid ambiguity with `list__replace'.
1997-02-25 17:18:33 +00:00
Andrew Bromage
5f6e24c1f0 Bug fix to the profiler which causes it to abort with
Estimated hours taken: 1

Bug fix to the profiler which causes it to abort with
`relation__lookup_element' errors.

profiler/process_file.m:
      Changed some occurrences of relation__lookup_element to
      relation__add_element, so that new elements are added to
      the new dynamic call graph.
1996-10-24 03:02:06 +00:00
Andrew Bromage
804852adab Design change to relation.m to fix a MAJOR shortcoming.
Estimated hours taken: 5

Design change to relation.m to fix a MAJOR shortcoming.  Relations
now require the domain to be entered explicitly
fixes a known bug where performing a topological sort in certain
situations resulted in not all elements appearing in the sort.

compiler/call_graph.m:
compiler/process_file.m:
compiler/propagate.m:
	Minor changes to use the new relation.m.
1996-10-21 02:01:41 +00:00
Peter Ross
09c6fecdbf Various small changes to prepare the profiler for the upcoming release.
Estimated hours taken: 0.5

Various small changes to prepare the profiler for the upcoming release.

profiler/generate_output.m:
	Try out the new functional syntax for floating point numbers.

profiler/output.m:
	The calls field in the flat profile now is the summation of the
	self-recursive calls and the other calls to the predicate.

profiler/process_file.m:
	Change the way the program exits at some points.
1996-07-16 09:07:14 +00:00
Peter Ross
7ada33a875 When we encounter an address that the profiler knows nothing about in
Estimated hours taken: 0.25 + (3 hrs waster debugginh ;-) )

profiler/process_file.m:
	When we encounter an address that the profiler knows nothing about in
	the Prof.Counts file, ignore it and print out a warning rather then
	exiting.
1996-05-07 08:07:55 +00:00
Peter Ross
2912f73674 Rewrite of the profiler so that it handles cycles in the call graph more
Estimated hours taken: 20

Rewrite of the profiler so that it handles cycles in the call graph more
gracefully.

profiler/propagate.m:
	Now we build a map of all the cycles as we do a dfs search on the call
	graph.  Then we use this data to fill out the prof_info structure in
	a meaningful manner.

profiler/prof_info.m:
	Divide the prof_info structure into two.  We now have seperate
	structures for cycles and single predicates.

profiler/*.m:
	Minor changes to make sure that we print out the data in the correct
	manner.
1996-04-20 09:46:24 +00:00
Peter Ross
ff2ea496c9 Print out the actual file names of the std files being read in.
Estimated hours taken: 0.25

profiler/process_file.m:
	Print out the actual file names of the std files being read in.
1996-03-21 09:19:24 +00:00
Peter Ross
547ed00702 Little bug fix for "0 xxx" case in the Prof.Counts file.
Estimated hours taken: 0,05


profiler/process_file.m:
	Little bug fix for "0 xxx" case in the Prof.Counts file.  Rather then
	ignore "0 1" we now ignore "0 X".
1996-03-20 07:03:29 +00:00
Fergus Henderson
f1ad13b7c4 Undo dylan's changes in the names of some library entities,
Estimated hours taken: 1.5

Undo dylan's changes in the names of some library entities,
by applying the following sed script

	s/term_atom/term__atom/g
	s/term_string/term__string/g
	s/term_integer/term__integer/g
	s/term_float/term__float/g
	s/term_context/term__context/g
	s/term_functor/term__functor/g
	s/term_variable/term__variable/g
	s/_term__/_term_/g
	s/std_util__bool_/bool__/g

to all the `.m' and `.pp' files in the compiler and library directories.
The reason for undoing these changes was to minimize incompatibilities
with 0.4 (and besides, the changes were not a really good idea in the first
place).

I also moved `bool' from std_util.m to a separate module.
The main reason for that change is to ensure that the `__' prefix is
only used when it genuinely represents a module qualifier.
(That's what dylan's changes were trying to acheive, but `term__'
does genuinely represent a module qualifier.)

profiler/*.m:
	Where appropriate, add `bool' to the list of imported modules.
1996-02-03 18:06:19 +00:00
Fergus Henderson
cb26aa8b52 Work-around problem with the "0 1" line in Prof.Counts.
mercury_profile.m:
	Work-around problem with the "0 1" line in Prof.Counts.
	Use library__version/1 to get the version number.

call_graph.m:
	Fix bug where `io__seen' was called when it should not have been.
	Improve error message if `io__see' fails.

process_file.m:
	Handle errors gracefully: write a message to stderr, don't
	call error/1.

Mmake:
	Pass EXTRA_MLFLAGS to ml.
	This is because ml now strips the executable by default,
	so you need to pass --no-strip if you want to debug it.
1995-09-11 06:17:43 +00:00
Peter Ross
4102076514 Added some more explanatory information to the output.
output.m:
	Added some more explanatory information to the output.

process_file.m:
	cosmetic changes
1995-08-31 05:35:37 +00:00
Fergus Henderson
378a37bae8 Fix the mis-use of apostrophes everywhere.
profiler/*.m:
	Fix the mis-use of apostrophes everywhere.
	Tidy up the output of `mprof --help' a little.
1995-08-24 10:22:48 +00:00
Peter Ross
2c2d199f83 Very basic description of how to enable profiling and view the
README:
	Very basic description of how to enable profiling and view the
	results.  Please send comment's on the bits you don't understand
	and the I should explain better and expand on.

*.m:
	Now also generate's the flat profile.  Which tells you how much time
	you spend in each predicate as a percentage of total time.

	Also print's out an alphabetic list of all the predicate's and there
	ID numbers.
1995-08-15 03:16:35 +00:00
Peter Ross
34e35b1a11 added new options to.
options.m:
	added new options to.

*.m:
	code reorginization, a lot of the code was moved into new modules.
	PS passes boot check now.
1995-07-20 14:44:40 +00:00