Checked against Jekejeke Prologue trailed notes. It was collected only at n = 100'000. For B-Prolog, the following command line worked fine on Windows:
bp -s 40000000
This is said to be 160 MB stack / heap space. I get both warm and not set tables than cold ones:
B-Prolog n = 100'000 in s:
without tab: 14.276, 12.229
with tabulation: 0.419, 0.143, 0.127, 0.152
The storage code for Jekejeke uses the acceptz / 2 predicate from the hypo module. Unlike B-Prolog tables, tracked entries will recount everything with every call. You need to manually add it to your code:
Projection Yekeke / Minlog n = 100'000 in s:
without memorization: 4,521, 3,893
with memorization: 0.724, 0.573, 0.585, 0.555
Thus, there is still room for improvement in speed at Jekejeke. Regarding your question, B-Prolog: When the memory is too tight, this may occasionally put extra pressure on the GC, which can lead to your observed behavior.
bye
PS: this is the code to remember in Jekejeke Prolog. You need to install Jekejeke Minlog to have a hypo- accessible module. It is best to install the latest version:
:- thread_local posInt_CollatzStepsm/2. mposInt_CollatzSteps(I,N) :- ( I == 1 -> N = 0 % base case ; posInt_CollatzStepsm(I,N) %%% memo check -> true ; 1 is I /\ 1 -> I0 is I*3+1, mposInt_CollatzSteps(I0,N0), N is N0+1, % odd assumez(posInt_CollatzStepsm(I,N)) %%% memo add ; I0 is I>>1, mposInt_CollatzSteps(I0,N0), N is N0+1, % even assumez(posInt_CollatzStepsm(I,N)) %%% memo add ). ?- time(mi0_i_maxSteps0_maxSteps(1, 100000, 0, R)). % Up 724 ms, GC 71 ms, Thread Cpu 640 ms (Current 06/20/19 09:43:24) R = 350 ?- time(mi0_i_maxSteps0_maxSteps(1, 100000, 0, R)). % Up 573 ms, GC 69 ms, Thread Cpu 500 ms (Current 06/20/19 09:43:27) R = 350