AminetAminet
Search:
84783 packages online
About
Recent
Browse
Search
Upload
Setup
Services

dev/c/MemPools.lha

Mirror:Random
Showing: ppc-morphos icongeneric icon
No screenshot available
Short:Fast malloc() replacement, v1.3
Author: mandree at dosis.uni-dortmund.de jochen.wiedmann at uni-tuebingen.de
Uploader:mandree dosis uni-dortmund de
Type:dev/c
Architecture:m68k-amigaos
Date:1998-03-13
Replaces:dev/c/MemPools*.lha
Download:dev/c/MemPools.lha - View contents
Readme:dev/c/MemPools.readme
Downloads:646

CHANGES by Matthias Andree
==========================

1.2 -> 1.3 (1998-03-12)

    Since  DICE  is  to  be  considered  entirely  out-of-date,  I  removed  all
    references  to  DICE, and reworked things a bit. I was trying to link a tool
    with SAS/C 6.58, which - according to MUNGWALL SNOOP output - stuck with  4k
    blocks.  Investigating this further, I found that mempools.lib did not offer
    regargs entry points, thus, my tool stuck with SAS/C stdlib  pooling  (which
    uses  4k  blocks  currently).  I  fixed  this  flaw  and  some  little other
    peculiarities.

    NOTE: the debug feature Jochen Wiedmann stated below is indeed  included  in
    the  sources,  but  cannot currently be used to automatically build an SAS/C
    mempoolsd.lib.

    NOTE: The make files are a horrible mess.



MemPools - malloc() replacement using standard Exec memory pools
================================================================

Many people don't like using malloc() and similar functions because  they  think
it's  too  slow  and  gives too much overhead. Well, as far as I can say they're
alright, at least for users of SAS/C: The Exec pool  functions  seem  to  be  at
least  5 times faster and it can even be faster than the malloc() of GNU C! (See
"Timings" below.)

Other people like malloc(): It's portable and rather easy to use. I  am  one  of
these, however I don't want to loose the speed of pool functions.

The mempools package is a link library with the  functions  malloc(),  calloc(),
realloc(),  strdup() and free(). It replaces the compilers own functions by just
linking against this library. No additional work  is  required  as  the  library
takes use of the compilers auto- initialization facility.

Ths autoinitialization restricts use of the mempools library to users  of  SAS/C
and gcc.

Note, that pools are available not  only  for  users  of  OS  3.x!  The  current
amiga.lib  offers  replacements  which  call  exec.library, if the OS is 3.x and
emulate pools otherwise. The MemPools library uses this replacements.


A debugging possibility very similar to Mungwall is integrated into the library,
which  is  enabled  by  compiling  with  -DDEBUG. The makefiles provide a target
"mempoolsd.lib" which does just that.



1.) Disclaimer: Copyrights, (No) Warranty
-----------------------------------------

This program is Copyright (C) 1994  Jochen Wiedmann
				    Am Eisteich 9
				    72555 Metzingen
				    Germany

				    Phone: (0049) +7123 / 14881
				    Mail: jochen.wiedmann@uni-tuebingen.de

All changes are Copyright (C) 1998  Matthias Andree
				    Stormstr. 14
				    58099 Hagen
				    Germany

				    Phone: +49-(0)23 31-96 30 72
				    Mail: mandree@dosis.uni-dortmund.de


Permission is granted to make and distribute either verbatim and modified copies
of this documentation and the library MemPools provided the copyright notice and
this permission notice are preserved on all copies and the "GNU  General  Public
License" (in the file COPYING) is distributed as well.

The authors give ABSOLUTELY NO warranty that  the  software  described  in  this
documentation  and  the results produced by them are correct. The authors cannot
be held responsible for ANY damage resulting from the use of this software.



2.) Installation
----------------

There are two libraries  included  in  the  distribution,  it  depends  on  your
compiler  which  one  you  need:  mempools.lib  is for SAS/C, its destination is
sc:lib. libmempools.a is the GNU-c version which should go to GNU:lib.

If you want to recreate them, just type smake (SAS/C) or make (GNU-c).



3.) Usage
---------

All you have to do is to link against the appropriate mempools library.

