[m-rev.] for post-commit review: semantic help pieces for grade options

Julien Fischer jfischer at opturion.com
Thu Jul 17 14:54:38 AEST 2025


On Thu, 17 Jul 2025 at 01:21, Zoltan Somogyi <zoltan.somogyi at runbox.com> wrote:
>
>
> On Mon, 14 Jul 2025 14:25:12 +1000, Julien Fischer <jfischer at opturion.com> wrote:
> > >      --memory-profiling                  (grade modifier: `.memprof')
> > >          Prepare the generated code for profiling of memory usage and
> > retention
> > > -        by mprof. This option is supported only when targeting C.
> > > +        by mprof. Please see the
> > > +        "Using mprof for profiling memory retention" section in the
> > Mercury
> > > +        User's Guide for details.
> >
> > I don't think memory rentention profiling is the main thing that memprof
> > grades
> > are used for, so I would either say:
> >
> >    Please see the "Using mprof for profiling memory allocation" and
> >    "User mprof for profiling memory retention" sections in the Mercury
> >    User's Guide for details.
> >
> > or, if you have to list one only section, point to the allocation one.
>
> I don't have any objection to this, but I would like to understand the
> situation before I make any changes. I don't usually use mprof (I use
> the deep profiler instead),
> and I don't usually even install the mprof-related
> grades, so I am asking you guys: what happens if you invoke mprof -m
> on a profile for a program that was compiled in a .prof (but not .memprof) grade?

In that specific case, you get a warning:

     Warning: error opening `Prof.Counts': can't open input file: No
such file or directory
    The generated profile will only include call counts.

And then you get such a profile.
(I suspect the situation where files from one type of profiling are
lying around in your
current working directory when run the other type of profiling may be
a bit more murky.)

> Do you get the same info as you would get from a program compiled in
> a .memprof grade? Less detailed but still useful info?
> Or nothing useful at all?

Since you do get the call counts, less detailed but useful info (depending
on how useful you find the call counts).

> And can mprof still do its usual call-counting and time-profiling tasks
> for a program compiled in a .memprof grade? Is there *anything* that mprof
> can do for a program compiled in .prof grade that it cannot do for .memprof grade?

The "Profiling introduction" in the User's guide says:

    ‘mprof’ can be used to profile either time or space, but not both
at the same time

mprof does call counts in both prof and memprof grades, but only time
in prof grades
and only memory usage in memprof grades.

Julien.


More information about the reviews mailing list