[m-dev.] for review: clean up MLDS init functions

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 9 23:44:38 AEDT 2000


On 09-Nov-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> > > Or is that taking a sledgehammer to a walnut?
> > 
> > Probably.  Anyway last time I looked, the pretty-printing library
> > has exponential performance for large outputs.  So we'd need to fix
> > that problem first.
> 
> No, I fixed that ages ago to use bounded lookahead.  The first
> version was indeed exponential, but now it laughs in the face of large
> terms.

Well, there's still some performance problems.  The performance may
not be exponential, but stack usage seems to be at least linear, and
the constant factor is too high.  In particular, here's a test case:
apply the following patch, and then run 

	cd ../samples
	MERCURY_COMPILER=../compiler/mercury_compile \
		mmc -H --dump-mlds all -cv interpreter.m

This crashes with a stack overflow, unless you increase the stack size
from the default of 4M.  In fact it uses more than 25M of stack space,
even though the data structure that it is dumping is much smaller than
that -- the total heap usage without --dump-mlds is only 12M, and only
part of that is the MLDS.

Index: mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.181
diff -u -d -u -r1.181 mercury_compile.m
--- mercury_compile.m	2000/10/14 04:00:12	1.181
+++ mercury_compile.m	2000/11/09 11:56:25
@@ -73,6 +73,7 @@
 	% library modules
 :- import_module int, list, map, set, std_util, dir, require, string, bool.
 :- import_module library, getopt, set_bbbtree, term, varset.
+:- import_module pprint.
 :- import_module gc.
 
 %-----------------------------------------------------------------------------%
@@ -3066,8 +3067,8 @@
 	( { Res = ok } ->
 		% XXX the following doesn't work, due to performance bugs
 		% in pprint:
-		%	pprint__write(80, pprint__to_doc(MLDS)),
-		io__print(MLDS), io__nl,
+		pprint__write(80, pprint__to_doc(MLDS)),
+		% io__print(MLDS), io__nl,
 		io__told,
 		maybe_write_string(Verbose, " done.\n"),
 		maybe_report_stats(Stats)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list