a) SAS/C

    Add the option LIB mempools.lib to your compiler  statement.  By  using  the
    "scopts" program you can get this automatically, too.

b) gcc

    Add the option -lmempools to your compiler statement. I don't  know  if  gcc
    can handle this automatically. Probably someone can enlighten me?

However, you might be interested in controlling the pools attributes.  This  can
be  done  by  creating global variables __MemPoolPuddleSize, __MemPoolThreshSize
and __MemPoolFlags  which  correspond  to  the  arguments  of  the  CreatePool()
function.  For example, if you want to modify the puddle size (this can increase
speed, see "Timings" below), just add  the  following  line  somewhere  to  your
program:

    ULONG __MemPoolPuddleSize = 16384;  /*  Default: 4096       */

Or if you want malloc() to obtain chip memory, just write

    #include <exec/memory.h>
    ULONG __MemPoolFlags = MEMF_CHIP;   /*  Default: MEMF_ANY   */




4.) Timings
-----------

I wrote a little timing program. (I don't claim that it is very  good,  probably
someone can write a better one.) I was rather surprised about the results:

    Compiler    Time (Mins:Secs)    Notes

    SAS/C       1:17,66             SAS/C uses an own pool system.
				    Thus, the exit() function is
				    rather fast. malloc(), however,
				    seems to be slow.

    gcc         0:12,84 (ixemul)    gcc uses a pool system which is
		0:14,34 (libnix)    rather close to Exec pools. This
				    gives good results.

    MemPools    0:15,10 (4096)      By increasing the puddle size
		0:12,14 (8192)      (see "Usage") you get better
		0:10,80 (16384)     results! It seems worth to try a
				    little bit.


Contents of dev/c/MemPools.lha
 PERMSSN    UID  GID    PACKED    SIZE  RATIO     CRC       STAMP          NAME
---------- ----------- ------- ------- ------ ---------- ------------ -------------
[generic]                  911    1808  50.4% -lh5- d5bc Mar 12  1998 calloc.c
[generic]                 6993   17982  38.9% -lh5- dc3e Mar 12  1998 copying
[generic]                 1240    2638  47.0% -lh5- c039 Mar 12  1998 free.c
[generic]                 1578    3708  42.6% -lh5- 1051 Mar 12  1998 init.c
[generic]                 1080    3336  32.4% -lh5- aef3 Mar 12  1998 libmempools.a
[generic]                 1230    3243  37.9% -lh5- d350 Mar 12  1998 Makefile
[generic]                 1174    2454  47.8% -lh5- ab57 Mar 12  1998 malloc.c
[generic]                   59      59 100.0% -lh0- 1c72 Mar 12  1998 MemPoolFlags.c
[generic]                   60      60 100.0% -lh0- e35b Mar 12  1998 MemPoolPuddleSize.c
[generic]                  992    2055  48.3% -lh5- 8eca Mar 12  1998 mempools.h
[generic]                  845    1876  45.0% -lh5- 0761 Mar 12  1998 mempools.lib
[generic]                 2634    5609  47.0% -lh5- 3e69 Mar 12  1998 MemPools.readme
[generic]                   59      59 100.0% -lh0- b808 Mar 12  1998 MemPoolThreshSize.c
[generic]                  183     401  45.6% -lh5- f61e Mar 12  1998 my_alib_protos.h
[generic]                  970    1974  49.1% -lh5- 7ff2 Mar 12  1998 realloc.c
[generic]                  130     212  61.3% -lh5- de68 Mar 12  1998 scoptions
[generic]                 1336    3248  41.1% -lh5- 55e5 Mar 12  1998 SMakefile
[generic]                  901    1783  50.5% -lh5- ef04 Mar 12  1998 strdup.c
[generic]                 1826    5029  36.3% -lh5- 727a Mar 12  1998 TimeMem.c
[generic]                 1308    2861  45.7% -lh5- 3481 Mar 12  1998 TimeProg.c
---------- ----------- ------- ------- ------ ---------- ------------ -------------
 Total        20 files   25509   60395  42.2%            Mar 12  1998
Page generated in 0.01 seconds
Aminet © 1992-2024 Urban Müller and the Aminet team. Aminet contact address: <aminetaminet net>