[Mono-devel-list] Proposal: Library Loading

Michal Moskal malekith at pld-linux.org
Wed Apr 14 05:11:13 EDT 2004


On Wed, Apr 14, 2004 at 01:31:49AM -0400, Miguel de Icaza wrote:
> For example, Gtk# would install something like this:
> 
> <configuration>
> 	<dllmap dll="libglib-2.0-0.dll" target="libglib-2.0.so.0.200.3" />
> </configuration>

But what happens when you install new version of libglib-2.0 (100%
binary compatible)? You need to run mlibconf again. So postinstall
scripts in any packaging system would need to run mlibconf. I believe
most distros will have problems with this.

> The benefit is that Mono only needs to open *one* configuration file
> instead of having to get a directory listing, and load multiple files,
> which impacts startup time. 

Premature optmization is root of all evil :-)

#v+
#include <sys/types.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
        DIR *d;
        struct dirent *e;
        char name[100];
        char buf[10000];
        FILE *f;
 
        d = opendir("testdir");
 
        if (d == NULL) {
                perror("testdir");
                exit(1);
        }
 
        while ((e = readdir(d)) != NULL) {
                if (e->d_name[0] == '.')
                        continue;
                snprintf(name, sizeof (name), "testdir/%s", e->d_name);
                f = fopen(name, "r");
                if (f == NULL) {
                        perror(name);
                        exit(1);
                }
                fread(buf, sizeof(buf), 1, f);
                fclose(f);
        }
 
        closedir(d);
 
        exit(0);
}
#v-

I run this program against directory with 1000 small files. It took
0.03s on my athlon box and 0.15s on Pentium 266 (with heavy load). Now
consider that you will have 50 not 1000 files there, so it will take
1ms on modern box.  Nowhere near other startup costs.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
: When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?



More information about the Mono-devel-list mailing list