Skip to content
This repository was archived by the owner on Feb 16, 2026. It is now read-only.

Optimize req.method == "foo"#4438

Merged
nigoroll merged 3 commits intovarnishcache:masterfrom
cartoush:optimize_req_method
Jan 19, 2026
Merged

Optimize req.method == "foo"#4438
nigoroll merged 3 commits intovarnishcache:masterfrom
cartoush:optimize_req_method

Conversation

@cartoush
Copy link
Copy Markdown
Contributor

Resolves #4343

This PR optimizes VCL's req.method == "foo" by running strcmp on req.method as early as possible only once and initializing a bitmap with the result. Thanks to that the following strcmp's call are replaced with binary AND operations.

This commit introduces the 'wkm' field in struct
http, this will allow us to evaluate requests'
method once with strcmp and store the result in a
bitmap, effectively transforming strcmp calls into
binary AND operations.
In this commit the http_SetWellKnownMethod is
introduced and called on req/bereq.method
initialization and modification.
@cartoush cartoush force-pushed the optimize_req_method branch from 4840ffa to 136ea89 Compare January 19, 2026 13:35
@nigoroll
Copy link
Copy Markdown
Member

bugwash: http_method_eq to take the WKM_ enum directly, then merge

Here the http_method_eq macro is updated to use
the http->wkm field in order to evaluate a
request's method instead of vstrcmp().
This commit also introduces the http_method_among
that allows checking whether a request's method
can be found in a set of well known HTTP methods.
@cartoush cartoush force-pushed the optimize_req_method branch from 136ea89 to 382ea77 Compare January 19, 2026 14:30
@nigoroll nigoroll merged commit 382ea77 into varnishcache:master Jan 19, 2026
9 of 10 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimizer req.method

2 participants