[m-rev.] for post-commit review: parse conjunctions using tail recursive code

Julien Fischer jfischer at opturion.com
Sun May 8 16:30:46 AEST 2022


On Sat, 7 May 2022, Zoltan Somogyi wrote:

> Parse conjunctions using tail recursive code ...
> 
> to allow even very long conjunctions to be parsed in constant stack space.
> 
> compiler/prog_item.m:
>     We used to represent a conjunction in the parse tree as
>
>         conj_expr(ContextA, GoalA,
>             conj_expr(ContextB, GoalB,
>                 conj_expr(ContextC, GoalC,
>                     GoalD)))
>
>     To enable the changes in parse_goal.m and parse_dcg_goal.m, switch over
>     to representing them as
>
>         conj_expr(ContextA, GoalA, [GoalB, GoalC, GoalD])
>
>     and likewise for par_conj_exprs.
>
>     The fact that this throws away ContextB and ContextC is not a problem;
>     they were never used, being thrown away when converting the parse tree
>     to the HLDS.

The change looks fine; benchmarks are attached.
(baseline is commit fabd05b, modified is commit 0f0f1e6)

Julien.
-------------- next part --------------
benchmark 1:
EXTRA_MCFLAGS = -O2
GRADE = asm_fast.gc
base mercury_compile.01 average of 16 with ignore=1     22.60
mod  mercury_compile.01 average of 16 with ignore=1     22.97 speedup -1.64%

benchmark 2:
EXTRA_MCFLAGS = -O2 --intermod-opt
GRADE = asm_fast.gc
base mercury_compile.02 average of 16 with ignore=1     21.95
mod  mercury_compile.02 average of 16 with ignore=1     22.14 speedup -0.87%

benchmark 3:
EXTRA_MCFLAGS = -O5
GRADE = asm_fast.gc
base mercury_compile.03 average of 16 with ignore=1     20.88
mod  mercury_compile.03 average of 16 with ignore=1     20.86 speedup  0.10%

benchmark 4:
EXTRA_MCFLAGS = -O5 --intermod-opt
GRADE = asm_fast.gc
base mercury_compile.04 average of 16 with ignore=1     19.61
mod  mercury_compile.04 average of 16 with ignore=1     19.25 speedup  1.84%

benchmark 5:
EXTRA_MCFLAGS = -O2
GRADE = hlc.gc
base mercury_compile.05 average of 16 with ignore=1     24.38
mod  mercury_compile.05 average of 16 with ignore=1     24.06 speedup  1.31%

benchmark 6:
EXTRA_MCFLAGS = -O2 --intermod-opt
GRADE = hlc.gc
base mercury_compile.06 average of 16 with ignore=1     22.32
mod  mercury_compile.06 average of 16 with ignore=1     22.38 speedup -0.27%

benchmark 7:
EXTRA_MCFLAGS = -O5
GRADE = hlc.gc
base mercury_compile.07 average of 16 with ignore=1     22.49
mod  mercury_compile.07 average of 16 with ignore=1     22.48 speedup  0.04%

benchmark 8:
EXTRA_MCFLAGS = -O5 --intermod-opt
GRADE = hlc.gc
base mercury_compile.08 average of 16 with ignore=1     19.85
mod  mercury_compile.08 average of 16 with ignore=1     19.70 speedup  0.76%

total baseline time 174.08
total modified time 173.84 speedup  0.14%
baseline wins   3
modified wins   5


More information about the reviews mailing list