Subject: Re: kern/8321: Native ELF execution is slower than Native A_OUT
To: None <netbsd-bugs@netbsd.org>
From: bill@psych.uw.edu.pl <bill@psych.uw.edu.pl>
List: netbsd-bugs
Date: 09/04/1999 21:26:37
hi,
here is a patch for file stolen from FreeBSD.
before:
$ time file /etc/passwd
/etc/passwd: ASCII text
1.06s real 0.40s user 0.34s system
after:
$ time file.patched /etc/passwd
/etc/passwd: ASCII text
0.21s real 0.09s user 0.04s system
diff -uNr file/apprentice.c file.patched/apprentice.c
--- file/apprentice.c Sat Sep 4 20:51:09 1999
+++ file.patched/apprentice.c Sat Sep 4 20:42:17 1999
@@ -56,7 +56,7 @@
static void eatsize __P((char **));
static int maxmagic = 0;
-
+static int alloc_incr = 256;
static int apprentice_1 __P((const char *, int));
int
@@ -189,9 +189,9 @@
struct magic *m;
char *t, *s;
-#define ALLOC_INCR 20
if (nd+1 >= maxmagic){
- maxmagic += ALLOC_INCR;
+ maxmagic += alloc_incr;
+
if ((magic = (struct magic *) realloc(magic,
sizeof(struct magic) *
maxmagic)) == NULL) {
@@ -201,7 +201,8 @@
else
exit(1);
}
- memset(&magic[*ndx], 0, sizeof(struct magic) * ALLOC_INCR);
+ memset(&magic[*ndx], 0, sizeof(struct magic) * alloc_incr);
+ alloc_incr *= 2;
}
m = &magic[*ndx];
m->flag = 0;
diff -uNr file/file.h file.patched/file.h
--- file/file.h Sat Sep 4 20:51:09 1999
+++ file.patched/file.h Sat Sep 4 20:33:21 1999
@@ -37,7 +37,7 @@
#ifndef HOWMANY
# define HOWMANY 8192 /* how much of the file to look at */
#endif
-#define MAXMAGIS 1000 /* max entries in /etc/magic */
+#define MAXMAGIS 5000 /* max entries in /etc/magic */
#define MAXDESC 50 /* max leng of text description */
#define MAXstring 32 /* max leng of "string" types */