On Sun, Mar 09, 2025 at 10:18:37AM +0000, Gavin Smith wrote:
> On Sun, Mar 09, 2025 at 01:20:26AM +0100, Patrice Dumas wrote:
> > On Sat, Mar 08, 2025 at 06:23:54PM -0500, Gavin D. Smith wrote:
> > > This is an automated email from the git hooks/post-receive script.
> > > 
> > >     Disable clean-up at end of program
> > >     
> > >     * tta/perl/texi2any.pl:
> > >     Comment out call to Texinfo::Document::remove_document.
> > 
> > If there is more than one input file, this allows to bring down the
> > memory used.  Also it is a bit strange that it takes a long time, as it
> > should only free C structures.  I guess that it is indeed slower than
> > just releasing the memory at exit, but it is cleaner, I think that it
> > should also be left for tests.
> 
> You can check that it takes significant time.  See timings at end of
> this email.
> 
> For tests, I assume it could be checked if TEST is set?

Yes.

>  Can the tests
> be used for checking if all memory is freed by the end?

Not directly, the way I observe it is by looking at valgrind
reachable/total memory.  But freeing explicitly the tree in tests makes
sure that a double free is caught, and also that if part of the tree is
free'd and not another it appears as a memory leak in valgrind.


Also, maybe more 'philosophically', not freeing this memory is a bit
like accepting that memory leaks are not an issue if the speed gain is
important when the memory is only released at exit.  Indeed, the
unrealeased memory is a memory leak from the whole Perl+C program point
of view, as the Perl object that could be used to retrieve the C to be
freed is lost (it is not fully lost, all the documents may still be
released, but the handler to this specific document is lost).  (As a
side note, the document holds Perl references, such that if it is not
free'd, Perl will not be able to collect this memory.  Since we are at
the end of the program, not allowing Pelr to release memory it probably
also speeds up the program).


If I read well, this is significant, but not a big relative difference.

> BEFORE:
> $ for n in 1 2 3 ; do time ../tta/perl/texi2any.pl ../../libc/libc.texi ; done
> creature.texi:309: warning: `.' or `,' must follow @xref, not f
> 
> real    0m5.345s
> user    0m5.030s
> sys     0m0.312s
> creature.texi:309: warning: `.' or `,' must follow @xref, not f
> 
> real    0m5.347s
> user    0m5.039s
> sys     0m0.304s
> creature.texi:309: warning: `.' or `,' must follow @xref, not f
> 
> real    0m5.364s
> user    0m5.019s
> sys     0m0.344s
> 
> 
> AFTER:
> 0$ for n in 1 2 3 ; do time ../tta/perl/texi2any.pl ../../libc/libc.texi ; 
> done
> creature.texi:309: warning: `.' or `,' must follow @xref, not f
> 
> real    0m5.113s
> user    0m4.790s
> sys     0m0.320s
> creature.texi:309: warning: `.' or `,' must follow @xref, not f
> 
> real    0m5.165s
> user    0m4.902s
> sys     0m0.260s
> creature.texi:309: warning: `.' or `,' must follow @xref, not f
> 
> real    0m5.214s
> user    0m4.902s
> sys     0m0.308s
> 
> 

Reply via email to