[m-dev.] Ciao Prolog being slow [fwd]
Peter Schachte
schachte at cs.mu.OZ.AU
Wed May 22 10:41:54 AEST 2002
I just got this interesting exchange on the Ciao Prolog mailing list.
They discuss Mercury performance relative to Prolog. But note at the
end the correspondant's complaint about code size of Mercury programs,
and his decision to ditch Visual Prolog because of the type
declarations.
--
Peter Schachte A nation that continues year after year to spend
schachte at cs.mu.OZ.AU more money on military defense than on programs
www.cs.mu.oz.au/~schachte/ of social uplift is approaching spiritual doom.
Phone: +61 3 8344 9166 -- Martin Luther King, Jr.
----- Forwarded message from Manuel Carro <boris at aaron.ls.fi.upm.es> -----
From: Manuel Carro <boris at aaron.ls.fi.upm.es>
Subject: Ciao Prolog being slow
Reply-To: boris at aaron.ls.fi.upm.es
To: ciao-users at clip.dia.fi.upm.es
Dear Ciao users,
I am forwarding to the list a couple of messages which address
matters we believe are of general interest.
Antonio Costa Pereira <costa at ufu.br> worte:
>> I am not an expert programmer. Therefore, I may be doing something
>> very stupid. Please, be patient with me. I am a linguist, with special
>> interest in Ancient Greek and Egyptian Hieroglyphics. I usually write
>> my programs in Visual Prolog or Mercury, but I decided to take a look
>> in other versions of Prolog. Therefore, I downloaded Gnuprolog and
>> Ciao Prolog. I found out that Ciao Prolog runs so slowly in my
>> machine that it is almost useless. Depending on the problem, it is
>> from 40 times to 200 times slower than Mercury. A typical syntax
>> analysis of a text with five pages in Hieroglyphics takes 5 minutes in
>> Mercury, and almost four hours in Ciao Prolog in a 5 MHz Pentium! I
>> checked the compiler options carefully to see whether I was doing
>> something wrong ( like missing compiler options) to no
>> avail. Therefore, I would be glad if people from this list could help
>> me. A friend told me that there is an option that makes Ciao Prolog
>> generate C code that is even faster than Mercury. What is the trick
>> to generate this C code? I have Visual C installed in my machine,
>> that I use to compile Mercury. Is Ciao Prolog as simple to compile as
>> Mercury? Can I use Visual C to complete the compilation? Or should I
>> use gcc in Cygwin?
Hello. We wouldn't be surprised that Ciao Prolog goes slower than
Mercury. After all, they are different languages, with Mercury
requiring some more user effort, such as modes, types, determinism
declarations, etc., which makes translation to C (or assembler) easier
(though it is true that the latest Mercury releases do much of this
job automatically --- more knowledgeable readers may want to add more
information). However, the differences you mention exceed by far and
large what we would expect.
Probably some declarations in the Mercury program are helping a
lot the compiler, and the Prolog possible counterparts (i.e., all that
can be added to an otherwise correct Prolog program in order to help a
steadfast execution) are missing. From the top of my head, I can
guess that maybe determinism (or, better, the lack of it) might be the
culprit: some cuts properly placed, and using indexing on the first
argument, might help.
How big is the program? Can it be understood after some
reasonable time? If so, could you send it to me, along with some test
cases? We obviously can't promise speedup, but if there is any point
which can be straightforwardly improved, we may be able to spot it.
Just for curiosity, and to see if I am in the right track, how
does GNU Prolog behave? Are the figures you obtain as bad as Ciao
Prolog's?
Yes, it is true that we are working on compilation to C. However
the compiler is still on a very preliminary stage, and although
results are good, it is still far from being usable.
MCL
________________________________________________
Nula aestetica sine etica. Ergo apaga y v?monos.
==============================================================================
Message: Address: Action:
help majordomo at clip.dia.fi.upm.es Info. on useful commands
subscribe ciao-users-request at clip.dia.fi.upm.es Subscribe to this list
unsubscribe ciao-users-request at clip.dia.fi.upm.es Unsubscribe from this list
<whatever> ciao-users at clip.dia.fi.upm.es Send message to list
-----------------------------------------------------------------------------
Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/
-----------------------------------------------------------------------------
----- End forwarded message -----
----- Forwarded message from Antonio Costa Pereira <costa at ufu.br> -----
From: Antonio Costa Pereira <costa at ufu.br>
Subject: Re: Ciao Prolog is very slow in my machine
To: ciao-users at clip.dia.fi.upm.es
Dear Sir.
Thank you for your prompt answer.
> Just for curiosity, and to see if I am in the right track, how
> does GNU Prolog behave? Are the figures you obtain as bad as Ciao
> Prolog's?
You are right. GnuProlog is almost as slow as Ciao Prolog.
> After all, they are different languages, with Mercury
> requiring more user effort, such as modes, types, determinism
> declarations, etc., which makes translation to C (or assembler)
> easier.
Again, I am sure you are right. I think that mode and type inference
makes Mercury run faster. I never declare modes or types. I always
compile with the option "mmc --infer-all myprogram.m". In any case,
Mercury infer modes and types. As for determinism, my students and I
avoid non-deterministic predicates very carefully. Thus, I am sure
that all predicates are deterministic.
Question: Is it possible to insert mode declaration in a Ciao-Prolog
code? If the answer is yes, I could check how it influences speed.
I have made an experience with GNU-Prolog that may help. Dr. Marcus
Vinicius, from Ryerson University
(http://www.scs.ryerson.ca/~m3santos/) wrote a Prolog to C translator
as part of his MSC thesis. I got a copy of this thesis and of the
translator. A few years later, Dr. Cedric Carvalho wrote a Prolog to
JVM compiler with mode and type inference. One of my students combined
the two compilers to generate C code (instead of JVM) for GNU-Prolog.
Then, I used gplc to compile and link this code to a GNU-Prolog
program. With this off-hand scheme, I was able to compile only very
simple programs. However, they proved to be as fast as equivalent
programs in Mercury. Is it possible to add an option to Ciao Prolog
to generate mode and type inference? Of course, it is possible. I
think I should rephrase the question. Do you have plans to add mode
and type inference to Ciao-Prolog?
> Yes, it is true that we are working on compilation to C. However
> the compiler is still on a very preliminary stage, and although
> results are good, it is still far from being usable.
Would you accept volunteers? I am sending copies of this letter to
Dr. Cedric and Dr. Marcus. They know well the kind of programs I
write, and they may make suggestions. I am also sure that they would
be happy to work as volunteers in your Prolog to C compiler, if you
accept volunteers, of course.
By the way, I do not want to keep with Mercury because it generates
ridiculously large code (ten times larger than Ciao Prolog, or
GNU-Prolog). Finally, I am giving up Visual Prolog because it requires
type declaration.
Eduardo Costa
==============================================================================
Message: Address: Action:
help majordomo at clip.dia.fi.upm.es Info. on useful commands
subscribe ciao-users-request at clip.dia.fi.upm.es Subscribe to this list
unsubscribe ciao-users-request at clip.dia.fi.upm.es Unsubscribe from this list
<whatever> ciao-users at clip.dia.fi.upm.es Send message to list
-----------------------------------------------------------------------------
Archived messages: http://www.clip.dia.fi.upm.es/Mail/ciao-users/
-----------------------------------------------------------------------------
----- End forwarded message -----
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list