Hi, please find attached four patches that reduce the CPU cost of the normalize-uri actions. The first three replace byte-at-a-time loops in src/uri_normalizer.c and remove a repeated scan in the query sort comparator; the last one extends the reg-test, whose existing cases are all too short to reach the paths that changed. None of them changes the output.
I sent this series on Sep 3rd, but only the cover letter made it to the list - the patches were attachments and never appeared in the archive. Resending properly with git send-email this time. Sorry for the noise. Measured on a 24-core AMD EPYC 7413, gcc 8.5.0, -O2 -march=native, keep-alive, CPU time per request: URL before after change 8 byte path 266.4 us 266.0 us none measurable 60 parameter query 314.02 us 311.17 us -0.9% 427 parameter query 1137.52 us 1062.53 us -6.6% Those are whole-request figures. Against a build with the six actions removed the same 427 parameter case costs 989.67 us, so what the actions themselves add goes from 218.3 us to 142.9 us, about a third less. The gain comes almost entirely from the comparator change and scales with the parameter count, so short URIs get nothing out of it. One point worth raising: the second patch needs a small struct instead of a bare struct ist. It stays at 16 bytes on 64-bit, so the ERR_ALLOC threshold is unchanged there, but on 32-bit it grows from 8 to 12 bytes and that bound drops by a third. I looked for a way to avoid this and did not find one that holds: 16-bit lengths would silently truncate since tune.bufsize can go up to INT_MAX, and dropping the length field does not work because qsort reorders the parameters, so it cannot be recovered from neighbouring pointers afterwards. I can still rework the patch to keep the old bound at the cost of the rescan if you prefer. Best regards Youngkwang Lee (4): OPTIM: uri_normalizer: bulk-copy runs between percent signs OPTIM: uri_normalizer: compute query parameter names only once OPTIM: uri_normalizer: bulk-copy the parts around encoded fragments REGTESTS: uri_normalizer: cover long URIs and many query parameters reg-tests/http-rules/normalize_uri.vtc | 38 +++++- src/uri_normalizer.c | 169 ++++++++++++++++--------- 2 files changed, 146 insertions(+), 61 deletions(-) -- 2.45.1

