[BusyBox] apt-get, dpkg applet progress

Glenn McGrath bug1 at optushome.com.au
Sat Apr 27 06:30:04 UTC 2002


Just a note incase anyone is wondering how im going on my plas to one day
implement an apt-get applet.

Believe it or not, im still trying to get the data structures right, im
getting there though, the current data structures are as follows.

I have five hashtables, each allocated with 1 malloc call as metioned
below, the figures are after passing woody available and status file (only
storing system type fields)

The following are all strings, they have an index at the start of the
block to reference them.
 - package names hashtable, 11026 entries, uses 170kB memory
 - upstream version numbers, 2728 entries, uses 27kB
 - revision numbers, 162 entries, uses 1.2 kB

The following 2 store fixed length structs and are just stored one after
each in the block
 - package_name and version hashtable, 11997 entries,
85kB (not counting local stack contents) it stores the location of a
package name, upstream version and revison in the string hashtables, it
also has a pointer to where i store dependency info in a stack like
structure, i think this stack may be whats using lots of memory, im
working on reorganising it next.
 - package_name, version and operator hastable, 3241 entries, only 2 bytes
per entry, 6kB

So all up the data storage shouldnt be that much, but looking at the
dmalloc log i see.

heap: 0x8090000 to 0x8221000, size 1642496 bytes (401 blocks)
alloc calls: malloc 70863, calloc 95125, realloc 37217, free 165988
total memory allocated: 3507073 bytes (203205 pnts)
max in use at one time: 529560 bytes (8507 pnts)
max alloc rounding loss: 226760 bytes (29%)
max memory space wasted: 538016 bytes (41%)
final user memory space: basic 227, divided 89, 1294336 bytes
final admin overhead: basic 6, divided 79, 348160 bytes (21%)

So it needs 1.6MB of heap space to store the basic package info for all
packages (which is required to implement apt-get), which is more than i
expect, i hope to get it below 1 MB.

All it does at the moment is parse the status and available files and list
immediate dependencies of a specified package name, im not worrying about
implementing any proper functionality till i get the memory usage down, if
anyone is interested, a patch with my current progress is at the link
below.

http://people.debian.org/~bug1/busybox/apt_get_dpkg.20040427.diff.bz2



Glenn



More information about the busybox mailing list