Re: Differences among the "bomb" and "xbetween" (Was: New milestone float formatting [LoL])

Liste des GroupesRevenir à cl prolog 
Sujet : Re: Differences among the "bomb" and "xbetween" (Was: New milestone float formatting [LoL])
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.prolog
Date : 24. Sep 2024, 16:20:33
Autres entêtes
Message-ID : <vculbv$n5et$1@solani.org>
References : 1 2 3 4 5
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.19
Here some results on a Lenovo Yoga with
Windows 11 for xbetween:
/* SWI-Prolog 9.3.11 */
?- time((xbetween1(1,1000000000,_),fail)).
% 2,000,000,002 inferences, 72.688 CPU in 72.790 seconds (100% CPU, 27515047 Lips)
false.
/* Dogelog Player 1.2.3, WSL2, JDK 21 */
?- time((xbetween1(1,1000000000,_),fail)).
% Time 160451 ms, GC 4 ms, Lips 24929729, Wall 24/09/2024 17:01
fail.
Dang, still ca. 2x times slower. But no
memory problem at all. Prolog specific GC is
very low, only 4 ms, because the Prolog system
doesn't allocate some logical variables for
this example. The extended neck here is semi-det
builtins, that are already evaluated only using
native stack and no Prolog stack, when the
clause is instantiated:
xbetween1(L, U, N) :- L < U, M is L+1, xbetween1(M, U, N).
                       \---- neck ----/
So overhead in Dogelog compared to SWI-Prolog
is among the fact that it abandons and creates a choice
point in every backtracking. Haven't found a way
yet to elegantly avoid this unecessary effort.
Mild Shock schrieb:
 > Here are two test cases for memory
 > management of a Prolog system:
 >
 > /* bomb */
 >
 > app([], X, X).
 > app([X|Y], Z, [X|T]) :- app(Y, Z, T).
 > garbage(0, [0]) :- !.
 > garbage(N, L) :- M is N-1, garbage(M, R), app(R, R, L).
 > foo :- garbage(12,_), foo.
 >
 > /* xbetween */
 > xbetween1(L, _, L).
 > xbetween1(L, U, N) :- L < U, M is L+1, xbetween1(M, U, N).
 >
 > They test possibly something different. xbetween does
 > not produce a lot of objects during tail recursion,
 > it only decrements one integer. The xbetween example
 >
 > might be ok, wherea the bomb example might be neverthelesss
 > not ok, especially since unlike in the xbetween example,
 > the bomb example has also an "intermediate" variables.
 >
 > The "intermediate" variable is "_":
 >
 > foo :- garbage(12,_), foo.
 >
 > The xbetween example has no such variable. All
 > variables in the xbetween example are either in
 > the head or in the tail recursive call, making
 >
 > it a more trivial example than the bomb example.
 >
 >

Date Sujet#  Auteur
28 Jul 24 * New milestone float formatting [LoL] (Was: Request for comments, Novacore the sequel to ISO modules)9Mild Shock
28 Jul 24 +* Re: New milestone float formatting [LoL] (Was: Request for comments, Novacore the sequel to ISO modules)4Mild Shock
28 Jul 24 i`* Re: New milestone float formatting [LoL] (Was: Request for comments, Novacore the sequel to ISO modules)3Mild Shock
24 Sep 24 i `* Re: Differences among the "bomb" and "xbetween" (Was: New milestone float formatting [LoL])2Mild Shock
26 Sep 24 i  `- New milestone time formatting (Was: Differences among the "bomb" and "xbetween")1Mild Shock
9 Oct 24 `* More Prolog Improvement Proposals (PIPs) [PIP401 - PIP404]4Mild Shock
9 Oct 24  `* Even More Prolog Improvement Proposals (PIPs) [PIP301 - PIP303] (Was: More Prolog Improvement Proposals (PIPs) [PIP401 - PIP404])3Mild Shock
9 Oct 24   `* Re: Even More Prolog Improvement Proposals (PIPs) [PIP301 - PIP303] (Was: More Prolog Improvement Proposals (PIPs) [PIP401 - PIP404])2Mild Shock
9 Oct 24    `- Re: Even More Prolog Improvement Proposals (PIPs) [PIP301 - PIP303] (Was: More Prolog Improvement Proposals (PIPs) [PIP401 - PIP404])1Mild Shock

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal