dean gaudet wrote:

>On Wed, 27 Jun 2001, Brian Pane wrote:
>
>>+/* Information to which an extension can be mapped
>>+ */
>>+typedef struct extension_info {
>>+    char *forced_type;                /* Additional AddTyped stuff */
>>+    char *encoding_type;              /* Added with AddEncoding... */
>>+    char *language_type;              /* Added with AddLanguage... */
>>+    char *handler;                    /* Added with AddHandler... */
>>+    char *charset_type;               /* Added with AddCharset... */
>>+} extension_info;
>>+
>>
>
>looks like you're causing the data structure to use a fair amount more
>memory ... or at least spreading out the data onto more cache lines.
>you've got 5 pointers per extension when only 1 is typically needed right?
>
Right--the code is intentionally sacrificing some memory to gain speed.
In the original,  there were 5 tables, and each extension was looked up
in each table on each request (and most of these lookups typically yielded
no match).  In my patch, there's a single lookup that retrieves the 
extension_info
structure (in which most of the fields are NULL, but retrieving a field 
value
from the struct is cheap compared to the hash table lookup).

--Brian

>
>an alternative is to make the "extension info" part of the key to the hash
>table.  so rather than just using the extension to look up an
>extension_info and then extract the pointer field_name, you use
>(extension, field_name) to look up a pointer.
>
>you could do this by prepending some constant to the extension, like "0" =
>forced_type, "1"  = encoding_type, ...
>
>(or perhaps APR hash tables are generic enough that you can use different
>keys other than strings, i haven't looked.)
>
>-dean
>
>
>



Reply via email to