Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: eb44b6cfaa64548b24158a0550d3f6850a65d513
https://github.com/WebKit/WebKit/commit/eb44b6cfaa64548b24158a0550d3f6850a65d513
Author: Anne van Kesteren <[email protected]>
Date: 2026-08-17 (Mon, 17 Aug 2026)
Changed paths:
M Source/WTF/wtf/URLParser.cpp
M Source/WTF/wtf/URLParser.h
M Source/WTF/wtf/text/CodePointIterator.h
M Tools/TestWebKitAPI/Tests/WTF/URLParser.cpp
Log Message:
-----------
Vectorize URL component parsing (path, query, fragment, opaque path)
https://bugs.webkit.org/show_bug.cgi?id=319750
Reviewed by Yusuke Suzuki.
The URL parser walks its input one code point at a time, and for each one
checks whether it is a component delimiter or a member of that component's
percent-encode set. For the common case of long runs of ordinary characters
(path segments, query strings, fragments) this is the dominant cost.
This patch scans those runs with SIMD to find the first code point that
actually needs individual handling -- a delimiter, an encode-set member, a
control, or a non-ASCII code point -- and the parser then consumes the whole
preceding run at once. Every "trivial" code point in such a run is copied
verbatim, so:
- When the output is unchanged from the input (canonical URLs, no syntax
violation), the run is simply skipped and the offsets advanced.
- When the output buffer is being built (relative URLs and other
non-canonical input), the run is appended in a single bulk copy rather than
one code point at a time.
Because SIMD::find only vectorizes runs of at least one 16-byte stride, and
the bulk-append path must additionally scan a run before copying it, short
buffer-building runs are gated behind a one-stride length guard so they keep
using the existing per-code-point loop; the fast (no-copy) path is always
scanned since its leaner loop wins even below a stride.
Measured with a same-binary A/B of the parser (SIMD scanning on vs. off):
- On the corpus used by PerformanceTests/Parser/url-parser.html
(resources/final-url-en, 82,257 real-world absolute URLs), throughput
improves ~1.33x (203 -> 153 ns/URL, denoised with 10 runs).
- On a corpus of URLs extracted from the HTML Standard (66,944 hrefs,
~77% relative fragments), throughput improves ~1.3-1.4x.
- Synthetic long components (path/query/fragment of ~100 code points) improve
3-4x, with the win scaling with component length. Short components are
unchanged.
Canonical link: https://commits.webkit.org/319305@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications