This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: mallinfo not 64-bit clean


I'm concerned about getting a mallinfo replacement that allows
efficient access to malloc statistics.

Since this is all being done inside of one process, it seems
excessive to do a bunch of text processing to generate xml 
and then immediately do a bunch of text processing to extract the
data back out.

I agree that an implementation is required that provides an abstraction
that is not tied to a particular implementation of malloc, that can be
extended and altered over time, yet also provide efficient access to
data.

I've discussed this with a few others, as we have been bit by this same
problem that Andreas Jaeger encountered to start this off.  Gathering
statistics on 64 Opteron (ok different processor), are rather useless
when
what you get for memory usage on a process that consumes 9Gb of ram is
1Gb.

How about the following alternative!  Check out ioctl(2).  Here is an
interface that is extensible, time proven, etc.
int get_malloc_statistics(int request, ...)

You can setup some defines for the request,
#define  MALLOC_ALL_ARENAS   000000  /* get summary data for all arena's
*/
#define  MALLOC_CURR_ARENA   000001  /* get data for current arena */
#define  MALLOC_SELECT_ARENA 000002  /* specify arena of interest */

#define  MALLOC_NUM_ARENAS                    000010 /* Query number of
arenas */
#define  MALLOC_TOTAL_REQUESTED_MEMORY        000020 /* Sum of all
requests (long long) */
#define  MALLOC_TOTAL_REQUESTS                000030 /* Count of all
requests */
#define  MALLOC_ALLOCATIONS_IN_USE            000040 /* Active user
allocations */
#define  MALLOC_NUMBER_OF_ALLOCATIONS         000050 /* Count of Active
Allocations */
#define  MALLOC_OVERHEAD                      000060 /* malloc's
overhead storage */
#define  MALLOC_TOTAL_REQUESTED_FROM_SYSTEM   000070 /* storage
requested from system */
...

and make calls like
int n;
success = get_malloc_statistics(MALLOC_NUM_ARENAS, &n)
size_t tot_mem;
for (i = 0; i < n ; i++) {
   success = get_malloc_statistics(
          MALLOC_SELECT_ARENA|MALLOC_TOTAL_ALLOCATIONS_IN_USE, &tot_mem,
n)
   ...
}
...
success =
get_malloc_statistics(MALLOC_ALL_ARENAS|MALLOC_ALLOCATIONS_IN_USE,
&tot_mem)
// since some languages (like std c++ right now) don't support long
long....
struct big { long overflow; long count} big;
success =
get_malloc_statistics(MALLOC_ALL_ARENAS|MALLOC_TOTAL_REQUESTED_MEMORY,
&tot_mem)
...

This interface is time tested, efficient, extensible, etc.  Not only
does this allow
moving malloc_stats out of malloc, so stdio isn't there, it also avoids
adding
in a bunch of data formatting commands into malloc.

--------------
Stephen Dum            steve_dum at mentor dot com    (503)-685-7743
Mentor Graphics Corp.  8005 S.W. Boeckman Rd.   Wilsonville, Or
97070-7777


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]