You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/12/21 22:16:50 UTC
table_foo minor speedup
It's not big, but this patch isn't very agressive at avoiding the
pstrdup()s. It only avoids pstrdup on key or val < _end (i.e. in bss or
data sections). I used zeusbench... the test page was a .shtml which
contained just "nothing" ... I chose this only because I wanted to make
the code do a lot of table_set()s with constant args, and mod_include does
that.
without the patch: 131.50 req/s
with the patch: 132.44 req/s
(30 second sample, 30 simultaneous clients, my "usual" benchmark .conf
files described in perf-tuning, 'cept I put in MaxClient 15 because the
server box is an underpowered 40Mb laptop... I've only got 10baseT at
home.)
Anyway, there's probably a few more req/s to be had here... with a more
complete patch. But I'm not going to push it on anyone. I just like this
hack.
Dean
Index: main/alloc.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/alloc.c,v
retrieving revision 1.61
diff -u -r1.61 alloc.c
--- alloc.c 1997/12/14 20:48:54 1.61
+++ alloc.c 1997/12/21 20:57:44
@@ -720,6 +720,10 @@
return NULL;
}
+extern char _end;
+#define is_const(s) ((const char *)(s) < &_end)
+#define dup_nonconst(p, s) (is_const(s) ? (char *)(s) : pstrdup((p), (s)))
+
API_EXPORT(void) table_set(table *t, const char *key, const char *val)
{
register int i, j, k;
@@ -729,7 +733,7 @@
for (i = 0; i < t->nelts; ++i)
if (!strcasecmp(elts[i].key, key)) {
if (!done) {
- elts[i].val = pstrdup(t->pool, val);
+ elts[i].val = dup_nonconst(t->pool, val);
done = 1;
}
else { /* delete an extraneous element */
@@ -743,8 +747,8 @@
if (!done) {
elts = (table_entry *) push_array(t);
- elts->key = pstrdup(t->pool, key);
- elts->val = pstrdup(t->pool, val);
+ elts->key = dup_nonconst(t->pool, key);
+ elts->val = dup_nonconst(t->pool, val);
}
}
@@ -781,8 +785,8 @@
}
elts = (table_entry *) push_array(t);
- elts->key = pstrdup(t->pool, key);
- elts->val = pstrdup(t->pool, val);
+ elts->key = dup_nonconst(t->pool, key);
+ elts->val = dup_nonconst(t->pool, val);
}
API_EXPORT(void) table_add(table *t, const char *key, const char *val)
@@ -790,8 +794,8 @@
table_entry *elts = (table_entry *) t->elts;
elts = (table_entry *) push_array(t);
- elts->key = pstrdup(t->pool, key);
- elts->val = pstrdup(t->pool, val);
+ elts->key = dup_nonconst(t->pool, key);
+ elts->val = dup_nonconst(t->pool, val);
}
API_EXPORT(table *) overlay_tables(pool *p, const table *overlay, const table *base)
Re: table_foo minor speedup
Posted by Dean Gaudet <dg...@arctic.org>.
On Sun, 21 Dec 1997, Dean Gaudet wrote:
> without the patch: 131.50 req/s
> with the patch: 132.44 req/s
Oh I changed the #define is_const to:
#define is_const(s) ((const char *)(s) < (const char *)&(s))
Which essentially makes it so that anything not on the stack is *not*
pstrdup()d. This isn't correct by any means, but it should give an idea
how much a speedup can be gained if we meticulously went through making it
pstrdup() only when it needs to.
With that change I got 133.21 req/s.
So we can expect somewhere between a .8% and 1.3% speedup doing this. At
least on the request mix I was using... it's probably a bit different on
live servers, but probably not more than 2%.
Dean