From: MidiShare
Subject: CMU CL alien problems and performances
Date: 
Message-ID: <MidiShare_nospam-0207011246350001@macsteph.grame.fr>
Hi,

We use CMU CL with an external package  (a .so file) and we have several
problems.

- our external library use several data structures that we defined in CMU
as alien types. Whe use functions that manipulates pointer on data
structures that are allocated and desallocated by the external library.
Generally speaking, the code is very slow, even if everything is compiled.
We get warning messages like the following :

Note: Unable to optimize because:
      Could not optimize away %SAP-ALIEN: forced to do runtime 
allocation of alien-value structure.

Is there a way to get good performances using the alien package?

- our external library allocated threads (actually pthread), but it seems
that this cause a problem: we use an alien "Open" function that allocates
a thread, and a alien "Close" that close the thread: the alien code calls
pthread_cancel and pthead_join  and eveyrthing seems correct on the alien
side. But it seems that the lisp process still sees a child thread (using
ps -ax) and then using "Open" again never returns.

Is there a problem in using pthread code together with CMU CL?

- CMU Lisp is said to be multi-thread? what kind of thread ?

Thanks in advance

Stephane Letz
From: Tim Moore
Subject: Re: CMU CL alien problems and performances
Date: 
Message-ID: <9hq8t5$qso$0@216.39.145.192>
You'll probably get more help with a question like this on
··········@cons.org.

On Mon, 2 Jul 2001, MidiShare wrote:
> Hi,
> 
> We use CMU CL with an external package  (a .so file) and we have several
> problems.
> 
> - our external library use several data structures that we defined in CMU
> as alien types. Whe use functions that manipulates pointer on data
> structures that are allocated and desallocated by the external library.
> Generally speaking, the code is very slow, even if everything is compiled.
> We get warning messages like the following :
> 
> Note: Unable to optimize because:
>       Could not optimize away %SAP-ALIEN: forced to do runtime 
> allocation of alien-value structure.
> 
> Is there a way to get good performances using the alien package?

It definitely helps to (proclaim (inline ...)) the external interface
functions.  However, it's hard to tell if this is your problem without
seeing the code.

What's "slow?"

> 
> - our external library allocated threads (actually pthread), but it seems
> that this cause a problem: we use an alien "Open" function that allocates
> a thread, and a alien "Close" that close the thread: the alien code calls
> pthread_cancel and pthead_join  and eveyrthing seems correct on the alien
> side. But it seems that the lisp process still sees a child thread (using
> ps -ax) and then using "Open" again never returns.
> 
> Is there a problem in using pthread code together with CMU CL?

Uh, yeah.  CMUCL doesn't use pthreads at all (yet).  You haven't said what
system your running on, but it's quite likely that your system's pthreads
is implemented via hacks in the C library; CMUCL is most likely not
calling those C functions.

> - CMU Lisp is said to be multi-thread? what kind of thread ?

CMUCL threads :)  That is, multi-threading is implemented through Lisp
stack groups and scheduling hacks in blocking I/O calls.

Tim