[erlang-questions] Compiling erlang core modules with +native and -smp

Kostis Sagonas kostis@REDACTED
Tue May 27 17:25:18 CEST 2008


Colm Dougan wrote:
> 
> Anyway, later when I ran some code with this erlang using the -smp
> option to 'erl' I got lots of warnings like this :
> 
> =INFO REPORT==== 27-May-2008::15:31:24 ===
> <HiPE (v 3.6.3)> Warning: not loading native code for module io_lib:
> it was compiled for an incompatible runtime system; please regenerate
> native code for this runtime system
> 
> I guess this is because the +native code is not compatible with -smp
> and modules need to be compiled with both +native *and* -smp in order
> for the native code to be used.

The latter.  In general, you can only use native code in the runtime 
system (and of course platform) which created the native code.  The 
issue is that native code might contain information (e.g. data structure 
offsets) which are runtime system specific.

> My question is - if I intend to use -smp on my runtime system would I
> be better off :
> a] compiling the erlang core modules with +native *and* -smp.  Has
> anyone experience of doing this?
> OR
> b] don't compile the core modules with +native at all
> 
> In general, is it worthwhile compiling the core modules with +native?
> i.e. have people seen decent performance wins by doing this or is it
> not really worth it?

You are asking two completely separate questions above.
The reasons for using native code are completely orthogonal to SMP.
Native code is for speed -- as a rough estimate expect a performance 
improvement of 2-3 times -- in programs using binaries is even more than 
that, in programs spending most of their time in message passing you may 
not notice any performance improvement.

Whether this improvement is something you care about, it's up to you.

However, be aware that up till R12B-2 native code has some limitations. 
The main one, in my opinion, is that you can not get precise stacktraces 
when an exception occurs. This limitation will be lifted in R12B-3.

Kostis



More information about the erlang-questions mailing list