(This appears to be a difficult to reproduce problem: when I checked things a second time, the problem did not show. Also, this directive didn’t do anything: :-set_prolog_flag(optimise, true).
but the -O
flag did set the flag.
Anyway, in case a reproducible example can be made …
When I wrote the “deadfish challenge” code (Autum Challenge: Short Deadfish Numbers - #4 by oskardrums) I found that when I used library(yall), it ran ~10x slower, despite having the “optimise” flag on (for this particular problem, the “optimise” flag resulted in a ~10% performance improvement).
When I looked at the generated code (using vm_list/1), I noticed that the auxiliary predicates were as expected, except that they also had something like this before the byte codes:
0 s_trustme(clause(95761178407712))
for the auxiliary for [S0,S]>>(S is S0+1)
. This didn’t appear for the equivalent incr(X0,X):-X is X0+1
, nor did it appears when “optimise” wasn’t set.
The sample code is here: deadfish code using dict/DCG and library(yall) · GitHub
It has an if
directive to switch between using library(yall) and regular Prolog code.