Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.prolog > #14746
| From | Mild Shock <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.prolog |
| Subject | It was painful for my GC, but fixed now (Re: The pairs are nasty, otherwise not always slow!) |
| Date | 2025-07-30 14:51 +0200 |
| Message-ID | <106d4fs$33hjf$3@solani.org> (permalink) |
| References | <105vr4s$2r116$1@solani.org> <106d459$33hel$3@solani.org> |
Hi,
The sharing example was painful for my GC.
I got a long GC pause:
/* Dogelog Player 1.3.5 for JavaScript */
?- time((share(X), acyclic3(X), fail; true)).
% Zeit 122 ms, GC 0 ms, Lips 4906262, Uhr 30.07.2025 04:54
true.
?- time((share(X), acyclic3(X), fail; true)).
% Zeit 445 ms, GC 313 ms, Lips 1345087, Uhr 30.07.2025 04:54
true.
But fixed now:
/* Dogelog Player 1.3.5 for JavaScript */
?- time((share(X), acyclic3(X), fail; true)).
% Zeit 125 ms, GC 7 ms, Lips 4788512, Uhr 30.07.2025 09:11
true.
Here is share/1, the idea is to have some
deep term, and share it widely:
share(L) :-
fac(s(s(s(s(s(s(s(n))))))), X),
length(L, 5000),
maplist(=(X), L).
With usual peano arithmetic. n/0 stands for
null, and s/1 for successor:
add(n, X, X).
add(s(X), Y, Z) :- add(X, s(Y), Z).
mul(n, _, n).
mul(s(X), Y, Z) :- mul(X, Y, H), add(Y, H, Z).
fac(n, s(n)).
fac(s(X), Y) :- fac(X, H), mul(s(X), H, Y).
Mild Shock schrieb:
> Hi,
>
> Looks like the pairs are really nasty.
> I have them on the Novacore GIT.
>
> This one is no problem for Scryer-Prolog:
>
> test :-
> share(X), share(Y), X == Y.
>
> /* SWI-Prolog 9.3.26 */
> ?- time(test).
> % 32,140 inferences, 0.000 CPU in 0.002 seconds (0% CPU, Infinite Lips)
> true.
>
> /* Scryer Prolog 0.9.4-417 */
> ?- time(test).
> % CPU time: 0.006s, 32_042 inferences
> true.
>
> /* Trealla Prolog 2.79.6 */
> ?- time(test).
> % Time elapsed 0.016s, 42012 Inferences, 2.582 MLips
> true.
>
> /* Dogelog Player 1.3.5 */
> ?- time(test2).
> % % Zeit 83 ms, GC 0 ms, Lips 12117469, Uhr 30.07.2025 05:47
> % true.
>
> The Dogelog Player solutions uses a variant
> of library(hash), called library(maps).
> Both hash tables are itself 100% Prolog.
>
> Bye
>
> Mild Shock schrieb:
>> Hi,
>>
>> Having fun with Bisimulation, and a new test
>> suite of nasty circular pairs. But how store
>> circular pairs, if clauses do not support
>>
>> circular terms. Well chop it up into equations,
>> I create 1000 such equation pairs:
>>
>> test([A = c(A, B), C = c(A, D), E = n, _ = c(F, B),
>> F = c(C, C), G = c(G, D), D = c(E, C), B = n],
>> [H = c(H, I), J = c(K, I), L = c(L, I), I = c(M, N),
>> O = c(K, J), N = n, K = c(K, J), M = c(K, O)]).
>> Etc..
>>
>> The pairs are nasty because the usual compare_with_stack/2
>> chokes on them. Here some results:
>>
>> /* SWI-Prolog 9.3.26 */
>> ?- time((between(1,30,_), part, fail; true)).
>> % 540,118 inferences, 0.047 CPU in 0.041 seconds (115% CPU, 11522517
>> Lips)
>> true.
>>
>> /* Trealla Prolog 2.78.40 */
>> ?- time((between(1,30,_), part, fail; true)).
>> % Time elapsed 0.113s, 1143903 Inferences, 10.157 MLips
>> true.
>>
>> /* Scryer Prolog 0.9.4-417 */
>> ?- time((between(1,30,_), part, fail; true)).
>> % CPU time: 0.226s, 1_117_809 inferences
>> true.
>>
>> /* Dogelog Player 1.3.5 */
>> ?- time((between(1,30,_), part2, fail; true)).
>> % Zeit 309 ms, GC 0 ms, Lips 8693718, Uhr 25.07.2025 13:47
>> true.
>>
>> The amazing thing is, I compared a 100% Prolog
>> implementation, so there is a lot of head room
>> for improvement:
>>
>> part2 :-
>> bitest(X,Y), X ~~ Y, fail; true.
>>
>> The operator (~~)/2 is part of library(math),
>> and has been implemented with same_term/2 so far.
>>
>> Bye
>>
>
Back to comp.lang.prolog | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Novacore goes Bisimulation: Scryer Prolog is Slow! Mild Shock <janburse@fastmail.fm> - 2025-07-25 13:51 +0200
Is Mild Shock going rogue? (Was: Novacore goes Bisimulation: Scryer Prolog is Slow!) Mild Shock <janburse@fastmail.fm> - 2025-07-25 14:07 +0200
Is Mostowski Collapse a professional mathematician (Was: Is Mild Shock going rogue?) Mild Shock <janburse@fastmail.fm> - 2025-07-25 14:16 +0200
New Project Name: NovaCore becomes VibeCore (Re: Is Mostowski Collapse a professional mathematician) Mild Shock <janburse@fastmail.fm> - 2025-07-25 14:42 +0200
Nice Printing Error Scryer Prolog (Was: Novacore goes Bisimulation: Scryer Prolog is Slow!) Mild Shock <janburse@fastmail.fm> - 2025-07-26 21:33 +0200
Dynamic unify_with_occurs_check/2 speed-up (Was: Nice Printing Error Scryer Prolog) Mild Shock <janburse@fastmail.fm> - 2025-07-26 21:37 +0200
The End of Deutsch-Schorr-Waite [cycle_detection.rs] (Was: Novacore goes Bisimulation: Scryer Prolog is Slow!) Mild Shock <janburse@fastmail.fm> - 2025-07-28 10:50 +0200
Backtracking Branching Association List (Re: The End of Deutsch-Schorr-Waite [cycle_detection.rs]) Mild Shock <janburse@fastmail.fm> - 2025-07-28 11:02 +0200
Do it like in acyclic_decompose/3 (Re: Backtracking Branching Association List) Mild Shock <janburse@fastmail.fm> - 2025-07-28 11:38 +0200
Cache-Trashing vs Cache-Friendly [Code Example] (Re: Do it like in acyclic_decompose/3) Mild Shock <janburse@fastmail.fm> - 2025-07-28 17:27 +0200
Entering the Age of Rational Trees (2025) (Was: The End of Deutsch-Schorr-Waite [cycle_detection.rs]) Mild Shock <janburse@fastmail.fm> - 2025-08-16 13:02 +0200
The End of Debray Allocator (Was: The End of Deutsch-Schorr-Waite [cycle_detection.rs]) Mild Shock <janburse@fastmail.fm> - 2025-08-24 14:44 +0200
The pairs are nasty, otherwise not always slow! (Re: Novacore goes Bisimulation: Scryer Prolog is Slow!) Mild Shock <janburse@fastmail.fm> - 2025-07-30 14:45 +0200
It was painful for my GC, but fixed now (Re: The pairs are nasty, otherwise not always slow!) Mild Shock <janburse@fastmail.fm> - 2025-07-30 14:51 +0200
Scryer Prolog has the most useless max_depth (Re: Novacore goes Bisimulation: Scryer Prolog is Slow!) Mild Shock <janburse@fastmail.fm> - 2025-08-02 13:43 +0200
Novacore goes native (=)/2 and (==)/2 bisimulation (Was: Scryer Prolog has the most useless max_depth) Mild Shock <janburse@fastmail.fm> - 2025-08-02 14:45 +0200
csiph-web