How to use profile/1,2?

How to use profile/1,2 ? Once a year ago,
on same environment (macOS) with git version,
it worked without problem, but now it does not work like this
with latest macOS, Homebrew and git SWI-Prolog.
Am I missing something ?


% ?- profile(append([],[], X), []).
%@ Warning: /Users/cantor/lib/swipl/xpce/prolog/boot/pce_autoload.pl:45:
%@ Warning:    Local definition of pce_autoload:get/3 overrides weak import from pce_principal
%@ X = [].

The warning message seems to require xpce installed, but I do every SWI-Programming
in GNU-emacs in ediprolog-mode. If xpce must be installed, I must install it.

I recall having had this problem at one point, but can’t find the note to myself on how I fixed it (I seem to recall retracting a PCE-reated predicate). I can reproduce a problem with WSL under Microsoft Windows, but can’t reproduce it under Linux. Have you tried unset DISPLAY or swipl --no-pce?

Here’s what I see with WSL (Ubuntu 18.0.4 Linux 4.4.0-18362-Microsoft #476-Microsoft Fri Nov 01 16:53:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux):

$ (unset DISPLAY; swipl)
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.22)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- profile(append([a,b,c], [x], Z)).
ERROR: error in system call (Invalid argument)
ERROR: In:
ERROR:   [14] '$profile'(user:append(...,...,...),cputime)
ERROR:   [13] setup_call_catcher_cleanup(system:true,prolog_statistics:'$profile'(...,cputime),_4360,prolog_statistics:show_profile([])) at /usr/lib/swi-prolog/boot/init.pl:564
ERROR:   [11] prolog_statistics:profile(user:append(...,...,...),[]) at /usr/lib/swi-prolog/library/statistics.pl:370
ERROR:    [9] <user>
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
   Call: (15) prolog_statistics:show_profile([]) ? abort
% Execution Aborted

$ (unset DISPLAY; swipl)
Welcome to SWI-Prolog (threaded, 64 bits, version 8.1.22)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- debug.
true.

[debug]  ?- profile(append([a,b,c], [x], Z)).
ERROR: error in system call (Invalid argument)
ERROR: In:
ERROR:   [14] '$profile'(user:append(...,...,...),cputime)
ERROR:   [13] setup_call_catcher_cleanup(system:true,prolog_statistics:'$profile'(...,cputime),_4494,prolog_statistics:show_profile([])) at /usr/lib/swi-prolog/boot/init.pl:564
ERROR:   [12] call_cleanup(prolog_statistics:'$profile'(...,cputime),prolog_statistics:show_profile([])) at /usr/lib/swi-prolog/boot/init.pl:572
ERROR:   [11] prolog_statistics:profile(user:append(...,...,...),[]) at /usr/lib/swi-prolog/library/statistics.pl:370
ERROR:   [10] prolog_statistics:profile(user:append(...,...,...)) at /usr/lib/swi-prolog/library/statistics.pl:364
ERROR:    [9] <user>
   Call: (15) prolog_statistics:show_profile([]) ? abort
% Execution Aborted

Suggests there is something wrong with the WSL emulation for managing the timers. At least, that is about the only system call that is involved. Call Microsoft :slight_smile:

The reported error suggests you are a bit behind and this reminds me as an issue introducing the new style autoloading that has been fixed.

Thanks Jan and Peter,

I will update git version soon later. I want to know around

reset/shift overhead and term_hash for the ZDD library I am

developing, which is necessary for efficiency as a public library.

Now, I have a short plan of introducing a ZDD garbage collection, which

is very simple minded one but seems useful for applications which use heavy amount of memory like

path counting problems.

Kuniaki Mukai

Jan.

Profile/1 works on terminal, but does not on emacs/ediprolog mode.

I changed bash to zsh according to the latest macOS (Catalina) default shell.

I will check later if this guess is the case.

% swipl

?- [’~/devel/zdd/prolog/zdd/pac’].

?- use_module(zdd(zdd)).

?- module(zdd).

zdd: ?- profile(zdd(minato3(rect(3,3), C))).