Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.psc.edu!hudson.lm.com!news.math.psu.edu!news.cac.psu.edu!howland.reston.ans.net!news.sprintlink.net!uunet!in1.uu.net!allegra!alice!pereira
From: pereira@alta.research.att.com (Fernando Pereira)
Subject: Re: Problems: Quintus to C Interface
In-Reply-To: Frank Bergmann's message of 11 Jul 1995 14:12:20 GMT
X-Nntp-Posting-Host: alta.research.att.com
Message-ID: <PEREIRA.95Jul11223110@alta.research.att.com>
Sender: usenet@research.att.com (netnews <9149-80593> 0112740)
Reply-To: pereira@research.att.com
Organization: AT&T Bell Laboratories
References: <3tu0s4$3i2@news.cs.tu-berlin.de>
Date: Wed, 12 Jul 1995 02:31:10 GMT
Lines: 41

In article <3tu0s4$3i2@news.cs.tu-berlin.de> Frank Bergmann <fraber@cs.tu-berlin.de> writes:
>  Within the last weeks, I reimplemented the Hierarchy Cache using
>  C. According to our profiler, the execution speed of all 
>  hierarchy operations went up by a factor of 50, while there is
>  no speedup measurable 'from the outside' (calling the program from
>  the OS). We have no idea how time gets consumed.
>
>  We actually have three theories in mind:
>	   - our profiler does't work properly
Quite possible. I don't know which profiler you use, but I know of no
profiler that knows how to handle the combination of Prolog and
C. Profilers make all sorts of assumptions about code and stack
layouts, and there's little commonality between C and Prolog in those
areas (or any others...)
>	   - the Quintus-C interface introduces a substantial overhead
There is *some* overhead --- saving and restoring Prolog registers,
doing data conversion (between the tagged representation used by
Prolog and the untagged representations of C), but unless you are
going through this in a tight inner loop, it should be in the noise.
>	   - Quintus needs to cleanup after the execution of C-code
Not the last time I looked.
>	   - ...
Are you sure that your original profiling was right? In particular, is
time being credited to the right predicates? One area that could be
very tricky is the crediting of time spent cleaning up after assert
and retract. Last time I looked (admittedly, several years ago), there
were certain combinations of assert, retract and pending choice points
that caused a lot of time being spent cleaning up the clause store and
various data structures concerned with maintaining clause access when
execution backtracked past some particular point (before that point all
the retracted stuff was not reclaimable because of choice points). And
there were still subtler interactions the details of which I can't
remember any longer.

--
Fernando Pereira
2B-441, AT&T Bell Laboratories
600 Mountain Ave, Murray Hill, NJ 07974-0636
pereira@research.att.com


