[m-dev.] for review: memory profiling [1/2]

Fergus Henderson fjh at cs.mu.oz.au
Fri Dec 5 14:49:32 AEDT 1997


On 05-Dec-1997, Zoltan Somogyi <zs at cs.mu.oz.au> wrote:
> 
> I also find the naming scheme confusing. Something like .prof{mem,calls,time},
> .prof{memcalls,memtime,callstime} and .profall would be better, with some
> combinations not supported of course.

The trouble with that is

- it breaks backwards compatibility -- the existing `.prof' grade
  needs to get renamed as `.profcallstime', so any Mmake files,
  scripts, etc. with `GRADE = asm_fast.gc.prof' in them will break.
  (The impact would not be great, so this is only a minor concern.)

- the names for the two documented cases are `.profmemcalls' and
  `.profcallstime', which are (a) confusing if you don't know about
  the other cases and (b) probably a bit too long -- grade names are
  designed to be short.
  (This is my major concern.)

If the choice is between confusing implementors or confusing users,
I think it is better to confuse the implementors ;-)
So on balance I'm still inclined to stick with the names
`.prof' rather than `.profcallstime' and `.memprof' rather than
`.profmemcalls'.

> > --- options.m	1997/11/13 06:27:17	1.211
> > +++ options.m	1997/11/29 13:56:36
> > @@ -110,8 +110,11 @@
> >  		;	asm_labels
> >  		;	gc
> >  		;	profiling
> > +		;	time_profiling
> > +		;	memory_profiling
> >  		;	profile_calls
> >  		;	profile_time
> > +		;	profile_memory
> >  		;	use_trail
> >  		;	pic_reg
> 
> Why both memory_profiling and profile_memory?

memory_profiling implies both profile_memory and profile_calls.
I'll add a comment.

> If the non-special one is only
> for internal, why is there an entry for it in long_option?

It's an undocumented feature.

Maybe someone will find a use for some of the undocumented
grades `.profcalls', `.proftime', `.profmem', or `.profall'.
I think they're probably more likely to cause confusion than
they are to be useful, so they're not documented, but I've
left the options in in case someone thinks of a use that
I didn't think of.

> >  @sp 1
> > - at item @code{--profiling} (grades: any grade containing @samp{.prof})
> > -Enable profiling.  Insert profiling hooks in the
> > + at item @code{--profiling}, @code{--time-profiling} (grades: any grade contai
>        ning @samp{.prof})
> > +Enable time profiling.  Insert profiling hooks in the
> >  generated code, and also output some profiling
> >  information (the static call graph) to the file
> >  @samp{@var{module}.prof}.  @xref{Profiling}.
> 
> Too long line.

I'm afraid I don't know any way of fixing that without breaking the
generated text.  As far as I know, Texinfo doesn't provide a line
continuation character.  The line doesn't actually wrap in the
generated text.

> >  @sp 1
> > + at item @code{--memory-profiling} (grades: any grade containing @samp{.mempro
>        f})
> > +Enable memory profiling.  Insert memory profiling hooks in the
> > +generated code, and also output some profiling
> > +information (the static call graph) to the file
> > + at samp{@var{module}.prof}.  @xref{Memory profiling}.
> 
> Too long line.

Ditto.

> Are you sure about the filename and the grade name?

Yep.

> > +:- pragma c_code("
> > +
> > +#include <stdio.h>
> > +#include ""mercury_prof_mem.h""
> > +#include ""mercury_heap_profile.h""
> > +
> > +#ifdef MEMORY_PROFILING
> > +
> > +  #define MEMORY_PROFILE_SIZE	10	/* Display this many top entri
>        es */
> > +
> > +  #define MAX_REPORT_LINES	10	/* ?? */
> 
> > +/*
> > +** Insert an entry into the table of the top `table_size' entries.
> > +** Entries are ranked according to their cells_at_period_end.
> > +** (XXX Why? Why not according to words_at_period_end?).
> > +** Entries that are not in the top `table_size' are discarded.
> > +*/
> > +static int
> > +ML_insert_into_table(const ML_memprof_report_entry *new_entry,
> > +	ML_memprof_report_entry *table, int table_size, int next_slot)
> 
> If you want to order the table by words, go ahead, but it is an arbirary
> choice. Or we could let the user make that choice by adding an extra arg
> to the report_stats predicates.

OK, I'll order it by words, and update the comment.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list