[m-rev.] for review: update stream line numbers when reporting statistics
Julien Fischer
jfischer at opturion.com
Sun Apr 4 16:23:09 AEST 2021
On Sun, 4 Apr 2021, Zoltan Somogyi wrote:
> On Sun, 4 Apr 2021 00:54:10 +1100 (AEDT), Julien Fischer <jfischer at opturion.com> wrote:
>> :- pragma foreign_proc("C#",
>> - report_stats,
>> + do_report_stats(Stream::in),
>> [may_call_mercury, terminates],
>> "
>> - ML_report_standard_stats(io.mercury_stderr);
>> + ML_report_standard_stats(Stream.F1);
>> ").
>
> I don't know what the .F1 here accomplishes; it certainly deserves
> a comment.
Done. F1 is the field in the generated Java class that corresponds to
the first agument of output_stream functor. (In the C grades it's a
notag type and we can get at the underlying file stream using a cast; in
the C# and Java grades we do not apply the notag optimisation so we need
to use a field access to retrieve the file stream.)
As a separate change, I'm planning to add some C# and Java methods for
manipulating file streams from C# and Java respectively, but that's a
separate change.
>> :- pragma foreign_proc("Java",
>> - report_stats,
>> + do_report_stats(Stream::in),
>> [may_call_mercury, terminates],
>> "
>> - ML_report_standard_stats(io.mercury_stderr);
>> + ML_report_standard_stats((io.MR_TextOutputFile) Stream.F1);
>> ").
>
> Likewise, and the cast deserves a comment too.
Done.
>> @@ -67,7 +67,7 @@
>> #endif // MR_MPROF_PROFILE_MEMORY
>>
>> void
>> -MR_report_standard_stats(FILE *fp)
>> +MR_report_standard_stats(FILE *fp, int *line_number)
>> {
>> int user_time_at_prev_stat;
>> int real_time_at_prev_stat;
>> @@ -153,11 +153,13 @@ MR_report_standard_stats(FILE *fp)
>> GC_get_bytes_since_gc() / 1024.0,
>> GC_get_heap_size() / 1024.0
>> );
>> + (*line_number)++;
>
> I didn't check for a one-to-one correspondence between lines printed
> and increments of *line_number, but I expect you did.
I did.
> I presume that the reason why the Java and C# code for printing stats
> has no similar increments is that the output methods they invoke do
> the increment at each newline already.
Correct.
> If that is right, then the diff is otherwise fine. And thanks.
Thanks for the review.
Julien.
More information about the reviews
mailing list