[m-rev.] for review: Make modecheck_conj_list_flatten_and_schedule tail recursive.
Peter Wang
novalazy at gmail.com
Fri Oct 16 15:45:44 AEDT 2015
On Thu, 15 Oct 2015 16:52:58 +1100 (AEDT), "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
>
>
> On Thu, 15 Oct 2015 14:28:25 +1100, Peter Wang <novalazy at gmail.com> wrote:
> > + reverse_prepend(ScheduledSolverGoals, !RevGoals),
>
> I think the idea behind the change is fine. However, I have found that
> playing games like this, reversing a list that is already in the correct order
> in order to preemptively undo a reverse that will be applied to the result later
> just makes maintenance unnecessarily hard, because the mental gymnastics
> required to figure out what is reversed and what is not makes it harder to
> think about the actual work being done.
Yes, sometimes.
> I would much rather we used
> cords here, and in similar places, and accept that there may be a very small
> performance penalty. Although it is also possible that there will be a speedup.
> For example, we wouldn't have to reverse the list here, so at this point
> in the code, cords would have an O(1) cost, not O(n).
I have changed it to used cords.
Just by the by, these days I'm not as keen on cords just for snoc.
A type rlist(T) ---> rlist(list(T)) is enough to free up the
programmer's mind while retaining the advantages and disadvantages of
the list representation underneath the covers. Of course, cords have
their uses.
> By the way, may I ask what motivates this spate of changes to handle
> large programs? I am interested in the subject, since I did a whole bunch
> of such changes earlier. Maybe I can help.
The program is not any larger, but the environment is different. For
some reason the compiler runs out of stack space more quickly on FreeBSD
than Linux. I won't speculate as to why (I did check ulimit -s).
The modules that the compiler crashed on aren't particularly big.
One module contains ~11k simple flat clauses. It prompted the fixes to
the module_qual, typecheck and purity modules, and also the lexer when I
tried commenting most of it out.
The other problematic module prompted the fix to the mode checker.
It is only ~2500 lines, containing a few functions that return constant
lists containing higher-order terms.
Peter
More information about the reviews
mailing list