I just ran into this interesting benchmarking program:
I ran it on swipl (I think I did this a couple of times to get an 80MB profile.coz file, took about two hours, maybe more):
$ cd /tmp/swipl-devel/bench
$ for i in $(seq 330); do coz run -b /tmp/swipl-devel/build.release/% --- swipl run.pl; done
I placed a throughput benchmark in function PL_next_solution(...)
in pl-wam.c
(you need to #include “coz.h”):
int
PL_next_solution(qid_t qid)
{ GET_LD
register_file REGISTERS = {.qid = qid}; /* Active registers */
Code PC; /* program counter */
exception_frame THROW_ENV; /* PL_thow() environment */
COZ_PROGRESS; // <---- Here, this is a counter
#if O_VMI_FUNCTIONS
register_file *registers = ®ISTERS;
#else /* O_VMI_FUNCTIONS */
...
I got some interesting results after running for perhaps a couple of hours:
I chose “impact” as the sorting mode for the graphs, which come from uploading the profile.coz
file to this website: coz plot
- The first graph says that if line 197 in
pl-index.c
is sped up by 23% thenPL_next_solution(..)
will be reached 90% more times per second! - The second graph says that if line 2497 in
pl-vmi.c
is sped up by 55% thenPL_next_solution(..)
will be reached 55% more times per second! - The eighth graph, biggest bang for the buck, says that if line 1939 in
pl-vmi.c
is sped up by 10% thenPL_next_solution(..)
will be reached 56% more times per second!
And so on.
If you sort graphics by Min. speedup you get this:
- The fifth graph says that if you speed up line 509 of
pl-inline.h
by 50% you will slow down the throughput ofPL_next_solution(...)
by 26%.
Now that is quite a great benchmarking software. They were able to speedup SQLite by 25% with this tool. You can see more about its operating methods here (I think this is one of the authors):
I figured this may help @dmchurch in his optimization efforts.
I placed the COZ_PROGRESS counter in PL_next_solution(..)
because that is where we get the answer after calling a predicate.