Enhanced version of text profiler data

I am unable to run the new GUI version on my old MacOS config. Since I converted to the commandline version some time ago, this is no big deal but I did lose one thing that I valued, namely the ability to display and browse the profiler data in an X-window. The current text-only version is considerably inferior to the xpce version, so I spent some time enhancing it.

For the many who have probably never seen it, an example of the current text-only version looks like:

=====================================================================
Total time: 0.896 seconds
=====================================================================
Predicate                       Box Entries =    Calls+Redos     Time
=====================================================================
clpBNR:getValue/2                   286,017 =  286,017+0        16.4%
clpBNR:pt_powrCase/6                 47,748 =   47,748+0        16.2%
clpBNR:doNode_/7                     95,382 =   95,382+0        15.1%
clpBNR:linkNodeList_/3              142,862 =  142,862+0         9.7%
clpBNR:linkNode_/3                   95,382 =   95,382+0         7.9%
true.

Currently, the experimental enhanced version of the same data:

======================================================================================================
Number of nodes: 422                      [ports(true)]                     Total time: 0.884 seconds
Predicate                         Calls + Redos    Exits + Fails            Time:Self + Time:Children
======================================================================================================
clpBNR:getValue/2               286,017 + 0      286,017 + 0           0.15s.( 16.4%) + 0.00s.(  0.0%)
clpBNR:pt_powrCase/6             47,748 + 0       47,748 + 0           0.14s.( 16.2%) + 0.00s.(  0.0%)
clpBNR:doNode_/7                 95,382 + 0       95,339 + 43          0.13s.( 15.1%) + 0.72s.( 81.2%)
clpBNR:linkNodeList_/3          142,862 + 0      142,862 + 0           0.09s.(  9.7%) + 0.07s.(  7.9%)
clpBNR:linkNode_/3               95,382 + 0       95,382 + 0           0.07s.(  7.9%) + 0.00s.(  0.0%)
======================================================================================================
true.

Note that the time values in this version are slightly smaller because they’re based on net time with the profiler overhead removed. And it still lacks the call graph and interactive browsing capability of the GUI version.

The enhanced version is implemented as:

:- module(terminal_show_profile, []).
:- use_module(library(prolog_profile), [profile_data/1, profile_procedure_data/2]).

using the prolog:show_profile_hook/1, so it just has be be loaded into a non-xpce version of SWIP to use it (not sure how multiple hook instances would work).

Possible future options:

  • publish the existing module as an add-on pack for those few who might have similar requirements to me. Requires installation and explicit load to use it.
  • generate a PR for library(prolog_profile) to provide an equivalent as the default text representation. (i.e., just becomes part of the release so no action required by the user).
  • do nothing; insufficient general interest so it just stays in my local toolbox.

Any opinions? Feedback on enhanced format?

I’m happy to accept that.

Otherwise, I’d make the IDE tools run … If you can get Macports and Xcode installed that should be quite feasible.

I’ll get started “merging” the code into the existing prolog_profile; shouldn’t take much effort.

For future consideration. I don’t have a lot of confidence I can make it work since I’m not really sure why it’s currently broken.

It probably builds fine on your system. Even in the case that Xcode clang is old and does not support C11, Macports probably allows you to install a recent version of gcc, providing both better performance and support for C11. If you get Macports installed, it probably all still works. Just needs a lot of patience to build …

Just to prove I have some small amount of patience:

Had to upgrade MacPorts to MacOS 10.14 compatible version (was 10.13 compatible). Now:

$ port help
sqlite error: attempt to write a readonly database (8) while executing query: CREATE INDEX registry.snapshot_file_id ON snapshot_files(id)
    while executing
"registry::open $db_path"
    (procedure "mportinit" line 856)
    invoked from within
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/port: Failed to initialize MacPorts, sqlite error: attempt to write a readonly database (8) while executing query: CREATE INDEX registry.snapshot_file_id ON snapshot_files(id)

And for the record:

$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

whatever that implies.

And now my patience has run out again.