On Thu, Nov 26, 2026 at 11:52 AM Branko Čibej via dev
<[email protected]> wrote:
>
> No, I won't like it, but I also won't keep harping on that.

Sorry, and thanks.

> If everyone else is happy with having such unmaintainable code in the tree, I 
> won't go against consensus.

Well, I'm not sure it's less maintainable than an additional python
generator, generated .inc files, a private header and some Makefile.in
glue for a single function improvement?
Also the `switch (s[0])` or `switch (strlen(s))` is a common C
pattern, hopefully the REST_EQ{,n}() macros added in v2 help keeping
the code readable..

> I will, however, point out that you're doing this optimisation – which I 
> admit is twice as fast as the perfect hash – based on, let me see, I think 
> it's exactly zero metrics from real-world usage.

Not quite, apr_uri_port_of_scheme() shows in httpd benchmarks
(mod_proxy cases mainly). There was a change some times ago (can't
point to it right now) which took it in the fast path and it was
noticeable (IIRC jfclere noticed too).

For completeness, here are the new (microbenchmark) numbers:

scheme       trunk  perfect H  H++ uchmap      v1      v2
http          12.2       49.0        36.0    17.3    14.1
ftp           20.9       44.7        31.9    15.7    12.8
https         30.2       52.6        40.9    30.9    16.1
gopher        37.0       57.4        47.4    20.2    19.5
ldap          45.5       50.6        36.5    13.8    14.3
nntp          52.5       49.8        36.5    17.4    16.2
snews         61.6       53.9        40.9    17.7    18.4
imap          69.1       50.4        35.8    17.1    16.1
pop           78.0       47.8        31.6    16.8    13.2
sip           85.6       48.1        31.9    24.8    17.4
rtsp          94.3       51.7        35.8    19.4    14.4
wais         101.7       47.2        36.4    18.3    15.6
z39.50r      112.4       60.1        53.4    22.6    20.1
z39.50s      120.6       61.4        52.4    37.6    19.9
prospero     129.8       64.1        56.6    26.1    28.6
nfs          133.1       44.5        31.5    24.1    19.8
tip          143.4       44.7        32.3    15.3    12.3
acap         151.4       48.9        35.7    19.6    14.0
telnet       160.5       56.6        47.1    32.7    26.3
ssh          167.3       46.4        32.3    34.6    21.5
HTTP          12.4       47.9        35.4    17.5    13.9
Prospero     125.6       66.7        56.6    26.1    28.5
SSH          167.8       46.1        32.0    34.8    21.7
unknown      168.1       60.6        37.4     5.2     5.4
mean          95.3       51.7        39.8    22.0    17.6
vs trunk        --       -46%        -58%    -77%    -82%

* "H++ uchmap" is "perfect H" with static tables and one pass that
folds case through apr_cstr's ucharmap, hashes and buffers each
character, then confirms the match inline instead of calling
strcasecmp(): about 23% faster than H, and right on EBCDIC too (I had
claude these changes).

Cheers;
Yann.

Reply via email to