Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.000 CPU in display by time/1 built-in #1334

Closed
Jean-Luc-Picard-2021 opened this issue Nov 25, 2024 · 4 comments
Closed

0.000 CPU in display by time/1 built-in #1334

Jean-Luc-Picard-2021 opened this issue Nov 25, 2024 · 4 comments

Comments

@Jean-Luc-Picard-2021
Copy link

Jean-Luc-Picard-2021 commented Nov 25, 2024

I could produce just now with SWI-Prolog 9.3.14,
tested on Windows 11 Pro, 22631.4460:

?-  time(test).
% 7,001,002 inferences, 1.234 CPU in 1.243 seconds (99% CPU, 5671698 Lips)
true.

?- time(test).
% 7,001,001 inferences, 0.000 CPU in 1.257 seconds (0% CPU, Infinite Lips)
true.

?- time(test).
% 7,001,001 inferences, 1.203 CPU in 1.246 seconds (97% CPU, 5819014 Lips)
true.

?- time(test).
% 7,001,001 inferences, 0.000 CPU in 1.249 seconds (0% CPU, Infinite Lips)
true.

The test case was:

:- dynamic(foo/2).

test :-
   retractall(foo(_,_)),
   warehouse(1000000, 1, 18884).

warehouse(0, _, _) :- !.
warehouse(N, X, Y) :-
   assertz(foo(Y, bar)),
   (retract(foo(X, bar)) -> true; true),
   zx81(X, Z), zx81(Y, T),
   M is N-1,
   warehouse(M, Z, T).

zx81(X, Y) :- Y is (X*75+74) mod 65537.
@Jean-Luc-Picard-2021 Jean-Luc-Picard-2021 changed the title CPU time 0.0000 in time/1 predicate 0.000 CPU in display by time/1 built-in Nov 25, 2024
@JanWielemaker
Copy link
Member

Works fine for me. What OS? Possibly in a VM? Looks more like an OS issue than a SWI-Prolog issue. SWI-Prolog just queries the relevant OS call.

@Jean-Luc-Picard-2021
Copy link
Author

Jean-Luc-Picard-2021 commented Nov 25, 2024

Attention: CPU is Ryzen and not Intel.

CPU: AMD Ryzen 5 4500U with Radeon Graphics @ 2.38 GHz
RAM: 16.0 GB (15.2 GB verwendbar)
Edition: Windows 11 Pro
Build: 22631.4460

image

@Jean-Luc-Picard-2021
Copy link
Author

Maybe this can be ignored. Could be an artefact
that some GC thread is doing a lot of work, so that
the main thread time measurement falls below

the time granulatrity of the time measurement used.
Could be a bug of the Ryzen CPU. Similar problems are
found elsewhere that thread CPU is not available:

Title: JVMPI GetCurrentThreadCpuTime() always returns zero time when using NSJ 1.3
https://support.hpe.com/hpesc/public/docDisplay?docId=ns102.0.28374788.4363595en_us&docLocale=en_US

@JanWielemaker
Copy link
Member

There is no portable way to get thread CPU time. What is implemented works most of the time on quite a wide range of systems using various OS specific techniques . This should most probably be considered an OS issue if it does not work as advertised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants