[net.lang.prolog] A Cautionary tale.

O'KeefeHPS@sri-unix.UUCP (07/12/84)

From:  O'Keefe HPS (on ERCC DEC-10)

I just spent some time trying to make the tokeniser I recently
submitted to the Prolog library go faster.  I put in a table of
character codes in a way I know to be implementation dependent,
I unfolded calls in line, and generally got up to some tricks
I felt slightly ashamed of.  What was the result?
The new version ran 50% - 100% SLOWER.

On the subject of making things go faster, someone recently
sent in a list of versions of reverse that might go faster.
That issue seems to have been lost from our archive, but I
recall that the correspondent involved didn't give any
figures for how fast the different versions were.  I would
not be at all surprised if some or all of them were slower.

The really amusing thing here is that if I had tried to get
the most efficient program I could think of first, instead of
trying to get something to work and then optimising it, I would
have ended up with a slower program, and would have been quite
sure that t was as fast as I could make it.

dep@allegra.UUCP (Dewayne E. Perry) (07/13/84)

offering :- all_the _previous_lines, leave_this_line_if_appeased.

The rules for the operation reverse were reported to be faster because
they were measured to be faster using C Prolog (measured by doing
each version 200 times on a list with 36 elements).

You may recall that I warned about optimizations that appeal to your
intuition as improving the average case, etc, but that do not have
that effect in a prolog implementation.  This phenomena comes from
the complex underlying structure that does the data base management
and the inferences.  There seem to be two levels of understanding 
needed to exploit this structure:  the logical structure of prolog -
ie, the simplifications made to first order predicate calculus and the
underlying theory in order tomake prolog a practical working system -
and the implementation of this logical structure - ie, the particular
quirks of a particular version of prolog.  Unfortunately, these latter
considerations vary from version to version.  Besides, you shouldn't
depend on those kinds of "features" anyway.

?- author(X)

X = Dewayne E. Perry