[m-dev.] pprint performance

Ralph Becket rafe at cs.mu.OZ.AU
Mon Feb 25 13:25:48 AEDT 2002

Peter Schachte, Monday, 25 February 2002:
> Maybe instead of using an integer depth you could use
> 	:- type depth_limit ---> none ; limit(int).
> [... good suggestion]

I think I've identified the real problem.

The steps involved in writing a term T are
1. convert the term to a doc with D = to_doc(T),
2. convert the doc to a list of strings for output,
3. write out the list of strings.

For a term with a million nodes where each node is represented using
around ten strings (newlines, indents, brackets, commas, names, ...),
with each string costing two words per cons cell, we will consume of the
order of 80 MBytes just for the list of strings!

Most of the time we are just printing these strings, so we might as well
do it as we go rather than first collecting them in a list (the other
functionality provided is to concatenate them into a single string, but
that's a much lower priority problem.)

I'll try combining steps 2 and 3 so as not to construct an output list
and report back.

- Ralph
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