Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Language Efficiency
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Fergus Henderson  
View profile  
 More options May 2 1995, 3:00 am
Newsgroups: comp.lang.c++, comp.lang.ada, comp.lang.cobol
From: f...@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: 1995/05/02
Subject: Re: Language Efficiency

de...@cs.nyu.edu (Robert Dewar) writes:
>Fergus notes the comparison of peformance of Prolog and Mercury, and states
>that Mercury is up to 70% faster:
>(The feature in question is the ability to write `read(X), call(X)',
>which can call any predicate with any arguments depending on the input.)

You have misquoted me; perhaps I was not clear in my original post.

Mercury is "up to" more than 100 times faster than Prolog (if you
compare it against a slow Prolog implementation with a favourable
benchmark).  That just means that "up to" figures are generally not
very useful.  A fairer comparison against the best available Prolog
implementation (Aquarius Prolog with global analysis) on ten small
benchmarks shows improvements ranging from a few per cent to a factor of
three, averaging very roughly about 70%.

The reasons why Mercury is better were not stated in my original post,
because there are many of them, and the post was already long enough.
They are that Mercury has a strong type system, mode system, and
determinism system, which together guarantee the availability of
complete and accurate information which the compiler can use to
optimize the data representation, calling conventions, and code.
The Aquarius compiler attempts to infer the same sort of information,
but since full inference of all the information that is guaranteed
in Mercury would be prohibitively expensive in terms of compile
time, Aquarius is forced to approximate.
For full details, see the paper (available from my WWW home page).

The relevance of the feature `read(X), write(X)' was that
Aquarius Prolog with global analysis doesn't actually
implement full Prolog, since it doesn't allow `read(X), call(X)'.
To be fair in comparing Mercury with full Prolog, we should use
Aquarius without global analysis, which would mean that Mercury
would be faster by very roughly another 50% or 100%.

>But how can forbidding a feature POSSIBLY mean that you can compile faster.
>If it is possible to compile faster if read(x) and call(x) are avoided, then
>surely a prolog compiler can just look at your program, see if you use these
>features, and use one of two totally different compilation strategies
>depending on the answer.

What you would have to do would be to look at every argument to a
meta-predicate like `call' (Prolog has many of them other than `call' -
their use is common in Prolog programs), and see whether the
argument could possibly have come from a call to `read'.  This is
of course undecideable, so you have to approximate.
Furthermore, this has to be a genuinely global analysis.  Aquarius Prolog's
"global" analysis really only works on a module at a time - you must use
`cat' to join your entire program into a single really big module if you
want genuinely global analysis with Aquarius.  Unfortunately Aquarius Prolog
is prohibitively slow analysing large programs with genuinely global
analysis.  I suspect that the analysis required to determine if your
program ever invokes a meta-predicate with an argument whose form
is not known until runtime would be just a hard as the analysis Aquarius
Prolog is doing already, and I would not be surprised if current technology
was not sufficient to make this analysis accurate enough in a sufficiently
short analysis time to be useful.

So in short, if a language provides information that another
language does not provide, and if that information cannot be inferred
in a reasonable amount of compile-time, the former language will be
inherently more efficient than the latter.

>Of course I understand that this makes implementation harder, and it is
>indeed true that you have to work very hard to deal with difficult
>problems, but you often can deal with them much better than you might
>imagine.

Even if it were theoretically possible, often there is no point
optimizing for particular special cases, since they are so rare.
Programs that are written in Prolog will be hard to optimize, since
they will tend to use all aspects of Prolog, even those that make
optimization hard; programs that are written in Mercury are guaranteed
to be in the easy-to-optimize basket, since most of those aspects of
Prolog that make optimization are aren't present in Mercury.

>Another example from SNOBOL-4

>In SNOBOL-4, when you access any variable by name, as in the access to
>Q in  the assignment

>    R = Q

>you have to check if Q is input associated (and if so, read from a file), and
>if it is trace associated (and if so, call a user defined trace routine).
>Similarly the assignment to R may write to a file or call a userdefined
>trace procedure. The I/O associations and trace associations are completely
>dynamic, and it is impossible to tell at compile time whether any given
>reference needs the extra tests.

>Yes, without ANY loss of dynamic flexibility, the 370 SPITBOL compiler
>does these tests with precisely ZERO overhead in the most common case
>where the variables R and Q are never associated. ZERO doesn't just mean
>small, it means ZERO!

I find that unlikely.  Is there a space cost?  Is that no overhead at
all or just no _time_ overhead?  Did you consider cache effects?
Simply having the code around to handle the uncommon cases will
probably slow down the common-case code, even if the uncommon-case code
is never executed.  At the very least, it will occupy more disk space.

--
Fergus Henderson                       | I'll forgive even GNU emacs as
f...@cs.mu.oz.au                        | long as gcc is available ;-)
http://www.cs.mu.oz.au/~fjh            |             - Linus Torvalds


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.