Profilercc is not compatible with profiler mode of the core engine
amato-gianluca opened this issue · 5 comments
Hello,
I am trying to use the profilercc
package. If I understand correctly, in order to have access to all the features of the package, I need to recompile the Ciao engine with debug-level=profile
. Therefore, I proceeded to recompile the code with
/ciao-boot.sh configure --core:debug-level=profile
./ciao-boot.sh build
Unfortunately, compilation of the ciaodbg
bundle gives these errors:
compiling [4/12] lib/profilercc/profiler_c.pl /home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c: In function ‘disable_hooks’:
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c:133:24: error: ‘profile__hook_noop’ undeclared (first use in this function); did you mean ‘profile__hook_nop’?
133 | profile__hook_redo=profile__hook_noop;
| ^~~~~~~~~~~~~~~~~~
| profile__hook_nop
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c:133:24: note: each undeclared identifier is reported only once for each function it appears in
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c:135:24: error: ‘profile__hook_call_noop’ undeclared (first use in this function); did you mean ‘profile__hook_call_nop’?
135 | profile__hook_call=profile__hook_call_noop;
| ^~~~~~~~~~~~~~~~~~~~~~~
| profile__hook_call_nop
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c: In function ‘profile__hook_redo_’:
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c:171:18: error: ‘InitialNode’ undeclared (first use in this function); did you mean ‘InitialChoice’?
171 | if (w->choice!=InitialNode) {
| ^~~~~~~~~~~
| InitialChoice
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c: In function ‘profile__hook_cut_’:
/home/amato/.ciaoroot/v1.23.0-m1/ciaodbg/lib/profilercc/profiler.c:202:16: error: ‘cp_younger’ undeclared (first use in this function); did you mean ‘cp_older’?
202 | next_alt = cp_younger->next_alt;
| ^~~~~~~~~~
| cp_older
compiled lib/profilercc/ (12 modules)
I tried to apply all the changes suggested by the compiler, and with further minor changes I was able to compile ciaodbg
without errors. However, enabling profiling at that point was causing a lot of Segmentation Fault errors.
Hi Gianluca! Thank you for the report. The profilercc package is very sophisticated but hard to use and enable for large programs (like CiaoPP). Moreover, we found a couple of bugs that are producing the segmentation faults. We are working right now on simpler profiler alternatives (we'll try to commit something usable hopefully today).
Hi Jose, thanks for your reply.
I am able to use the profilercc package without compiling the Ciao Engine with the profiler support. I only get the number of calls for predicates and the number of ticks, but I think these information may be enough for what I am trying to do. Is the "number of ticks" reliable as an approximation of the total execution time of a predicate ?
Hi Gianluca,
Yes, number of ticks should be reliable approximation. Profilecc requires instrumentation at the Prolog-level and that may introduce too much noise. Another thing to consider is that currently CiaoPP domains can be much slower when loaded from a toplevel than then compiled statically (due to an issue with indexing in multifile predicates). We plan to solve this issue soon.
As promised we have recovered the naive profiler too. We are testing it locally before pushing to github (in a few minutes!).
Hi again,
Following up on my last message, we have just pushed a new Ciao version to GitHub which, apart from other changes, recovers (and improves a bit) the built-in profiler. This is a basic, relatively low overhead profiler, which can be used to determine call counts, times, etc. per predicate when executing a goal or an executable.
The changes are still in the master
branch (no new release yet). The manual (you need to generate it locally and see the "Profiling" chapter in Part I, or on the source of https://github.com/ciao-lang/ciao/blob/master/core/library/profile.pl) gives detailed instructions about how to use it with examples.
Time measuring in this profiler is a rough estimate (it just measures the time in a predicate until we call another one), but the overhead is smaller and do not require any source code changes (nor selecting cost centers, etc.). For large programs like CiaoPP,
the profiling overhead for counting number of calls is normally quite low (negligible in some examples that I tried).
Please let us know if you find any problems!
P.D. We have also moved the cost center-based one (more powerful but more complex, with more overhead, and which currently needs some work) to its own bundle https://github.com/ciao-lang/profilercc.
(Marked as fixed, please feel free to reopen)