[m-rev.] for post-commit review: fix a perf bug

Julien Fischer jfischer at opturion.com
Thu Oct 29 15:37:09 AEDT 2015


Hi Zoltan,

On Thu, 29 Oct 2015, Zoltan Somogyi wrote:

> The story of how I found the need for this fix is in the log message.
>
> This diff  just works around the performance problem for code
> that does not use solver types. It does so by avoiding calls to
> the actual problem predicate, candidate_init_vars.
>
> That predicate was introduced into what was then modes.m in 2004,
> in commit 3bbfd4c7c98ee54de9ab7a0aa2ea6ba31d0e3d9d. It was
> added by rafe, so I cannot ask him, but maybe someone else has
> worked on it since. Does anyone know why it is written the way it is?
> If someone does, maybe we could actually solve the problem,
> not just work around it.

...

> Fix a performance problem in mode analysis.
> 
> When working on the diff to make_hlds_passes.m, the compiler took effectively
> forever on an intermediate version; I killed it after about half an hour
> of CPU time. Invoking a debug version of the compiler on that version
> of make_hlds_passes.m and interrupting it several times while it was
> twiddling its thumbs showed that it was spending its time in computing
> a set of candidate vars for auto-initialization. Since the predicate
> it was analyzing at the time, do_parse_tree_to_hlds, is quite big and has
> lots of variables, the sets of candidate variables could be quite big,
> and may have to be computed lots of times. However, all those computations
> are wasted, since once the set of candidate vars is computed, mode analysis
> checks if the variables in those sets have a solver type that has auto
> initialization.

Auto initialization of solver types as a language feature was disabled many
years ago, although the capability for supporting it was retained in the
compiler.  In light of the above, do we even want to maintain the residual
support for it?  I vote for removing it; I can't see it every being wanted
again.

(The diff is fine BTW.)

Julien.






More information about the reviews mailing list