[mercury-users] Re: Can Mercury be used to build an API?

Fergus Henderson fjh at cs.mu.oz.au
Fri Apr 4 04:18:45 AEST 1997


Peter Ludemann, you wrote:
> 
> It's still not clear whether Mercury fits my requirements or not.  I
> guess it all hinges on how "heavy" the Mercury environment is

I tried a fairly trivial example program with a C main calling a very simple
mercury library (the program is samples/c_interface/c_calls_mercury
from the Mercury distribution), and tweaked a couple of things to minimize
memory usage.  I then compared this with the usual C hello world program.

Well, the output of `ps' and `size' is somewhat confusing, but I think
the overhead of the Mercury stuff is about an extra 48k code (.text),
8k read-only data (.rodata), 4k initialized read-write data (.data etc.),
28k uninitialized data (.bss), and 56k for the (very small) Mercury heap
and Mercury stacks; i.e. a total overhead of 56k read-only and 88k read-write,
or a grand total of roughly 150k.

N.B.  Please take these figures with a large grain of salt! 
There is a non-zero possibility that I have misinterpreted the output
of `ps' and `size'.  That was with Linux libc 5.0.9; on another machine
with Linux libc 4.3.12, I get about the same figures for the C->Mercury
program, but better figures for the C program, so the overhead is
higher.  Also, that is with the MERCURY_OPTIONS environment variable
set to "-sd1 -sn1 -zd1 -zn1 -p1" to allocate the absolute minimum size
for the Mercury stacks; if your program uses a non-trivial amount of
space on the Mercury stack or heap, you'd have to allocate some space
for that.  The other tweak I made was to recompile the conservative
garbage collector with `-DSMALL_CONFIG'.  I'm not sure how much
difference that makes.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the users mailing list