Repository navigation
libmicrohttpd 1.0.10: header values parsed in a tight loop (a JWT costs a third) - #27
Merged
Merged
Conversation
…e tight loop A 700-byte Authorization header cost 0.86 us of a 10 us PATCH in get_req_headers; with the patch 0.31 us. Line ends, folding, bare CR/LF and the client discipline levels go through MHD's loop as before; libmicrohttpd's make check: 180/180. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
tools/mhd/patches/1.0.10/0001-header-value-fastpath.patch- applied bymhdBuild.sh(CI image, published image, runners, workstations).Why: profiling coraine's PATCH with an access token, the token's cost is MHD's header parser:
get_req_header()reads a value one character at a time, re-testing CR/LF/SP/HTAB/NUL and writingws_startback to the connection for each.get_req_headerswent from 2.0 % to 9.2 % of the broker's time with a 696-byteAuthorization: Bearer <JWT>.The patch: after a value's first character, the following characters above SP are processed exactly as it is - they are skipped in a compare-only loop. CR, LF, SP, HTAB, NUL and other control characters stop it and take MHD's path unchanged (line end, obs-fold, bare CR/LF, the client discipline levels). Under
MHD_FAVOR_SMALL_CODEthe release's code is compiled.Measured (coraine on 1 core, corDB, PATCH c50, ABBA stock/patched/patched/stock, 12 s each):
libmicrohttpd's own
make checkon the patched tree: 180 of 180 pass. coraine's functests on it (debug build, mongoc, the patched library throughLD_LIBRARY_PATH, verified in a running broker's maps): 811 of 811 pass (2026-10-13, after the merge).Upstream: not posted - a draft for Karlson2k/libmicrohttpd waits for KZ.
Merge after: nothing
🤖 Generated with Claude Code